Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: Drop mtd.owner requirement in nand_scan

Since commit 807f16d4db95 ("mtd: core: set some defaults
when dev.parent is set"), it's now legal for drivers
to call nand_scan and nand_scan_ident without setting
mtd.owner.

Drop the check and while at it remove the BUG() abuse.

Fixes: 807f16d4db95 ("mtd: core: set some defaults when dev.parent is set")
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: editorial note - while commit 807f16d4db95 wasn't explicitly
broken, some follow-up commits in the v4.4 release broke a few
drivers, since they would hit this BUG() if they used nand_scan()
and were built as modules]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Ezequiel García and committed by
Brian Norris
20c07a5b f55532a0

+1 -9
+1 -9
drivers/mtd/nand/nand_base.c
··· 4009 4009 * This is the first phase of the normal nand_scan() function. It reads the 4010 4010 * flash ID and sets up MTD fields accordingly. 4011 4011 * 4012 - * The mtd->owner field must be set to the module of the caller. 4013 4012 */ 4014 4013 int nand_scan_ident(struct mtd_info *mtd, int maxchips, 4015 4014 struct nand_flash_dev *table) ··· 4428 4429 * 4429 4430 * This fills out all the uninitialized function pointers with the defaults. 4430 4431 * The flash ID is read and the mtd/chip structures are filled with the 4431 - * appropriate values. The mtd->owner field must be set to the module of the 4432 - * caller. 4432 + * appropriate values. 4433 4433 */ 4434 4434 int nand_scan(struct mtd_info *mtd, int maxchips) 4435 4435 { 4436 4436 int ret; 4437 - 4438 - /* Many callers got this wrong, so check for it for a while... */ 4439 - if (!mtd->owner && caller_is_module()) { 4440 - pr_crit("%s called with NULL mtd->owner!\n", __func__); 4441 - BUG(); 4442 - } 4443 4437 4444 4438 ret = nand_scan_ident(mtd, maxchips, NULL); 4445 4439 if (!ret)