]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mtd: nand_base: Only use GET/SET FEATURES command on chips that support them.
authorDavid Mosberger <dmosberger@gmail.com>
Wed, 29 May 2013 12:30:13 +0000 (15:30 +0300)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 5 Aug 2013 19:49:04 +0000 (20:49 +0100)
Spansion's S34MLx chips support ONFI but not the GET/SET FEATURES calls.

Signed-off-by: David Mosberger <dmosberger@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/nand_base.c
include/linux/mtd/nand.h

index edc7663f4b7b1b505d4097004e7b963a21c540e6..1cbacffb51063d79d084d7ab9d12547bc8c57905 100644 (file)
@@ -2709,7 +2709,9 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
 {
        int status;
 
-       if (!chip->onfi_version)
+       if (!chip->onfi_version ||
+           !(le16_to_cpu(chip->onfi_params.opt_cmd)
+             & ONFI_OPT_CMD_SET_GET_FEATURES))
                return -EINVAL;
 
        chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1);
@@ -2730,7 +2732,9 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
 static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
                        int addr, uint8_t *subfeature_param)
 {
-       if (!chip->onfi_version)
+       if (!chip->onfi_version ||
+           !(le16_to_cpu(chip->onfi_params.opt_cmd)
+             & ONFI_OPT_CMD_SET_GET_FEATURES))
                return -EINVAL;
 
        /* clear the sub feature parameters */
index 38535eb453db2a911040a463d9f83bcf2795482f..0745a42f1acd0774acdbc3eb411061ca7648c900 100644 (file)
@@ -217,6 +217,9 @@ struct nand_chip;
 /* ONFI subfeature parameters length */
 #define ONFI_SUBFEATURE_PARAM_LEN      4
 
+/* ONFI optional commands SET/GET FEATURES supported? */
+#define ONFI_OPT_CMD_SET_GET_FEATURES  (1 << 2)
+
 struct nand_onfi_params {
        /* rev info and features block */
        /* 'O' 'N' 'F' 'I'  */