On Tue, 21 Apr 2020 18:46:37 +0200 Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > There is no need for separate parameter page reads, the delay penalty > is negligible so let's do read the three copies in one go. Same comment as for the ONFI param page read. Let's make sure we don't break existing users by using exec_op()'s check capability. > > Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> > --- > drivers/mtd/nand/raw/nand_jedec.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/drivers/mtd/nand/raw/nand_jedec.c b/drivers/mtd/nand/raw/nand_jedec.c > index 4cc1ea512887..befe8c29b505 100644 > --- a/drivers/mtd/nand/raw/nand_jedec.c > +++ b/drivers/mtd/nand/raw/nand_jedec.c > @@ -23,7 +23,7 @@ int nand_jedec_detect(struct nand_chip *chip) > { > struct mtd_info *mtd = nand_to_mtd(chip); > struct nand_memory_organization *memorg; > - struct nand_jedec_params *p; > + struct nand_jedec_params *p = NULL, *pbuf; > struct jedec_ecc_info *ecc; > int jedec_version = 0; > char id[5]; > @@ -38,25 +38,19 @@ int nand_jedec_detect(struct nand_chip *chip) > return 0; > > /* JEDEC chip: allocate a buffer to hold its parameter page */ > - p = kzalloc(sizeof(*p), GFP_KERNEL); > - if (!p) > + pbuf = kzalloc(sizeof(*pbuf) * 3, GFP_KERNEL); > + if (!pbuf) > return -ENOMEM; > > - ret = nand_read_param_page_op(chip, 0x40, NULL, 0); > + ret = nand_read_param_page_op(chip, 0x40, pbuf, 3 * sizeof(*pbuf)); > if (ret) { > ret = 0; > goto free_jedec_param_page; > } > > for (i = 0; i < 3; i++) { > - ret = nand_read_data_op(chip, p, sizeof(*p), true); > - if (ret) { > - ret = 0; > - goto free_jedec_param_page; > - } > - > - crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)p, 510); > - if (crc == le16_to_cpu(p->crc)) > + crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)&pbuf[i], 510); > + if (crc == le16_to_cpu(pbuf[i].crc)) > break; > } > > @@ -65,6 +59,8 @@ int nand_jedec_detect(struct nand_chip *chip) > goto free_jedec_param_page; > } > > + p = pbuf; > + > /* Check version */ > val = le16_to_cpu(p->revision); > if (val & (1 << 2)) ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/