Hi Miquel, On Sun, May 10, 2020 at 9:14 PM Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > > Hello, > > The main goal of this big cleanup series is to get rid of > nand_release(). I am always confused when it comes to use either > nand_cleanup() or nand_release() and I need to check the code in the > core, which is a sign of the API being badly designed. > > Historically, there was a "nand_release()" helper only, doing the MTD > device unregistration and cleaning/freeing all objects belonging to > the NAND core. Later (v4.9), nand_cleanup() was been added to take > care of all the NAND cleanup, and was called directly by > nand_release(). This new helper was very useful to cleanup all the > NAND core objects in one go on _probe() error (after a successful > nand_scan()). > > Unfortunately, because of the lack of symmetry in the API, a lot of > people also used nand_release wrongly in the _probe() error path. > > So now, instead of: > > nand_release(chip); > > I would like people to use: > > ret = mtd_device_unregister(mtd); > WARN_ON(ret); > nand_cleanup(chip); > > Note: as it is currently not possible to handle properly an error on > mtd_device_unregister(), WARN_ON() will at least inform the user. > > All of you receiving this cover letter will at least receive one patch > applying this change to the driver you are maintaining. > > Thanks, > Miquèl At first, I just wondered if we could add nand_register() that wraps the combo of nand_scan() and mtd_device_register() so that nand_register() vs nand_release() looks symmetrical. But, not all drivers call nand_scan() and mtd_device_register() in a row. So, I agree we should simply drop nand_release(). Thanks. -- Best Regards Masahiro Yamada ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/