Message ID | 8b9dd116b40fb7965a29fe0d051bd8b85e3f036b.1474450295.git.dwalter@sigma-star.at |
---|---|
State | Accepted |
Headers | show |
On Wed, 21 Sep 2016 11:44:41 +0200 Daniel Walter <dwalter@sigma-star.at> wrote: > From: Richard Weinberger <richard@nod.at> > > Provide a nand_cleanup() function to free all nand related resources > without unregistering the mtd device. > This should allow drivers to call mtd_device_unregister() and handle > its return value and still being able to cleanup all nand related > resources. > > Signed-off-by: Richard Weinberger <richard@nod.at> > Signed-off-by: Daniel Walter <dwalter@sigma-star.at> > --- > drivers/mtd/nand/nand_base.c | 18 +++++++++++++----- > include/linux/mtd/nand.h | 1 + > 2 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index 77533f7..e743052 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -4601,10 +4601,10 @@ int nand_scan(struct mtd_info *mtd, int maxchips) > EXPORT_SYMBOL(nand_scan); > > /** > - * nand_release - [NAND Interface] Free resources held by the NAND device > - * @mtd: MTD device structure > + * nand_cleanup - [NAND Interface] Free resources held by the NAND device > + * @mts: MTD device structure ^ @mtd. > */ > -void nand_release(struct mtd_info *mtd) > +void nand_cleanup(struct mtd_info *mtd) Can we pass a pointer to a nand_chip here. > { > struct nand_chip *chip = mtd_to_nand(mtd); > > @@ -4612,8 +4612,6 @@ void nand_release(struct mtd_info *mtd) > chip->ecc.algo == NAND_ECC_BCH) > nand_bch_free((struct nand_bch_control *)chip->ecc.priv); > > - mtd_device_unregister(mtd); > - > /* Free bad block table memory */ > kfree(chip->bbt); > if (!(chip->options & NAND_OWN_BUFFERS)) > @@ -4624,6 +4622,16 @@ void nand_release(struct mtd_info *mtd) > & NAND_BBT_DYNAMICSTRUCT) > kfree(chip->badblock_pattern); > } > + > +/** > + * nand_release - [NAND Interface] Free resources held by the NAND device Unregister the MTD device and free resources... > + * @mtd: MTD device structure > + */ > +void nand_release(struct mtd_info *mtd) > +{ > + mtd_device_unregister(mtd); > + nand_cleanup(mtd); > +} > EXPORT_SYMBOL_GPL(nand_release); > > MODULE_LICENSE("GPL"); > diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h > index 8dd6e01..c692c06 100644 > --- a/include/linux/mtd/nand.h > +++ b/include/linux/mtd/nand.h > @@ -39,6 +39,7 @@ extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, > extern int nand_scan_tail(struct mtd_info *mtd); > > /* Free resources held by the NAND device */ > +extern void nand_cleanup(struct mtd_info *mtd); The extern keyword is unneeded here. Actually all extern qualifiers have been removed recently. BTW, no need to resend the patch. I'll fix the problems when applying it (I'd like to have this function in 4.9). > extern void nand_release(struct mtd_info *mtd); > > /* Internal helper for board drivers which need to override command function */
Hi Richard, [auto build test WARNING on mtd/master] [also build test WARNING on v4.8-rc7] [cannot apply to next-20160921] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Daniel-Walter/Nandsim-facelift-part-I-of-II/20160921-182636 base: git://git.infradead.org/linux-mtd.git master reproduce: make htmldocs All warnings (new ones prefixed by >>): >> drivers/mtd/nand/nand_base.c:4608: warning: No description found for parameter 'mtd' >> drivers/mtd/nand/nand_base.c:4608: warning: Excess function parameter 'mts' description in 'nand_cleanup' drivers/mtd/nand/nand_bbt.c:1: warning: no structured comments found >> drivers/mtd/nand/nand_base.c:4608: warning: No description found for parameter 'mtd' >> drivers/mtd/nand/nand_base.c:4608: warning: Excess function parameter 'mts' description in 'nand_cleanup' vim +/mtd +4608 drivers/mtd/nand/nand_base.c 3b85c321 David Woodhouse 2006-09-25 4592 int nand_scan(struct mtd_info *mtd, int maxchips) 3b85c321 David Woodhouse 2006-09-25 4593 { 3b85c321 David Woodhouse 2006-09-25 4594 int ret; 3b85c321 David Woodhouse 2006-09-25 4595 5e81e88a David Woodhouse 2010-02-26 4596 ret = nand_scan_ident(mtd, maxchips, NULL); 3b85c321 David Woodhouse 2006-09-25 4597 if (!ret) 3b85c321 David Woodhouse 2006-09-25 4598 ret = nand_scan_tail(mtd); 3b85c321 David Woodhouse 2006-09-25 4599 return ret; 3b85c321 David Woodhouse 2006-09-25 4600 } 7351d3a5 Florian Fainelli 2010-09-07 4601 EXPORT_SYMBOL(nand_scan); 3b85c321 David Woodhouse 2006-09-25 4602 ^1da177e Linus Torvalds 2005-04-16 4603 /** 26e1c20c Richard Weinberger 2016-09-21 4604 * nand_cleanup - [NAND Interface] Free resources held by the NAND device 26e1c20c Richard Weinberger 2016-09-21 4605 * @mts: MTD device structure ^1da177e Linus Torvalds 2005-04-16 4606 */ 26e1c20c Richard Weinberger 2016-09-21 4607 void nand_cleanup(struct mtd_info *mtd) ^1da177e Linus Torvalds 2005-04-16 @4608 { 862eba51 Boris Brezillon 2015-12-01 4609 struct nand_chip *chip = mtd_to_nand(mtd); ^1da177e Linus Torvalds 2005-04-16 4610 e4225ae8 Rafał Miłecki 2016-04-17 4611 if (chip->ecc.mode == NAND_ECC_SOFT && 06f384c9 Rafał Miłecki 2016-04-17 4612 chip->ecc.algo == NAND_ECC_BCH) 193bd400 Ivan Djelic 2011-03-11 4613 nand_bch_free((struct nand_bch_control *)chip->ecc.priv); 193bd400 Ivan Djelic 2011-03-11 4614 fa671646 Jesper Juhl 2005-11-07 4615 /* Free bad block table memory */ ace4dfee Thomas Gleixner 2006-05-24 4616 kfree(chip->bbt); :::::: The code at line 4608 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org> :::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 77533f7..e743052 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4601,10 +4601,10 @@ int nand_scan(struct mtd_info *mtd, int maxchips) EXPORT_SYMBOL(nand_scan); /** - * nand_release - [NAND Interface] Free resources held by the NAND device - * @mtd: MTD device structure + * nand_cleanup - [NAND Interface] Free resources held by the NAND device + * @mts: MTD device structure */ -void nand_release(struct mtd_info *mtd) +void nand_cleanup(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); @@ -4612,8 +4612,6 @@ void nand_release(struct mtd_info *mtd) chip->ecc.algo == NAND_ECC_BCH) nand_bch_free((struct nand_bch_control *)chip->ecc.priv); - mtd_device_unregister(mtd); - /* Free bad block table memory */ kfree(chip->bbt); if (!(chip->options & NAND_OWN_BUFFERS)) @@ -4624,6 +4622,16 @@ void nand_release(struct mtd_info *mtd) & NAND_BBT_DYNAMICSTRUCT) kfree(chip->badblock_pattern); } + +/** + * nand_release - [NAND Interface] Free resources held by the NAND device + * @mtd: MTD device structure + */ +void nand_release(struct mtd_info *mtd) +{ + mtd_device_unregister(mtd); + nand_cleanup(mtd); +} EXPORT_SYMBOL_GPL(nand_release); MODULE_LICENSE("GPL"); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 8dd6e01..c692c06 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -39,6 +39,7 @@ extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, extern int nand_scan_tail(struct mtd_info *mtd); /* Free resources held by the NAND device */ +extern void nand_cleanup(struct mtd_info *mtd); extern void nand_release(struct mtd_info *mtd); /* Internal helper for board drivers which need to override command function */