All of lore.kernel.org
 help / color / mirror / Atom feed
* nand_base: fix for ONFI chips that do not support GET/SET FEATURES
@ 2013-04-30 23:39 David Mosberger-Tang
  2013-05-02  2:28 ` Huang Shijie
  0 siblings, 1 reply; 7+ messages in thread
From: David Mosberger-Tang @ 2013-04-30 23:39 UTC (permalink / raw)
  To: David Woodhouse, Artem Bityutskiy, Brian Norris; +Cc: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

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

[-- Attachment #2: nand_base-features-fix.diff.txt --]
[-- Type: text/plain, Size: 949 bytes --]

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 */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-04-30 23:39 nand_base: fix for ONFI chips that do not support GET/SET FEATURES David Mosberger-Tang
@ 2013-05-02  2:28 ` Huang Shijie
  2013-05-02  2:34   ` David Mosberger-Tang
  0 siblings, 1 reply; 7+ messages in thread
From: Huang Shijie @ 2013-05-02  2:28 UTC (permalink / raw)
  To: David Mosberger-Tang
  Cc: Artem Bityutskiy, Brian Norris, linux-mtd, David Woodhouse

于 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-05-02  2:28 ` Huang Shijie
@ 2013-05-02  2:34   ` David Mosberger-Tang
  2013-05-02  2:41     ` Huang Shijie
  0 siblings, 1 reply; 7+ messages in thread
From: David Mosberger-Tang @ 2013-05-02  2:34 UTC (permalink / raw)
  To: Huang Shijie; +Cc: Artem Bityutskiy, Brian Norris, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

Sure.  C99-style comments replaced with old-style comments...

  --david


On Wed, May 1, 2013 at 8:28 PM, Huang Shijie <b32955@freescale.com> wrote:
> 于 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
>
>

[-- Attachment #2: nand_base-features-fix.diff.txt --]
[-- Type: text/plain, Size: 1163 bytes --]

mtd: nand_base: Only use GET/SET FEATURES command on chips that support them.

Spansion's S34MLx chips support ONFI but not the GET/SET FEATURES calls.

Signed-off-by: David Mosberger <dmosberger@gmail.com>

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 */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-05-02  2:34   ` David Mosberger-Tang
@ 2013-05-02  2:41     ` Huang Shijie
  2013-05-02  3:45       ` David Mosberger-Tang
  0 siblings, 1 reply; 7+ messages in thread
From: Huang Shijie @ 2013-05-02  2:41 UTC (permalink / raw)
  To: David Mosberger-Tang
  Cc: Artem Bityutskiy, Brian Norris, linux-mtd, David Woodhouse

于 2013年05月02日 10:34, David Mosberger-Tang 写道:
> +	    !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4))
it's better to add a macro to replace the hardcore '4', such as

#define ONFI_OPT_CMD_SET_GET_FEAT (1 << 2)

Just a suggestion. :)

thanks
Huang Shijie

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-05-02  2:41     ` Huang Shijie
@ 2013-05-02  3:45       ` David Mosberger-Tang
  2013-05-02  3:49         ` David Mosberger-Tang
  0 siblings, 1 reply; 7+ messages in thread
From: David Mosberger-Tang @ 2013-05-02  3:45 UTC (permalink / raw)
  To: Huang Shijie; +Cc: Artem Bityutskiy, Brian Norris, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

Fine by me.

  --david


On Wed, May 1, 2013 at 8:41 PM, Huang Shijie <b32955@freescale.com> wrote:
> 于 2013年05月02日 10:34, David Mosberger-Tang 写道:
>> +         !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4))
> it's better to add a macro to replace the hardcore '4', such as
>
> #define ONFI_OPT_CMD_SET_GET_FEAT (1 << 2)
>
> Just a suggestion. :)
>
> thanks
> Huang Shijie
>

[-- Attachment #2: nand_base-features-fix-v2.diff.txt --]
[-- Type: text/plain, Size: 1404 bytes --]

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index dfcd0a5..db31357 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2720,7 +2720,8 @@ 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);
@@ -2741,7 +2742,8 @@ 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 */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index ab63634..9b98af8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -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'  */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-05-02  3:45       ` David Mosberger-Tang
@ 2013-05-02  3:49         ` David Mosberger-Tang
  2013-05-29 12:31           ` Artem Bityutskiy
  0 siblings, 1 reply; 7+ messages in thread
From: David Mosberger-Tang @ 2013-05-02  3:49 UTC (permalink / raw)
  To: Huang Shijie; +Cc: Artem Bityutskiy, Brian Norris, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]

Sorry, try this one instead.

  --david

On Wed, May 1, 2013 at 9:45 PM, David Mosberger-Tang
<dmosberger@gmail.com> wrote:
> Fine by me.
>
>   --david
>
>
> On Wed, May 1, 2013 at 8:41 PM, Huang Shijie <b32955@freescale.com> wrote:
>> 于 2013年05月02日 10:34, David Mosberger-Tang 写道:
>>> +         !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4))
>> it's better to add a macro to replace the hardcore '4', such as
>>
>> #define ONFI_OPT_CMD_SET_GET_FEAT (1 << 2)
>>
>> Just a suggestion. :)
>>
>> thanks
>> Huang Shijie
>>

[-- Attachment #2: nand_base-features-fix-v2.diff.txt --]
[-- Type: text/plain, Size: 1628 bytes --]

mtd: nand_base: Only use GET/SET FEATURES command on chips that support them.

Spansion's S34MLx chips support ONFI but not the GET/SET FEATURES calls.

Signed-off-by: David Mosberger <dmosberger@gmail.com>

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index dfcd0a5..13bdb96 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 ||
+	    !(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);
@@ -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 ||
+	    !(le16_to_cpu(chip->onfi_params.opt_cmd)
+	      & ONFI_OPT_CMD_SET_GET_FEATURES))
 		return -EINVAL;
 
 	/* clear the sub feature parameters */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index ab63634..9b98af8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -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'  */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES
  2013-05-02  3:49         ` David Mosberger-Tang
@ 2013-05-29 12:31           ` Artem Bityutskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Artem Bityutskiy @ 2013-05-29 12:31 UTC (permalink / raw)
  To: David Mosberger-Tang
  Cc: Huang Shijie, Brian Norris, linux-mtd, David Woodhouse

On Wed, 2013-05-01 at 21:49 -0600, David Mosberger-Tang wrote:
> Sorry, try this one instead.

Pushed, thanks, but please, next time send patches in-line in a form
which is consumable by 'git am'. Thanks!

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-29 12:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-30 23:39 nand_base: fix for ONFI chips that do not support GET/SET FEATURES David Mosberger-Tang
2013-05-02  2:28 ` Huang Shijie
2013-05-02  2:34   ` David Mosberger-Tang
2013-05-02  2:41     ` Huang Shijie
2013-05-02  3:45       ` David Mosberger-Tang
2013-05-02  3:49         ` David Mosberger-Tang
2013-05-29 12:31           ` Artem Bityutskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.