Skip to contentSkip to conversation

NAND: sunxi: Return ENOTSUPP on onfi functions

PATCH New Mylène Josserand 2 participants 6 messages Jul 13, 2018 – Jul 31, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover NAND: sunxi: Return ENOTSUPP on onfi functions

Hello everyone,

This is a first version of this series that fix code for NAND chip that does not have ONFI get/set features support.

Patch 01:
The current code returns an invalid error if it is not supported. It should return ENOTSUPP instead.
Patch 02:
In sunxi_nand driver, we should return of sunxi_nand_chip_init_timings function only when the ONFI is supported and we got a real error while setting the timing. If the onfi_get/set_features is not supported, we should continue the NAND intialization.

Let me kow what you think.

Thank you in advance,
Best regards,

Mylène Josserand (2):
mtd: nand: nand_base: Convert EINVAL into ENOTSUPP
mtd: nand: sunxi: Return on set_feature only when not ENOTSUPP

 drivers/mtd/nand/nand_base.c  | 4 ++--
 drivers/mtd/nand/sunxi_nand.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 mtd: nand: nand_base: Convert EINVAL into ENOTSUPP

Convert the EINVAL error into ENOTSUPP when the GET/SET_FEATURES is not supported.

---
 drivers/mtd/nand/nand_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +2 -2
index 64e4621aaa..9094f857c1 100644
@@ -3041,7 +3041,7 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
 	if (!chip->onfi_version ||
 	    !(le16_to_cpu(chip->onfi_params.opt_cmd)
 	      & ONFI_OPT_CMD_SET_GET_FEATURES))
-		return -EINVAL;
+		return -ENOTSUPP;
 #endif
 
 	chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1);
@@ -3070,7 +3070,7 @@ static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
 	if (!chip->onfi_version ||
 	    !(le16_to_cpu(chip->onfi_params.opt_cmd)
 	      & ONFI_OPT_CMD_SET_GET_FEATURES))
-		return -EINVAL;
+		return -ENOTSUPP;
 #endif
 
 	chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, addr, -1);
Signature · 1 line
2.11.0
#4 lore raw

PATCH 2/2 mtd: nand: sunxi: Return on set_feature only when not ENOTSUPP

In reply to Mylène Josserand

Return the error code of the set_features function only if the error code is not ENOTSUPP. Otherwise, if this function is not supported, it will return and fail to initialize the NAND.

---
 drivers/mtd/nand/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/sunxi_nand.c +1 -1
index bb87aca698..3ccb168d13 100644
@@ -1369,7 +1369,7 @@ static int sunxi_nand_chip_init_timings(struct sunxi_nand_chip *chip)
 						ONFI_FEATURE_ADDR_TIMING_MODE,
 						feature);
 			chip->nand.select_chip(mtd, -1);
-			if (ret)
+			if (ret && ret != -ENOTSUPP)
 				return ret;
 		}
 	}
Signature · 1 line
2.11.0