diff mbox

nand_base: fix for ONFI chips that do not support GET/SET FEATURES

Message ID CACwUX0NbKtBCFrjKBFd307D6=EbBZQbE4w25GSAzop0FsBM2LQ@mail.gmail.com
State New, archived
Headers show

Commit Message

David Mosberger-Tang April 30, 2013, 11:39 p.m. UTC
The attached patch is relative to linux-mtd.  It fixes a problem with
NAND-chips that are ONFI-compliant but don't support the SET/GET
FEATURES commands (such as Spansion S34Mx).

  --david

Comments

Huang Shijie May 2, 2013, 2:28 a.m. UTC | #1
于 2013年05月01日 07:39, David Mosberger-Tang 写道:
> The attached patch is relative to linux-mtd.  It fixes a problem with
> NAND-chips that are ONFI-compliant but don't support the SET/GET
> FEATURES commands (such as Spansion S34Mx).
>
good catch.

but could you check your patch with scripts/checkpatch.pl , and then
send out this patch?

thanks
Huang Shijie
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index dfcd0a5..13c8043 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2720,7 +2720,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 ||
+	    // supports GET/SET FEATURES?
+	    !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4))
 		return -EINVAL;
 
 	chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1);
@@ -2741,7 +2743,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 ||
+	    // supports GET/SET FEATURES?
+	    !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4))
 		return -EINVAL;
 
 	/* clear the sub feature parameters */