From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Fri, 14 Jun 2013 15:38:18 -0500 Subject: [U-Boot] [PATCH 4/4] ARM: at91: atmel_nand: add code to check the ONFI parameter ECC requirement In-Reply-To: <1371208842-28909-5-git-send-email-josh.wu@atmel.com> (from josh.wu@atmel.com on Fri Jun 14 06:20:42 2013) Message-ID: <1371242298.2996.9@snotra> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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