All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for mtd-utils 0/4] about the SLC/MLC
@ 2013-08-20  5:58 Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 1/4] add the MTD_MLCNANDFLASH case Huang Shijie
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Huang Shijie @ 2013-08-20  5:58 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

This patch set is just following the kernel changes about the SLC/MLC,
Please see:
  http://lists.infradead.org/pipermail/linux-mtd/2013-August/048160.html

This patch set tries to make the mtd-utils still runs in the _old_ logic
after we changed the code in kernel.

(The maillist blocks my email for the suspicious header, so i changed the
 title and resend it.)


Huang Shijie (4):
  add the MTD_MLCNANDFLASH case
  mtd: mtd-abi: add a helper to detect the nand type
  Use the mtd_type_is_nand_user() to check the nand
  check the MLC nand type

 flash_otp_write.c     |    4 ++--
 include/mtd/mtd-abi.h |    5 +++++
 lib/libmtd.c          |    5 ++++-
 lib/libmtd_legacy.c   |    3 +++
 mtd_debug.c           |    3 +++
 ubi-utils/mtdinfo.c   |    2 +-
 6 files changed, 18 insertions(+), 4 deletions(-)

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

* [PATCH for mtd-utils 1/4] add the MTD_MLCNANDFLASH case
  2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
@ 2013-08-20  5:58 ` Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 2/4] mtd: mtd-abi: add a helper to detect the nand type Huang Shijie
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2013-08-20  5:58 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

The MTD_MLCNANDFLASH case is missed in the current code.
This patch adds it.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 lib/libmtd.c        |    2 ++
 lib/libmtd_legacy.c |    3 +++
 mtd_debug.c         |    3 +++
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/libmtd.c b/lib/libmtd.c
index 654490e..3e8109a 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -403,6 +403,8 @@ static int type_str2int(const char *str)
 {
 	if (!strcmp(str, "nand"))
 		return MTD_NANDFLASH;
+	if (!strcmp(str, "mlc-nand"))
+		return MTD_MLCNANDFLASH;
 	if (!strcmp(str, "nor"))
 		return MTD_NORFLASH;
 	if (!strcmp(str, "rom"))
diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index 1ae9946..233a92e 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -322,6 +322,9 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
 	case MTD_NANDFLASH:
 		strcpy((char *)mtd->type_str, "nand");
 		break;
+	case MTD_MLCNANDFLASH:
+		strcpy((char *)mtd->type_str, "mlc-nand");
+		break;
 	case MTD_DATAFLASH:
 		strcpy((char *)mtd->type_str, "dataflash");
 		break;
diff --git a/mtd_debug.c b/mtd_debug.c
index 9110e9b..d6993ce 100644
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -260,6 +260,9 @@ int showinfo(int fd)
 		case MTD_NANDFLASH:
 			printf("MTD_NANDFLASH");
 			break;
+		case MTD_MLCNANDFLASH:
+			printf("MTD_MLCNANDFLASH");
+			break;
 		case MTD_DATAFLASH:
 			printf("MTD_DATAFLASH");
 			break;
-- 
1.7.1

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

* [PATCH for mtd-utils 2/4] mtd: mtd-abi: add a helper to detect the nand type
  2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 1/4] add the MTD_MLCNANDFLASH case Huang Shijie
@ 2013-08-20  5:58 ` Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 3/4] Use the mtd_type_is_nand_user() to check the nand Huang Shijie
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2013-08-20  5:58 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

The helper is for user applications, and it is just a copy of
the kernel helper: mtd_type_is_nand();

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 include/mtd/mtd-abi.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 4de167b..bcd7496 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -274,4 +274,9 @@ enum mtd_file_modes {
 	MTD_FILE_MODE_RAW,
 };
 
+static inline int mtd_type_is_nand_user(const struct mtd_info_user *mtd)
+{
+	return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
+}
+
 #endif /* __MTD_ABI_H__ */
-- 
1.7.1

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

* [PATCH for mtd-utils 3/4] Use the mtd_type_is_nand_user() to check the nand
  2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 1/4] add the MTD_MLCNANDFLASH case Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 2/4] mtd: mtd-abi: add a helper to detect the nand type Huang Shijie
