lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 13 Mar 2013 22:17:38 -0700 From: Brian Norris <computersforpeace@...il.com> To: Huang Shijie <b32955@...escale.com> Cc: dwmw2@...radead.org, artem.bityutskiy@...ux.intel.com, linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org Subject: Re: [PATCH v5 2/3] mtd: add the support to parse out the full-id nand type Hi Huang, A few nitpicks, and a few real comments. On Wed, Mar 13, 2013 at 7:59 PM, Huang Shijie <b32955@...escale.com> wrote: > When we meet a full-id nand type which @mfr_id is true, we can use > the find_full_id_nand() to parse out the neccessary information for a s/neccessary/necessary > nand chip. > > If we meet a non full-id nand type, we can handle it in the lagacy way. s/lagacy/legacy > Signed-off-by: Huang Shijie <b32955@...escale.com> > --- > drivers/mtd/nand/nand_base.c | 36 +++++++++++++++++++++++++++++++++--- > 1 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index 72eada2..b7ad9fd 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -3123,6 +3123,30 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, > chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; > } > > +static inline bool is_full_id_nand(struct nand_flash_dev *type) > +{ > + return type->mfr_id; > +} If we restore the id_len field (as I recommended in reply to the cover letter), then I think this check would be better performed as: return !type->id_len; That would really be a more specific and accurate test and can compensate for some wildly unlikely case in which a manufacturer uses manufacturer ID = 0. > +static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, > + struct nand_flash_dev *type, u8 *id_data, int *busw) > +{ > + if (!strncmp(type->id, id_data, 8)) { > + mtd->writesize = type->pagesize; > + mtd->erasesize = type->erasesize; > + mtd->oobsize = type->oobsize; > + > + chip->cellinfo = id_data[2]; > + chip->chipsize = (uint64_t)type->chipsize << 20; > + chip->options |= type->options; > + > + *busw = type->options & NAND_BUSWIDTH_16; > + > + return true; > + } > + return false; > +} > + > /* > * Get the flash and manufacturer id and lookup if the type is supported. > */ > @@ -3174,9 +3198,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > if (!type) > type = nand_flash_ids; > > - for (; type->name != NULL; type++) > - if (*dev_id == type->dev_id) > - break; > + for (; type->name != NULL; type++) { > + if (is_full_id_nand(type)) { > + if (find_full_id_nand(mtd, chip, type, id_data, &busw)) > + goto ident_done; > + } else { > + if (*dev_id == type->dev_id) Combine the previous two lines to: } else if (*dev_id == type->dev_id) { > + break; > + } > + } > > chip->onfi_version = 0; > if (!type->name || !type->pagesize) { Brian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists