[U-Boot] [PATCH 4/4] ARM: at91: atmel_nand: add code to check the ONFI parameter ECC requirement
Scott Wood
scottwood at freescale.com
Fri Jun 14 22:38:18 CEST 2013
On 06/14/2013 06:20:42 AM, Josh Wu wrote:
> +static int pmecc_choose_ecc(struct atmel_nand_host *host,
> + struct nand_chip *chip,
> + int *cap, int *sector_size)
> +{
> + /* Get ECC requirement from ONFI parameters */
> + *cap = *sector_size = 0;
> + if (chip->onfi_version) {
> + if (!get_onfi_ecc_param(chip, cap, sector_size))
> + MTDDEBUG(MTD_DEBUG_LEVEL1, "ONFI params,
> minimum required ECC: %d bits in %d bytes\n",
> + *cap, *sector_size);
> + else
> + printk(KERN_WARNING "NAND chip ECC reqirement
> is in Extended ONFI parameter, we don't support yet.\n");
Both of these prints are dev_info in Linux. While I tend to agree that
the first print should be debug and the second an error (or at least a
warning), it doesn't make much sense to use KERN_WARNING in U-Boot-only
code (and even in Linux, explicit use of KERN_WARNING is deprecated in
favor of pr_warn or dev_warn).
> + } else {
> + printk(KERN_WARNING "NAND chip is not ONFI compliant,
> assume ecc_bits is 2 in 512 bytes");
> + }
> + if (*cap == 0 && *sector_size == 0) {
> + /* Non-ONFI compliant or use extended ONFI parameters */
> + *cap = 2;
> + *sector_size = 512;
> + }
> +
> + /* If head file doesn't specify then use the one in ONFI
> parameters */
> + if (host->pmecc_corr_cap == 0) {
> + /* use the most fitable ecc bits (the near bigger one )
> */
> + if (*cap <= 2)
> + host->pmecc_corr_cap = 2;
> + else if (*cap <= 4)
> + host->pmecc_corr_cap = 4;
> + else if (*cap < 8)
> + host->pmecc_corr_cap = 8;
> + else if (*cap < 12)
> + host->pmecc_corr_cap = 12;
> + else if (*cap < 24)
> + host->pmecc_corr_cap = 24;
> + else
> + return -EINVAL;
Why are some of these "<=" and others "<"?
-Scott
More information about the U-Boot
mailing list