@ 2013-08-20  5:58 ` Huang Shijie
  2013-08-20  5:58 ` [PATCH for mtd-utils 4/4] check the MLC nand type Huang Shijie
  2013-10-22 23:33 ` [PATCH for mtd-utils 0/4] about the SLC/MLC Brian Norris
  4 siblings, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2013-08-20  5:58 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

Use this helper to check if it is a nand (including the SLC/MLC).

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 flash_otp_write.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flash_otp_write.c b/flash_otp_write.c
index eaca5e1..111318d 100644
--- a/flash_otp_write.c
+++ b/flash_otp_write.c
@@ -78,7 +78,7 @@ int main(int argc,char *argv[])
 
 	printf("Writing OTP user data on %s at offset 0x%"PRIxoff_t"\n", argv[2], offset);
 
-	if (mtdInfo.type == MTD_NANDFLASH)
+	if (mtd_type_is_nand_user(&mtdInfo))
 		len = mtdInfo.writesize;
 	else
 		len = 256;
@@ -97,7 +97,7 @@ int main(int argc,char *argv[])
 		}
 		p = buf;
 		while (size > 0) {
-			if (mtdInfo.type == MTD_NANDFLASH) {
+			if (mtd_type_is_nand_user(&mtdInfo)) {
 				/* Fill remain buffers with 0xff */
 				memset(buf + size, 0xff, mtdInfo.writesize - size);
 				size = mtdInfo.writesize;
-- 
1.7.1

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

* [PATCH for mtd-utils 4/4] check the MLC nand type
  2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
                   ` (2 preceding siblings ...)
  2013-08-20  5:58 ` [PATCH for mtd-utils 3/4] Use the mtd_type_is_nand_user() to check the nand Huang Shijie
@ 2013-08-20  5:58 ` Huang Shijie
  2013-10-22 23:33 ` [PATCH for mtd-utils 0/4] about the SLC/MLC Brian Norris
  4 siblings, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2013-08-20  5:58 UTC (permalink / raw)
  To: dwmw2; +Cc: Huang Shijie, computersforpeace, linux-mtd, dedekind1

In the current code, the MTD_NANDFLASH stands for both the SLC and MLC.

In the kernel, the MTD_NANDFLASH only stands for the SLC now,
so in order to keep the logic unchanged, we should also check the MLC nand
by MTD_MLCNANDFLASH.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 lib/libmtd.c        |    3 ++-
 ubi-utils/mtdinfo.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/libmtd.c b/lib/libmtd.c
index 3e8109a..2089373 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -776,7 +776,8 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
 
 	mtd->eb_cnt = mtd->size / mtd->eb_size;
 	mtd->type = type_str2int(mtd->type_str);
-	mtd->bb_allowed = !!(mtd->type == MTD_NANDFLASH);
+	mtd->bb_allowed = !!(mtd->type == MTD_NANDFLASH ||
+				mtd->type == MTD_MLCNANDFLASH);
 
 	return 0;
 }
diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index a9dc675..5ac95aa 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -315,7 +315,7 @@ static int print_dev_info(libmtd_t libmtd, const struct mtd_info *mtd_info, int
 		printf("Sub-page size:                  %d %s\n",
 		       mtd.subpage_size,
 		       mtd.subpage_size > 1 ? "bytes" : "byte");
-	else if (mtd.type == MTD_NANDFLASH)
+	else if (mtd.type == MTD_NANDFLASH || mtd.type == MTD_MLCNANDFLASH)
 		printf("Sub-page size:                  unknown\n");
 
 	if (mtd.oob_size > 0)
-- 
1.7.1

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

* Re: [PATCH for mtd-utils 0/4] about the SLC/MLC
  2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
                   ` (3 preceding siblings ...)
  2013-08-20  5:58 ` [PATCH for mtd-utils 4/4] check the MLC nand type Huang Shijie
@ 2013-10-22 23:33 ` Brian Norris
  2013-10-23  2:29   ` Huang Shijie
  4 siblings, 1 reply; 8+ messages in thread
From: Brian Norris @ 2013-10-22 23:33 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-mtd, dwmw2, dedekind1

On Tue, Aug 20, 2013 at 01:58:33PM +0800, Huang Shijie wrote:
> This patch set is just following the kernel changes about the SLC/MLC,
> Please see:
>   http://lists.infradead.org/pipermail/linux-mtd/2013-August/048160.html
> 
> This patch set tries to make the mtd-utils still runs in the _old_ logic
> after we changed the code in kernel.
> 
> (The maillist blocks my email for the suspicious header, so i changed the
>  title and resend it.)
> 
> 
> Huang Shijie (4):
>   add the MTD_MLCNANDFLASH case
>   mtd: mtd-abi: add a helper to detect the nand type
>   Use the mtd_type_is_nand_user() to check the nand
>   check the MLC nand type
> 
>  flash_otp_write.c     |    4 ++--
>  include/mtd/mtd-abi.h |    5 +++++
>  lib/libmtd.c          |    5 ++++-
>  lib/libmtd_legacy.c   |    3 +++
>  mtd_debug.c           |    3 +++
>  ubi-utils/mtdinfo.c   |    2 +-
>  6 files changed, 18 insertions(+), 4 deletions(-)

Pushed to mtd-utils.git. Thanks!

You're missing flash_erase.c, which still has:

	isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;

Maybe you want a helper for struct mtd_dev_info too? Or maybe just a
helper that looks at type 'int', so it applies to both mtd_dev_info.type
and mtd_info_user.type?

Brian

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

* Re: [PATCH for mtd-utils 0/4] about the SLC/MLC
  2013-10-22 23:33 ` [PATCH for mtd-utils 0/4] about the SLC/MLC Brian Norris
