Message ID | 20220713110616.305444-4-michael@amarulasolutions.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Michael, On Wed, Jul 13, 2022 at 1:06 PM Michael Trimarchi <michael@amarulasolutions.com> wrote: > > chip points to mtd. Passing chip is enough to have a reference > to mtd when is necessary > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- > drivers/mtd/nand/raw/nand_base.c | 24 +++++++++++++----------- > include/linux/mtd/rawnand.h | 3 +-- > 3 files changed, 15 insertions(+), 14 deletions(-) > > diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c > index 05886fa025..29c25f774e 100644 > --- a/drivers/mtd/nand/raw/mxs_nand_spl.c > +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c > @@ -83,7 +83,7 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) > struct nand_chip *chip = mtd_to_nand(mtd); > struct nand_flash_dev *type; > > - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); > + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, NULL); > > if (IS_ERR(type)) { > chip->select_chip(mtd, -1); > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index d58451196c..f666d8ef5d 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -4156,8 +4156,9 @@ static int nand_get_bits_per_cell(u8 cellinfo) > * chip. The rest of the parameters must be decoded according to generic or > * manufacturer-specific "extended ID" decoding patterns. > */ > -static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) > +static void nand_decode_ext_id(struct nand_chip *chip) > { > + struct mtd_info *mtd = &chip->mtd; > int extid, id_len; > /* The 3rd id byte holds MLC / multichip data */ > chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); > @@ -4287,7 +4288,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) > * compliant and does not have a full-id or legacy-id entry in the nand_ids > * table. > */ > -static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chip) > +static void nand_manufacturer_detect(struct nand_chip *chip) > { > /* > * Try manufacturer detection if available and use > @@ -4297,7 +4298,7 @@ static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chi > chip->manufacturer.desc->ops->detect) > chip->manufacturer.desc->ops->detect(chip); > else > - nand_decode_ext_id(mtd, chip); > + nand_decode_ext_id(chip); > } > > /* > @@ -4320,9 +4321,10 @@ static int nand_manufacturer_init(struct nand_chip *chip) > * decodes a matching ID table entry and assigns the MTD size parameters for > * the chip. > */ > -static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, > +static void nand_decode_id(struct nand_chip *chip, > struct nand_flash_dev *type) > { > + struct mtd_info *mtd = &chip->mtd; > int maf_id = chip->id.data[0]; > > mtd->erasesize = type->erasesize; > @@ -4436,11 +4438,11 @@ static const struct nand_manufacturers *nand_get_manufacturer_desc(u8 id) > /* > * Get the flash and manufacturer id and lookup if the type is supported. > */ > -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > - struct nand_chip *chip, > - int *maf_id, int *dev_id, > - struct nand_flash_dev *type) > +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, > + int *maf_id, int *dev_id, > + struct nand_flash_dev *type) > { > + struct mtd_info *mtd = &chip->mtd; > const struct nand_manufacturers *manufacturer_desc; > int busw, ret; > u8 *id_data = chip->id.data; > @@ -4536,9 +4538,9 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > chip->chipsize = (uint64_t)type->chipsize << 20; > > if (!type->pagesize) { > - nand_manufacturer_detect(mtd, chip); > + nand_manufacturer_detect(chip); > } else { > - nand_decode_id(mtd, chip, type); > + nand_decode_id(chip, type); > } > > /* Get chip options */ > @@ -4728,7 +4730,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, > nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); > > /* Read the flash type */ > - type = nand_get_flash_type(mtd, chip, &nand_maf_id, > + type = nand_get_flash_type(chip, &nand_maf_id, > &nand_dev_id, table); > > if (IS_ERR(type)) { > diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h > index 57fe7fb47b..d8141cb4d1 100644 > --- a/include/linux/mtd/rawnand.h > +++ b/include/linux/mtd/rawnand.h > @@ -29,8 +29,7 @@ struct nand_flash_dev; > struct device_node; > > /* Get the flash and manufacturer id and lookup if the type is supported. */ > -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > - struct nand_chip *chip, > +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, > int *maf_id, int *dev_id, > struct nand_flash_dev *type); > > -- > 2.34.1 > Looks good to me. Regards, Dario
Hi Michael, On Wed, Jul 13, 2022 at 1:06 PM Michael Trimarchi <michael@amarulasolutions.com> wrote: > > chip points to mtd. Passing chip is enough to have a reference > to mtd when is necessary > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- > drivers/mtd/nand/raw/nand_base.c | 24 +++++++++++++----------- > include/linux/mtd/rawnand.h | 3 +-- > 3 files changed, 15 insertions(+), 14 deletions(-) > > diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c > index 05886fa025..29c25f774e 100644 > --- a/drivers/mtd/nand/raw/mxs_nand_spl.c > +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c > @@ -83,7 +83,7 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) > struct nand_chip *chip = mtd_to_nand(mtd); > struct nand_flash_dev *type; > > - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); > + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, NULL); > > if (IS_ERR(type)) { > chip->select_chip(mtd, -1); > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index d58451196c..f666d8ef5d 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -4156,8 +4156,9 @@ static int nand_get_bits_per_cell(u8 cellinfo) > * chip. The rest of the parameters must be decoded according to generic or > * manufacturer-specific "extended ID" decoding patterns. > */ > -static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) > +static void nand_decode_ext_id(struct nand_chip *chip) > { > + struct mtd_info *mtd = &chip->mtd; > int extid, id_len; > /* The 3rd id byte holds MLC / multichip data */ > chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); > @@ -4287,7 +4288,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) > * compliant and does not have a full-id or legacy-id entry in the nand_ids > * table. > */ > -static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chip) > +static void nand_manufacturer_detect(struct nand_chip *chip) > { > /* > * Try manufacturer detection if available and use > @@ -4297,7 +4298,7 @@ static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chi > chip->manufacturer.desc->ops->detect) > chip->manufacturer.desc->ops->detect(chip); > else > - nand_decode_ext_id(mtd, chip); > + nand_decode_ext_id(chip); > } > > /* > @@ -4320,9 +4321,10 @@ static int nand_manufacturer_init(struct nand_chip *chip) > * decodes a matching ID table entry and assigns the MTD size parameters for > * the chip. > */ > -static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, > +static void nand_decode_id(struct nand_chip *chip, > struct nand_flash_dev *type) you can put all parameters in the same line. static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) > { > + struct mtd_info *mtd = &chip->mtd; > int maf_id = chip->id.data[0]; > > mtd->erasesize = type->erasesize; > @@ -4436,11 +4438,11 @@ static const struct nand_manufacturers *nand_get_manufacturer_desc(u8 id) > /* > * Get the flash and manufacturer id and lookup if the type is supported. > */ > -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > - struct nand_chip *chip, > - int *maf_id, int *dev_id, > - struct nand_flash_dev *type) > +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, > + int *maf_id, int *dev_id, > + struct nand_flash_dev *type) Please fix indentation > { > + struct mtd_info *mtd = &chip->mtd; > const struct nand_manufacturers *manufacturer_desc; > int busw, ret; > u8 *id_data = chip->id.data; > @@ -4536,9 +4538,9 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > chip->chipsize = (uint64_t)type->chipsize << 20; > > if (!type->pagesize) { > - nand_manufacturer_detect(mtd, chip); > + nand_manufacturer_detect(chip); > } else { > - nand_decode_id(mtd, chip, type); > + nand_decode_id(chip, type); > } > > /* Get chip options */ > @@ -4728,7 +4730,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, > nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); > > /* Read the flash type */ > - type = nand_get_flash_type(mtd, chip, &nand_maf_id, > + type = nand_get_flash_type(chip, &nand_maf_id, > &nand_dev_id, table); > > if (IS_ERR(type)) { > diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h > index 57fe7fb47b..d8141cb4d1 100644 > --- a/include/linux/mtd/rawnand.h > +++ b/include/linux/mtd/rawnand.h > @@ -29,8 +29,7 @@ struct nand_flash_dev; > struct device_node; > > /* Get the flash and manufacturer id and lookup if the type is supported. */ > -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, > - struct nand_chip *chip, > +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, > int *maf_id, int *dev_id, > struct nand_flash_dev *type); > > -- > 2.34.1 > Except for a few lines of code to indent correctly, it looks good to me. Regards, Dario
diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 05886fa025..29c25f774e 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -83,7 +83,7 @@ static int mxs_flash_full_ident(struct mtd_info *mtd) struct nand_chip *chip = mtd_to_nand(mtd); struct nand_flash_dev *type; - type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL); + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, NULL); if (IS_ERR(type)) { chip->select_chip(mtd, -1); diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index d58451196c..f666d8ef5d 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4156,8 +4156,9 @@ static int nand_get_bits_per_cell(u8 cellinfo) * chip. The rest of the parameters must be decoded according to generic or * manufacturer-specific "extended ID" decoding patterns. */ -static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) +static void nand_decode_ext_id(struct nand_chip *chip) { + struct mtd_info *mtd = &chip->mtd; int extid, id_len; /* The 3rd id byte holds MLC / multichip data */ chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); @@ -4287,7 +4288,7 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip) * compliant and does not have a full-id or legacy-id entry in the nand_ids * table. */ -static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chip) +static void nand_manufacturer_detect(struct nand_chip *chip) { /* * Try manufacturer detection if available and use @@ -4297,7 +4298,7 @@ static void nand_manufacturer_detect(struct mtd_info *mtd, struct nand_chip *chi chip->manufacturer.desc->ops->detect) chip->manufacturer.desc->ops->detect(chip); else - nand_decode_ext_id(mtd, chip); + nand_decode_ext_id(chip); } /* @@ -4320,9 +4321,10 @@ static int nand_manufacturer_init(struct nand_chip *chip) * decodes a matching ID table entry and assigns the MTD size parameters for * the chip. */ -static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, +static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type) { + struct mtd_info *mtd = &chip->mtd; int maf_id = chip->id.data[0]; mtd->erasesize = type->erasesize; @@ -4436,11 +4438,11 @@ static const struct nand_manufacturers *nand_get_manufacturer_desc(u8 id) /* * Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, - struct nand_chip *chip, - int *maf_id, int *dev_id, - struct nand_flash_dev *type) +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, + int *maf_id, int *dev_id, + struct nand_flash_dev *type) { + struct mtd_info *mtd = &chip->mtd; const struct nand_manufacturers *manufacturer_desc; int busw, ret; u8 *id_data = chip->id.data; @@ -4536,9 +4538,9 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->chipsize = (uint64_t)type->chipsize << 20; if (!type->pagesize) { - nand_manufacturer_detect(mtd, chip); + nand_manufacturer_detect(chip); } else { - nand_decode_id(mtd, chip, type); + nand_decode_id(chip, type); } /* Get chip options */ @@ -4728,7 +4730,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); /* Read the flash type */ - type = nand_get_flash_type(mtd, chip, &nand_maf_id, + type = nand_get_flash_type(chip, &nand_maf_id, &nand_dev_id, table); if (IS_ERR(type)) { diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 57fe7fb47b..d8141cb4d1 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -29,8 +29,7 @@ struct nand_flash_dev; struct device_node; /* Get the flash and manufacturer id and lookup if the type is supported. */ -struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, - struct nand_chip *chip, +struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id, int *dev_id, struct nand_flash_dev *type);
chip points to mtd. Passing chip is enough to have a reference to mtd when is necessary Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> --- drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 24 +++++++++++++----------- include/linux/mtd/rawnand.h | 3 +-- 3 files changed, 15 insertions(+), 14 deletions(-)