[PATCH] mtd: nand: don't make vendor-specific code un-set their data pointer

Brian Norris computersforpeace at gmail.com
Mon May 1 17:04:51 PDT 2017


It makes sense to do this in nand_base.

(Alternatively: we don't really need to do this at all.)

Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
Compile tested only

 drivers/mtd/nand/nand_base.c  | 11 +++++++++--
 drivers/mtd/nand/nand_hynix.c |  1 -
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ed49a1d634b0..2adcc8cdedf1 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3910,11 +3910,16 @@ static void nand_manufacturer_detect(struct nand_chip *chip)
  */
 static int nand_manufacturer_init(struct nand_chip *chip)
 {
+	int ret;
+
 	if (!chip->manufacturer.desc || !chip->manufacturer.desc->ops ||
 	    !chip->manufacturer.desc->ops->init)
 		return 0;
 
-	return chip->manufacturer.desc->ops->init(chip);
+	ret = chip->manufacturer.desc->ops->init(chip);
+	if (ret)
+		nand_set_manufacturer_data(chip, NULL);
+	return ret;
 }
 
 /*
@@ -3927,8 +3932,10 @@ static void nand_manufacturer_cleanup(struct nand_chip *chip)
 {
 	/* Release manufacturer private data */
 	if (chip->manufacturer.desc && chip->manufacturer.desc->ops &&
-	    chip->manufacturer.desc->ops->cleanup)
+	    chip->manufacturer.desc->ops->cleanup) {
 		chip->manufacturer.desc->ops->cleanup(chip);
+		nand_set_manufacturer_data(chip, NULL);
+	}
 }
 
 /*
diff --git a/drivers/mtd/nand/nand_hynix.c b/drivers/mtd/nand/nand_hynix.c
index b12dc7325378..54d99f90aa9f 100644
--- a/drivers/mtd/nand/nand_hynix.c
+++ b/drivers/mtd/nand/nand_hynix.c
@@ -598,7 +598,6 @@ static void hynix_nand_cleanup(struct nand_chip *chip)
 
 	kfree(hynix->read_retry);
 	kfree(hynix);
-	nand_set_manufacturer_data(chip, NULL);
 }
 
 static int hynix_nand_init(struct nand_chip *chip)
-- 
2.13.0.rc1.294.g07d810a77f-goog




More information about the linux-mtd mailing list