@ 2013-10-23  2:29   ` Huang Shijie
  2013-10-23  3:28     ` Brian Norris
  0 siblings, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2013-10-23  2:29 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-mtd, dwmw2, dedekind1

于 2013年10月23日 07:33, Brian Norris 写道:
> You're missing flash_erase.c, which still has:
>
> 	isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
I missed it on purpose.

The "isNAND" is used for the jffs2 to write the cleanmarker.

Since the jffs2 does not support the MLC now, the above line is used to 
check the SLC nand now.
Only the SLC nand can be written with the cleanmarker.

Am i right?

thanks
Huang Shijie

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

* Re: [PATCH for mtd-utils 0/4] about the SLC/MLC
  2013-10-23  2:29   ` Huang Shijie
@ 2013-10-23  3:28     ` Brian Norris
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2013-10-23  3:28 UTC (permalink / raw)
  To: Huang Shijie
  Cc: linux-mtd@lists.infradead.org, David Woodhouse, Artem Bityutskiy

On Tue, Oct 22, 2013 at 7:29 PM, Huang Shijie <b32955@freescale.com> wrote:
> 于 2013年10月23日 07:33, Brian Norris 写道:
>
>> You're missing flash_erase.c, which still has:
>>
>>         isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
>
> I missed it on purpose.
>
> The "isNAND" is used for the jffs2 to write the cleanmarker.
>
> Since the jffs2 does not support the MLC now, the above line is used to
> check the SLC nand now.
> Only the SLC nand can be written with the cleanmarker.
>
> Am i right?

No, if you look at the code, 'isNAND' is used to help with the bad
block checking. And even for the JFFS2 stuff, all your intentional
omission does is cause MLC to be treated like NOR flash, which is
possibly even worse.

And anyway, the variable name 'isNAND' is currently misleading,
because it now only represents 'isSLC'.

Please fix 'isNAND' to reflect all NAND (SLC or MLC). If you would
like, you can add a separate check to print a nice warning or error
message if the flash is MLC and someone chose flash_erase --jffs2.

Brian

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

end of thread, other threads:[~2013-10-23  3:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20  5:58 [PATCH for mtd-utils 0/4] about the SLC/MLC Huang Shijie
2013-08-20  5:58 ` [PATCH for mtd-utils 1/4] add the MTD_MLCNANDFLASH case Huang Shijie
2013-08-20  5:58 ` [PATCH for mtd-utils 2/4] mtd: mtd-abi: add a helper to detect the nand type Huang Shijie
2013-08-20  5:58 ` [PATCH for mtd-utils 3/4] Use the mtd_type_is_nand_user() to check the nand Huang Shijie
2013-08-20  5:58 ` [PATCH for mtd-utils 4/4] check the MLC nand type Huang Shijie
2013-10-22 23:33 ` [PATCH for mtd-utils 0/4] about the SLC/MLC Brian Norris
2013-10-23  2:29   ` Huang Shijie
2013-10-23  3:28     ` Brian Norris

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.