[PATCH 2/5] mtd: nand: Propagate mtd_device_unregister() return value in tear down
Boris Brezillon
boris.brezillon at free-electrons.com
Thu Jul 7 11:58:32 PDT 2016
On Thu, 7 Jul 2016 20:29:24 +0200
Richard Weinberger <richard at nod.at> wrote:
> Boris,
>
> Am 06.07.2016 um 15:34 schrieb Boris Brezillon:
> >> /**
> >> - * nand_release - [NAND Interface] Free resources held by the NAND device
> >> + * __nand_release - [NAND Interface] Free resources held by the NAND device
> >> * @mtd: MTD device structure
> >> */
> >> -void nand_release(struct mtd_info *mtd)
> >> +int __nand_release(struct mtd_info *mtd)
> >
> > Can we find a better name? nand_release_safe()?
>
> Sure. Let's pick nand_release_safe().
>
> >> {
> >> + int ret;
> >> struct nand_chip *chip = mtd_to_nand(mtd);
> >>
> >> + ret = mtd_device_unregister(mtd);
> >> + if (ret)
> >> + return ret;
> >> +
> >
> > The question is, should we unregister the MTD device in nand_release().
> > It feels a bit odd to have nand_scan_xxx() functions only doing the
> > nand_chip initialization and letting the NAND controller driver
> > register the MTD device, and have nand_release() unregister the MTD
> > device for us.
> >
> > Maybe we should export a nand_cleanup() function that would just
> > release nand_chip resources and let NAND controller drivers that
> > really care about mtd_device_unregister() return code call it
> > themselves before calling nand_cleanup() (instead of calling
> > nand_release()).
>
> You mean renaming nand_release() to nand_cleanup() and the driver
> has to issue mtd_device_unregister() itself before it is allowed to
> do nand_cleanup(). Yes, that is also an option.
> The only downside is that we have to touch a lot of drivers then.
> But the conversion should be almost trivial.
No, I meant adding nand_cleanup() and then patching nand_release() to
first calling mtd_device_unregister() and then nand_cleanup(). This way
you get rid of __nand_release() and use mtd_device_unregister() +
nand_cleanup() in drivers that really care about
mtd_device_unregister() return code.
More information about the linux-mtd
mailing list