All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] m25p80,spi-nor: Fix module aliases for m25p80; clean up chip identification
@ 2014-09-30  2:13 ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:13 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

The first patch in the series restores the module aliases to m25p80, but
it does so by duplicating the list of names.  This should be suitable
for stable, but it isn't viable in the longer term.

The following patches change the spi-nor interface so that this
duplication is no longer necessary.  This includes removing
spi_nor::read_id, but it could be re-added after this with a different
interface, e.g. returning a flash_info structure (which would need to be
defined in spi_nor.h).

v2: Rebase onto l2-mtd/master.
    Put all the flash information into spi-nor.h rather than using an
    elaborate set of macros to validate names in spi-nor.c.

These patches are still untested by me, aside from compiling and
checking that m25p80 has the expected module aliases.

Ben.

Ben Hutchings (5):
  m25p80,spi-nor: Fix module aliases for m25p80
  spi-nor: Remove spi_nor::read_id operation
  spi-nor: Make spi_nor_scan() take a chip type name, not an
    spi_device_id
  spi-nor: Replace struct spi_device_id with struct flash_info
  m25p80,spi-nor: Share the list of supported chip type names again

 drivers/mtd/devices/m25p80.c      |  21 +++-
 drivers/mtd/spi-nor/fsl-quadspi.c |   7 +-
 drivers/mtd/spi-nor/spi-nor.c     | 251 +++++++-------------------------------
 include/linux/mtd/spi-nor.h       | 191 ++++++++++++++++++++++++++---
 4 files changed, 232 insertions(+), 238 deletions(-)


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 0/5] m25p80,spi-nor: Fix module aliases for m25p80; clean up chip identification
@ 2014-09-30  2:13 ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:13 UTC (permalink / raw)
  To: linux-arm-kernel

The first patch in the series restores the module aliases to m25p80, but
it does so by duplicating the list of names.  This should be suitable
for stable, but it isn't viable in the longer term.

The following patches change the spi-nor interface so that this
duplication is no longer necessary.  This includes removing
spi_nor::read_id, but it could be re-added after this with a different
interface, e.g. returning a flash_info structure (which would need to be
defined in spi_nor.h).

v2: Rebase onto l2-mtd/master.
    Put all the flash information into spi-nor.h rather than using an
    elaborate set of macros to validate names in spi-nor.c.

These patches are still untested by me, aside from compiling and
checking that m25p80 has the expected module aliases.

Ben.

Ben Hutchings (5):
  m25p80,spi-nor: Fix module aliases for m25p80
  spi-nor: Remove spi_nor::read_id operation
  spi-nor: Make spi_nor_scan() take a chip type name, not an
    spi_device_id
  spi-nor: Replace struct spi_device_id with struct flash_info
  m25p80,spi-nor: Share the list of supported chip type names again

 drivers/mtd/devices/m25p80.c      |  21 +++-
 drivers/mtd/spi-nor/fsl-quadspi.c |   7 +-
 drivers/mtd/spi-nor/spi-nor.c     | 251 +++++++-------------------------------
 include/linux/mtd/spi-nor.h       | 191 ++++++++++++++++++++++++++---
 4 files changed, 232 insertions(+), 238 deletions(-)


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/1934326d/attachment.sig>

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
  2014-09-30  2:13 ` Ben Hutchings
@ 2014-09-30  2:14   ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:14 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
its use was also removed at the same time.  Now if m25p80 is built as
a module it doesn't get the necessary aliases to be loaded
automatically.

A clean solution to this will involve defining the list of device
IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
API, but this is quite a large change.

As a quick fix suitable for stable, copy the device IDs back into
m25p80.

Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
Cc: stable <stable@vger.kernel.org> # 3.16.x
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  | 59 ++++++++++++++++++++++++++++++++++++++++---
 drivers/mtd/spi-nor/spi-nor.c |  5 ++--
 include/linux/mtd/spi-nor.h   |  3 +--
 3 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index dcda628..204bec1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -239,8 +239,11 @@ static int m25p_probe(struct spi_device *spi)
 		id = spi_nor_match_id(data->type);
 
 	/* If we didn't get name from platform, simply use "modalias". */
-	if (!id)
-		id = spi_get_device_id(spi);
+	if (!id) {
+		id = spi_nor_match_id(spi_get_device_id(spi)->name);
+		if (WARN_ON(!id))
+			return -ENODEV;
+	}
 
 	ret = spi_nor_scan(nor, id, mode);
 	if (ret)
@@ -263,12 +266,62 @@ static int m25p_remove(struct spi_device *spi)
 }
 

+/*
+ * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
+ * it with spi-nor, because if this is built as a module then modpost
+ * won't be able to read it and add appropriate aliases.
+ */
+static const struct spi_device_id m25p_ids[] = {
+	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
+	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
+	{"at26df321"},	{"at45db081d"},
+	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
+	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
+	{"f25l32pa"},
+	{"mr25h256"},	{"mr25h10"},
+	{"gd25q32"},	{"gd25q64"},
+	{"160s33b"},	{"320s33b"},	{"640s33b"},
+	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
+	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
+	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
+	{"mx66l1g55g"},
+	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
+	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
+	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
+	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
+	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
+	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
+	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
+	{"s25fl016k"},	{"s25fl064k"},
+	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
+	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
+	{"sst25wf040"},
+	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
+	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
+	{"m25p128"},	{"n25q032"},
+	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
+	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
+	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
+	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
+	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
+	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
+	{"m25px64"},
+	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
+	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
+	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
+	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
+	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
+	{ },
+};
+MODULE_DEVICE_TABLE(spi, m25p_ids);
+
+
 static struct spi_driver m25p80_driver = {
 	.driver = {
 		.name	= "m25p80",
 		.owner	= THIS_MODULE,
 	},
-	.id_table	= spi_nor_ids,
+	.id_table	= m25p_ids,
 	.probe	= m25p_probe,
 	.remove	= m25p_remove,
 
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index ae16aa2..53783ed 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -473,7 +473,7 @@ struct flash_info {
  * more nor chips.  This current list focusses on newer chips, which
  * have been converging on command sets which including JEDEC ID.
  */
-const struct spi_device_id spi_nor_ids[] = {
+static const struct spi_device_id spi_nor_ids[] = {
 	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
 	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
 	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
@@ -637,7 +637,6 @@ const struct spi_device_id spi_nor_ids[] = {
 	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
 	{ },
 };
-EXPORT_SYMBOL_GPL(spi_nor_ids);
 
 static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
 {
@@ -1113,7 +1112,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-const struct spi_device_id *spi_nor_match_id(char *name)
+const struct spi_device_id *spi_nor_match_id(const char *name)
 {
 	const struct spi_device_id *id = spi_nor_ids;
 
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9e6294f..5ec84cc 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -201,7 +201,6 @@ struct spi_nor {
  */
 int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 			enum read_mode mode);
-extern const struct spi_device_id spi_nor_ids[];
 
 /**
  * spi_nor_match_id() - find the spi_device_id by the name
@@ -213,6 +212,6 @@ extern const struct spi_device_id spi_nor_ids[];
  * Return: returns the right spi_device_id pointer on success,
  *         and returns NULL on failure.
  */
-const struct spi_device_id *spi_nor_match_id(char *name);
+const struct spi_device_id *spi_nor_match_id(const char *name);
 
 #endif


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
@ 2014-09-30  2:14   ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:14 UTC (permalink / raw)
  To: linux-arm-kernel

m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
its use was also removed at the same time.  Now if m25p80 is built as
a module it doesn't get the necessary aliases to be loaded
automatically.

A clean solution to this will involve defining the list of device
IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
API, but this is quite a large change.

As a quick fix suitable for stable, copy the device IDs back into
m25p80.

Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
Cc: stable <stable@vger.kernel.org> # 3.16.x
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  | 59 ++++++++++++++++++++++++++++++++++++++++---
 drivers/mtd/spi-nor/spi-nor.c |  5 ++--
 include/linux/mtd/spi-nor.h   |  3 +--
 3 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index dcda628..204bec1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -239,8 +239,11 @@ static int m25p_probe(struct spi_device *spi)
 		id = spi_nor_match_id(data->type);
 
 	/* If we didn't get name from platform, simply use "modalias". */
-	if (!id)
-		id = spi_get_device_id(spi);
+	if (!id) {
+		id = spi_nor_match_id(spi_get_device_id(spi)->name);
+		if (WARN_ON(!id))
+			return -ENODEV;
+	}
 
 	ret = spi_nor_scan(nor, id, mode);
 	if (ret)
@@ -263,12 +266,62 @@ static int m25p_remove(struct spi_device *spi)
 }
 

+/*
+ * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
+ * it with spi-nor, because if this is built as a module then modpost
+ * won't be able to read it and add appropriate aliases.
+ */
+static const struct spi_device_id m25p_ids[] = {
+	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
+	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
+	{"at26df321"},	{"at45db081d"},
+	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
+	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
+	{"f25l32pa"},
+	{"mr25h256"},	{"mr25h10"},
+	{"gd25q32"},	{"gd25q64"},
+	{"160s33b"},	{"320s33b"},	{"640s33b"},
+	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
+	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
+	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
+	{"mx66l1g55g"},
+	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
+	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
+	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
+	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
+	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
+	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
+	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
+	{"s25fl016k"},	{"s25fl064k"},
+	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
+	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
+	{"sst25wf040"},
+	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
+	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
+	{"m25p128"},	{"n25q032"},
+	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
+	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
+	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
+	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
+	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
+	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
+	{"m25px64"},
+	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
+	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
+	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
+	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
+	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
+	{ },
+};
+MODULE_DEVICE_TABLE(spi, m25p_ids);
+
+
 static struct spi_driver m25p80_driver = {
 	.driver = {
 		.name	= "m25p80",
 		.owner	= THIS_MODULE,
 	},
-	.id_table	= spi_nor_ids,
+	.id_table	= m25p_ids,
 	.probe	= m25p_probe,
 	.remove	= m25p_remove,
 
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index ae16aa2..53783ed 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -473,7 +473,7 @@ struct flash_info {
  * more nor chips.  This current list focusses on newer chips, which
  * have been converging on command sets which including JEDEC ID.
  */
-const struct spi_device_id spi_nor_ids[] = {
+static const struct spi_device_id spi_nor_ids[] = {
 	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
 	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
 	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
@@ -637,7 +637,6 @@ const struct spi_device_id spi_nor_ids[] = {
 	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
 	{ },
 };
-EXPORT_SYMBOL_GPL(spi_nor_ids);
 
 static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
 {
@@ -1113,7 +1112,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-const struct spi_device_id *spi_nor_match_id(char *name)
+const struct spi_device_id *spi_nor_match_id(const char *name)
 {
 	const struct spi_device_id *id = spi_nor_ids;
 
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9e6294f..5ec84cc 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -201,7 +201,6 @@ struct spi_nor {
  */
 int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 			enum read_mode mode);
-extern const struct spi_device_id spi_nor_ids[];
 
 /**
  * spi_nor_match_id() - find the spi_device_id by the name
@@ -213,6 +212,6 @@ extern const struct spi_device_id spi_nor_ids[];
  * Return: returns the right spi_device_id pointer on success,
  *         and returns NULL on failure.
  */
-const struct spi_device_id *spi_nor_match_id(char *name);
+const struct spi_device_id *spi_nor_match_id(const char *name);
 
 #endif


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/8a1a5390/attachment.sig>

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

* [PATCH v2 2/5] spi-nor: Remove spi_nor::read_id operation
  2014-09-30  2:13 ` Ben Hutchings
@ 2014-09-30  2:15   ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

There is currently no useful way to override the default
implementation of this operation.  The returned struct spi_device_id
must have a pointer to struct flash_info in its private data, but this
structure is defined inside spi-nor.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/spi-nor/spi-nor.c | 4 +---
 include/linux/mtd/spi-nor.h   | 3 ---
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 53783ed..c2f0573 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -902,8 +902,6 @@ static int spi_nor_check(struct spi_nor *nor)
 		return -EINVAL;
 	}
 
-	if (!nor->read_id)
-		nor->read_id = spi_nor_read_id;
 	if (!nor->wait_till_ready)
 		nor->wait_till_ready = spi_nor_wait_till_ready;
 
@@ -929,7 +927,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 	if (info->jedec_id) {
 		const struct spi_device_id *jid;
 
-		jid = nor->read_id(nor);
+		jid = spi_nor_read_id(nor);
 		if (IS_ERR(jid)) {
 			return PTR_ERR(jid);
 		} else if (jid != id) {
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 5ec84cc..66af67a 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -139,8 +139,6 @@ enum spi_nor_ops {
  * @write_xfer:		[OPTIONAL] the writefundamental primitive
  * @read_reg:		[DRIVER-SPECIFIC] read out the register
  * @write_reg:		[DRIVER-SPECIFIC] write data to the register
- * @read_id:		[REPLACEABLE] read out the ID data, and find
- *			the proper spi_device_id
  * @wait_till_ready:	[REPLACEABLE] wait till the NOR becomes ready
  * @read:		[DRIVER-SPECIFIC] read data from the SPI NOR
  * @write:		[DRIVER-SPECIFIC] write data to the SPI NOR
@@ -172,7 +170,6 @@ struct spi_nor {
 	int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
 	int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
 			int write_enable);
-	const struct spi_device_id *(*read_id)(struct spi_nor *nor);
 	int (*wait_till_ready)(struct spi_nor *nor);
 
 	int (*read)(struct spi_nor *nor, loff_t from,


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 2/5] spi-nor: Remove spi_nor::read_id operation
@ 2014-09-30  2:15   ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: linux-arm-kernel

There is currently no useful way to override the default
implementation of this operation.  The returned struct spi_device_id
must have a pointer to struct flash_info in its private data, but this
structure is defined inside spi-nor.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/spi-nor/spi-nor.c | 4 +---
 include/linux/mtd/spi-nor.h   | 3 ---
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 53783ed..c2f0573 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -902,8 +902,6 @@ static int spi_nor_check(struct spi_nor *nor)
 		return -EINVAL;
 	}
 
-	if (!nor->read_id)
-		nor->read_id = spi_nor_read_id;
 	if (!nor->wait_till_ready)
 		nor->wait_till_ready = spi_nor_wait_till_ready;
 
@@ -929,7 +927,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 	if (info->jedec_id) {
 		const struct spi_device_id *jid;
 
-		jid = nor->read_id(nor);
+		jid = spi_nor_read_id(nor);
 		if (IS_ERR(jid)) {
 			return PTR_ERR(jid);
 		} else if (jid != id) {
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 5ec84cc..66af67a 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -139,8 +139,6 @@ enum spi_nor_ops {
  * @write_xfer:		[OPTIONAL] the writefundamental primitive
  * @read_reg:		[DRIVER-SPECIFIC] read out the register
  * @write_reg:		[DRIVER-SPECIFIC] write data to the register
- * @read_id:		[REPLACEABLE] read out the ID data, and find
- *			the proper spi_device_id
  * @wait_till_ready:	[REPLACEABLE] wait till the NOR becomes ready
  * @read:		[DRIVER-SPECIFIC] read data from the SPI NOR
  * @write:		[DRIVER-SPECIFIC] write data to the SPI NOR
@@ -172,7 +170,6 @@ struct spi_nor {
 	int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
 	int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
 			int write_enable);
-	const struct spi_device_id *(*read_id)(struct spi_nor *nor);
 	int (*wait_till_ready)(struct spi_nor *nor);
 
 	int (*read)(struct spi_nor *nor, loff_t from,


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/595a9e05/attachment-0001.sig>

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

* [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
  2014-09-30  2:13 ` Ben Hutchings
@ 2014-09-30  2:15   ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

Drivers currently call spi_nor_match_id() and then spi_nor_scan().
This adds a dependency on struct spi_device_id which we want to
avoid.  Make spi_nor_scan() do it for them.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c      | 13 +++++--------
 drivers/mtd/spi-nor/fsl-quadspi.c |  7 +------
 drivers/mtd/spi-nor/spi-nor.c     | 13 +++++++++----
 include/linux/mtd/spi-nor.h       | 20 ++------------------
 4 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 204bec1..d9578b9 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -193,7 +193,7 @@ static int m25p_probe(struct spi_device *spi)
 {
 	struct mtd_part_parser_data	ppdata;
 	struct flash_platform_data	*data;
-	const struct spi_device_id *id = NULL;
+	const char *name = NULL;
 	struct m25p *flash;
 	struct spi_nor *nor;
 	enum read_mode mode = SPI_NOR_NORMAL;
@@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
 	 * If that's the case, respect "type" and ignore a "name".
 	 */
 	if (data && data->type)
-		id = spi_nor_match_id(data->type);
+		name = data->type;
 
 	/* If we didn't get name from platform, simply use "modalias". */
-	if (!id) {
-		id = spi_nor_match_id(spi_get_device_id(spi)->name);
-		if (WARN_ON(!id))
-			return -ENODEV;
-	}
+	if (!name)
+		name = spi_get_device_id(spi)->name;
 
-	ret = spi_nor_scan(nor, id, mode);
+	ret = spi_nor_scan(nor, name, mode);
 	if (ret)
 		return ret;
 
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 8d659a2..d5269a2 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
 	/* iterate the subnodes. */
 	for_each_available_child_of_node(dev->of_node, np) {
-		const struct spi_device_id *id;
 		char modalias[40];
 
 		/* skip the holes */
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 		if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
 			goto map_failed;
 
-		id = spi_nor_match_id(modalias);
-		if (!id)
-			goto map_failed;
-
 		ret = of_property_read_u32(np, "spi-max-frequency",
 				&q->clk_rate);
 		if (ret < 0)
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 		/* set the chip address for READID */
 		fsl_qspi_set_base_addr(q, nor);
 
-		ret = spi_nor_scan(nor, id, SPI_NOR_QUAD);
+		ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
 		if (ret)
 			goto map_failed;
 
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index c2f0573..171c665 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,6 +28,8 @@
 
 #define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
 
+static const struct spi_device_id *spi_nor_match_id(const char *name);
+
 /*
  * Read the status register, returning its value in the location
  * Return the status register value.
@@ -908,9 +910,9 @@ static int spi_nor_check(struct spi_nor *nor)
 	return 0;
 }
 
-int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
-			enum read_mode mode)
+int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 {
+	const struct spi_device_id	*id = NULL;
 	struct flash_info		*info;
 	struct device *dev = nor->dev;
 	struct mtd_info *mtd = nor->mtd;
@@ -922,6 +924,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 	if (ret)
 		return ret;
 
+	id = spi_nor_match_id(name);
+	if (!id)
+		return -ENODEV;
+
 	info = (void *)id->driver_data;
 
 	if (info->jedec_id) {
@@ -1110,7 +1116,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-const struct spi_device_id *spi_nor_match_id(const char *name)
+static const struct spi_device_id *spi_nor_match_id(const char *name)
 {
 	const struct spi_device_id *id = spi_nor_ids;
 
@@ -1121,7 +1127,6 @@ const struct spi_device_id *spi_nor_match_id(const char *name)
 	}
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(spi_nor_match_id);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 66af67a..c48ad49 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -184,31 +184,15 @@ struct spi_nor {
 /**
  * spi_nor_scan() - scan the SPI NOR
  * @nor:	the spi_nor structure
- * @id:		the spi_device_id provided by the driver
+ * @name:	the chip type name
  * @mode:	the read mode supported by the driver
  *
  * The drivers can use this fuction to scan the SPI NOR.
  * In the scanning, it will try to get all the necessary information to
  * fill the mtd_info{} and the spi_nor{}.
  *
- * The board may assigns a spi_device_id with @id which be used to compared with
- * the spi_device_id detected by the scanning.
- *
  * Return: 0 for success, others for failure.
  */
-int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
-			enum read_mode mode);
-
-/**
- * spi_nor_match_id() - find the spi_device_id by the name
- * @name:	the name of the spi_device_id
- *
- * The drivers use this function to find the spi_device_id
- * specified by the @name.
- *
- * Return: returns the right spi_device_id pointer on success,
- *         and returns NULL on failure.
- */
-const struct spi_device_id *spi_nor_match_id(const char *name);
+int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
 
 #endif


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
@ 2014-09-30  2:15   ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: linux-arm-kernel

Drivers currently call spi_nor_match_id() and then spi_nor_scan().
This adds a dependency on struct spi_device_id which we want to
avoid.  Make spi_nor_scan() do it for them.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c      | 13 +++++--------
 drivers/mtd/spi-nor/fsl-quadspi.c |  7 +------
 drivers/mtd/spi-nor/spi-nor.c     | 13 +++++++++----
 include/linux/mtd/spi-nor.h       | 20 ++------------------
 4 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 204bec1..d9578b9 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -193,7 +193,7 @@ static int m25p_probe(struct spi_device *spi)
 {
 	struct mtd_part_parser_data	ppdata;
 	struct flash_platform_data	*data;
-	const struct spi_device_id *id = NULL;
+	const char *name = NULL;
 	struct m25p *flash;
 	struct spi_nor *nor;
 	enum read_mode mode = SPI_NOR_NORMAL;
@@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
 	 * If that's the case, respect "type" and ignore a "name".
 	 */
 	if (data && data->type)
-		id = spi_nor_match_id(data->type);
+		name = data->type;
 
 	/* If we didn't get name from platform, simply use "modalias". */
-	if (!id) {
-		id = spi_nor_match_id(spi_get_device_id(spi)->name);
-		if (WARN_ON(!id))
-			return -ENODEV;
-	}
+	if (!name)
+		name = spi_get_device_id(spi)->name;
 
-	ret = spi_nor_scan(nor, id, mode);
+	ret = spi_nor_scan(nor, name, mode);
 	if (ret)
 		return ret;
 
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 8d659a2..d5269a2 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
 	/* iterate the subnodes. */
 	for_each_available_child_of_node(dev->of_node, np) {
-		const struct spi_device_id *id;
 		char modalias[40];
 
 		/* skip the holes */
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 		if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
 			goto map_failed;
 
-		id = spi_nor_match_id(modalias);
-		if (!id)
-			goto map_failed;
-
 		ret = of_property_read_u32(np, "spi-max-frequency",
 				&q->clk_rate);
 		if (ret < 0)
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 		/* set the chip address for READID */
 		fsl_qspi_set_base_addr(q, nor);
 
-		ret = spi_nor_scan(nor, id, SPI_NOR_QUAD);
+		ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
 		if (ret)
 			goto map_failed;
 
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index c2f0573..171c665 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,6 +28,8 @@
 
 #define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
 
+static const struct spi_device_id *spi_nor_match_id(const char *name);
+
 /*
  * Read the status register, returning its value in the location
  * Return the status register value.
@@ -908,9 +910,9 @@ static int spi_nor_check(struct spi_nor *nor)
 	return 0;
 }
 
-int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
-			enum read_mode mode)
+int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 {
+	const struct spi_device_id	*id = NULL;
 	struct flash_info		*info;
 	struct device *dev = nor->dev;
 	struct mtd_info *mtd = nor->mtd;
@@ -922,6 +924,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 	if (ret)
 		return ret;
 
+	id = spi_nor_match_id(name);
+	if (!id)
+		return -ENODEV;
+
 	info = (void *)id->driver_data;
 
 	if (info->jedec_id) {
@@ -1110,7 +1116,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-const struct spi_device_id *spi_nor_match_id(const char *name)
+static const struct spi_device_id *spi_nor_match_id(const char *name)
 {
 	const struct spi_device_id *id = spi_nor_ids;
 
@@ -1121,7 +1127,6 @@ const struct spi_device_id *spi_nor_match_id(const char *name)
 	}
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(spi_nor_match_id);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 66af67a..c48ad49 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -184,31 +184,15 @@ struct spi_nor {
 /**
  * spi_nor_scan() - scan the SPI NOR
  * @nor:	the spi_nor structure
- * @id:		the spi_device_id provided by the driver
+ * @name:	the chip type name
  * @mode:	the read mode supported by the driver
  *
  * The drivers can use this fuction to scan the SPI NOR.
  * In the scanning, it will try to get all the necessary information to
  * fill the mtd_info{} and the spi_nor{}.
  *
- * The board may assigns a spi_device_id with @id which be used to compared with
- * the spi_device_id detected by the scanning.
- *
  * Return: 0 for success, others for failure.
  */
-int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
-			enum read_mode mode);
-
-/**
- * spi_nor_match_id() - find the spi_device_id by the name
- * @name:	the name of the spi_device_id
- *
- * The drivers use this function to find the spi_device_id
- * specified by the @name.
- *
- * Return: returns the right spi_device_id pointer on success,
- *         and returns NULL on failure.
- */
-const struct spi_device_id *spi_nor_match_id(const char *name);
+int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
 
 #endif


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/f32af4c5/attachment.sig>

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

* [PATCH v2 4/5] spi-nor: Replace struct spi_device_id with struct flash_info
  2014-09-30  2:13 ` Ben Hutchings
@ 2014-09-30  2:15   ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

spi-nor does not depend on the SPI layer, so its use of struct
spi_device_id adds an unnecessary indirection.  Add the chip type name
to struct flash_info and remove the wrapping struct spi_device_id.

It also doesn't need a terminating zero entry in the array any
more, so remove that.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  |   2 +-
 drivers/mtd/spi-nor/spi-nor.c | 340 +++++++++++++++++++++---------------------
 2 files changed, 170 insertions(+), 172 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index d9578b9..79bc27a 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -264,7 +264,7 @@ static int m25p_remove(struct spi_device *spi)
 

 /*
- * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
+ * XXX This needs to be kept in sync with spi_nor_info.  We can't share
  * it with spi-nor, because if this is built as a module then modpost
  * won't be able to read it and add appropriate aliases.
  */
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 171c665..2449ee5 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,8 +28,6 @@
 
 #define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
 
-static const struct spi_device_id *spi_nor_match_id(const char *name);
-
 /*
  * Read the status register, returning its value in the location
  * Return the status register value.
@@ -425,6 +423,8 @@ err:
 }
 
 struct flash_info {
+	const char	name[SPI_NAME_SIZE];
+
 	/* JEDEC id zero means "no ID" (most older chips); otherwise it has
 	 * a high byte of zero plus three data bytes: the manufacturer id,
 	 * then a two byte device id.
@@ -452,201 +452,215 @@ struct flash_info {
 #define	USE_FSR			0x80	/* use flag status register */
 };
 
-#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
-	((kernel_ulong_t)&(struct flash_info) {				\
+#define INFO(_name, _jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
+	{								\
+		.name = (_name),					\
 		.jedec_id = (_jedec_id),				\
 		.ext_id = (_ext_id),					\
 		.sector_size = (_sector_size),				\
 		.n_sectors = (_n_sectors),				\
 		.page_size = 256,					\
 		.flags = (_flags),					\
-	})
+	}
 
-#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width, _flags)	\
-	((kernel_ulong_t)&(struct flash_info) {				\
+#define CAT25_INFO(_name, _sector_size, _n_sectors, _page_size,		\
+		   _addr_width, _flags)					\
+	{								\
+		.name = (_name),					\
 		.sector_size = (_sector_size),				\
 		.n_sectors = (_n_sectors),				\
 		.page_size = (_page_size),				\
 		.addr_width = (_addr_width),				\
 		.flags = (_flags),					\
-	})
+	}
 
 /* NOTE: double check command sets and memory organization when you add
  * more nor chips.  This current list focusses on newer chips, which
  * have been converging on command sets which including JEDEC ID.
  */
-static const struct spi_device_id spi_nor_ids[] = {
+static const struct flash_info spi_nor_info[] = {
 	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
-	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
-	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
+	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),
+	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),
 
-	{ "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8, SECT_4K) },
-	{ "at25df321a", INFO(0x1f4701, 0, 64 * 1024,  64, SECT_4K) },
-	{ "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) },
+	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),
+	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),
+	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),
 
-	{ "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8, SECT_4K) },
-	{ "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) },
-	{ "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) },
-	{ "at26df321",  INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) },
+	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),
+	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),
+	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),
+	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),
 
-	{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) },
+	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),
 
 	/* EON -- en25xxx */
-	{ "en25f32",    INFO(0x1c3116, 0, 64 * 1024,   64, SECT_4K) },
-	{ "en25p32",    INFO(0x1c2016, 0, 64 * 1024,   64, 0) },
-	{ "en25q32b",   INFO(0x1c3016, 0, 64 * 1024,   64, 0) },
-	{ "en25p64",    INFO(0x1c2017, 0, 64 * 1024,  128, 0) },
-	{ "en25q64",    INFO(0x1c3017, 0, 64 * 1024,  128, SECT_4K) },
-	{ "en25qh128",  INFO(0x1c7018, 0, 64 * 1024,  256, 0) },
-	{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512, 0) },
+	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),
+	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),
+	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),
+	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),
+	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),
+	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),
+	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),
 
 	/* ESMT */
-	{ "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) },
+	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),
 
 	/* Everspin */
-	{ "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "mr25h10",  CAT25_INFO(128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
+	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
 
 	/* GigaDevice */
-	{ "gd25q32", INFO(0xc84016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SECT_4K) },
+	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),
 
 	/* Intel/Numonyx -- xxxs33b */
-	{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, 0) },
-	{ "320s33b",  INFO(0x898912, 0, 64 * 1024,  64, 0) },
-	{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, 0) },
+	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),
+	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),
+	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),
 
 	/* Macronix */
-	{ "mx25l2005a",  INFO(0xc22012, 0, 64 * 1024,   4, SECT_4K) },
-	{ "mx25l4005a",  INFO(0xc22013, 0, 64 * 1024,   8, SECT_4K) },
-	{ "mx25l8005",   INFO(0xc22014, 0, 64 * 1024,  16, 0) },
-	{ "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
-	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, 0) },
-	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, 0) },
-	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
-	{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
-	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
-	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
-	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
-	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
+	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),
+	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),
+	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),
+	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),
+	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),
+	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),
+	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),
+	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),
+	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),
+	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),
+	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),
+	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ),
+	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ),
 
 	/* Micron */
-	{ "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
-	{ "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, 0) },
-	{ "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, 0) },
-	{ "n25q256a",    INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K) },
-	{ "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
-	{ "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
-	{ "n25q00",      INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
+	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),
+	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),
+	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),
+	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),
+	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),
+	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),
+	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),
 
 	/* PMC */
-	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
-	{ "pm25lv010",   INFO(0,        0, 32 * 1024,    4, SECT_4K_PMC) },
-	{ "pm25lq032",   INFO(0x7f9d46, 0, 64 * 1024,   64, SECT_4K) },
+	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),
+	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),
+	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),
 
 	/* Spansion -- single (large) sector size only, at least
 	 * for the chips listed here (without boot sectors).
 	 */
-	{ "s25sl032p",  INFO(0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 0) },
-	{ "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
-	{ "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
-	{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
-	{ "s25sl12801", INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
-	{ "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024,  64, 0) },
-	{ "s25fl129p1", INFO(0x012018, 0x4d01,  64 * 1024, 256, 0) },
-	{ "s25sl004a",  INFO(0x010212,      0,  64 * 1024,   8, 0) },
-	{ "s25sl008a",  INFO(0x010213,      0,  64 * 1024,  16, 0) },
-	{ "s25sl016a",  INFO(0x010214,      0,  64 * 1024,  32, 0) },
-	{ "s25sl032a",  INFO(0x010215,      0,  64 * 1024,  64, 0) },
-	{ "s25sl064a",  INFO(0x010216,      0,  64 * 1024, 128, 0) },
-	{ "s25fl008k",  INFO(0xef4014,      0,  64 * 1024,  16, SECT_4K) },
-	{ "s25fl016k",  INFO(0xef4015,      0,  64 * 1024,  32, SECT_4K) },
-	{ "s25fl064k",  INFO(0xef4017,      0,  64 * 1024, 128, SECT_4K) },
+	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),
+	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),
+	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),
+	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),
+	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),
+	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),
+	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),
+	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),
+	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),
+	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),
+	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),
+	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),
+	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),
+	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),
+	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),
 
 	/* SST -- large erase sizes are "overlays", "sectors" are 4K */
-	{ "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
-	{ "sst25vf080b", INFO(0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) },
-	{ "sst25vf016b", INFO(0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE) },
-	{ "sst25vf032b", INFO(0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE) },
-	{ "sst25vf064c", INFO(0xbf254b, 0, 64 * 1024, 128, SECT_4K) },
-	{ "sst25wf512",  INFO(0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE) },
-	{ "sst25wf010",  INFO(0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE) },
-	{ "sst25wf020",  INFO(0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE) },
-	{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
+	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
+	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE),
+	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE),
+	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE),
+	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),
+	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE),
+	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE),
+	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE),
+	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
 
 	/* ST Microelectronics -- newer production may have feature updates */
-	{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
-	{ "m25p10",  INFO(0x202011,  0,  32 * 1024,   4, 0) },
-	{ "m25p20",  INFO(0x202012,  0,  64 * 1024,   4, 0) },
-	{ "m25p40",  INFO(0x202013,  0,  64 * 1024,   8, 0) },
-	{ "m25p80",  INFO(0x202014,  0,  64 * 1024,  16, 0) },
-	{ "m25p16",  INFO(0x202015,  0,  64 * 1024,  32, 0) },
-	{ "m25p32",  INFO(0x202016,  0,  64 * 1024,  64, 0) },
-	{ "m25p64",  INFO(0x202017,  0,  64 * 1024, 128, 0) },
-	{ "m25p128", INFO(0x202018,  0, 256 * 1024,  64, 0) },
-	{ "n25q032", INFO(0x20ba16,  0,  64 * 1024,  64, 0) },
-
-	{ "m25p05-nonjedec",  INFO(0, 0,  32 * 1024,   2, 0) },
-	{ "m25p10-nonjedec",  INFO(0, 0,  32 * 1024,   4, 0) },
-	{ "m25p20-nonjedec",  INFO(0, 0,  64 * 1024,   4, 0) },
-	{ "m25p40-nonjedec",  INFO(0, 0,  64 * 1024,   8, 0) },
-	{ "m25p80-nonjedec",  INFO(0, 0,  64 * 1024,  16, 0) },
-	{ "m25p16-nonjedec",  INFO(0, 0,  64 * 1024,  32, 0) },
-	{ "m25p32-nonjedec",  INFO(0, 0,  64 * 1024,  64, 0) },
-	{ "m25p64-nonjedec",  INFO(0, 0,  64 * 1024, 128, 0) },
-	{ "m25p128-nonjedec", INFO(0, 0, 256 * 1024,  64, 0) },
-
-	{ "m45pe10", INFO(0x204011,  0, 64 * 1024,    2, 0) },
-	{ "m45pe80", INFO(0x204014,  0, 64 * 1024,   16, 0) },
-	{ "m45pe16", INFO(0x204015,  0, 64 * 1024,   32, 0) },
-
-	{ "m25pe20", INFO(0x208012,  0, 64 * 1024,  4,       0) },
-	{ "m25pe80", INFO(0x208014,  0, 64 * 1024, 16,       0) },
-	{ "m25pe16", INFO(0x208015,  0, 64 * 1024, 32, SECT_4K) },
-
-	{ "m25px16",    INFO(0x207115,  0, 64 * 1024, 32, SECT_4K) },
-	{ "m25px32",    INFO(0x207116,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px32-s0", INFO(0x207316,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px32-s1", INFO(0x206316,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px64",    INFO(0x207117,  0, 64 * 1024, 128, 0) },
-	{ "m25px80",    INFO(0x207114,  0, 64 * 1024, 16, 0) },
+	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),
+	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),
+	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),
+	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),
+	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),
+	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),
+	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),
+	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),
+	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),
+	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),
+
+	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),
+	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),
+	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),
+	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),
+	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),
+	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),
+	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),
+	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),
+	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),
+
+	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),
+	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),
+	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),
+
+	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),
+	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),
+	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),
+
+	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),
+	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),
 
 	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-	{ "w25x10", INFO(0xef3011, 0, 64 * 1024,  2,  SECT_4K) },
-	{ "w25x20", INFO(0xef3012, 0, 64 * 1024,  4,  SECT_4K) },
-	{ "w25x40", INFO(0xef3013, 0, 64 * 1024,  8,  SECT_4K) },
-	{ "w25x80", INFO(0xef3014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25x16", INFO(0xef3015, 0, 64 * 1024,  32, SECT_4K) },
-	{ "w25x32", INFO(0xef3016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25q32", INFO(0xef4016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
-	{ "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) },
-	{ "w25q80", INFO(0xef5014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25q80bl", INFO(0xef4014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
-	{ "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) },
+	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),
+	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),
+	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),
+	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),
+	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),
+	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),
+	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),
+	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),
 
 	/* Catalyst / On Semiconductor -- non-JEDEC */
-	{ "cat25c11", CAT25_INFO(  16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c03", CAT25_INFO(  32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c09", CAT25_INFO( 128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c17", CAT25_INFO( 256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ },
+	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
 };
 
-static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
+static const struct flash_info *spi_nor_info_by_name(const char *name)
+{
+	const struct flash_info *info;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(spi_nor_info); i++) {
+		info = &spi_nor_info[i];
+		if (!strcmp(name, info->name))
+			return info;
+	}
+	return NULL;
+}
+
+static const struct flash_info *spi_nor_info_probe(struct spi_nor *nor)
 {
 	int			tmp;
 	u8			id[5];
 	u32			jedec;
 	u16                     ext_jedec;
-	struct flash_info	*info;
+	const struct flash_info	*info;
 
 	tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, 5);
 	if (tmp < 0) {
@@ -661,11 +675,11 @@ static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
 
 	ext_jedec = id[3] << 8 | id[4];
 
-	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
-		info = (void *)spi_nor_ids[tmp].driver_data;
+	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_info); tmp++) {
+		info = &spi_nor_info[tmp];
 		if (info->jedec_id == jedec) {
 			if (info->ext_id == 0 || info->ext_id == ext_jedec)
-				return &spi_nor_ids[tmp];
+				return info;
 		}
 	}
 	dev_err(nor->dev, "unrecognized JEDEC id %06x\n", jedec);
@@ -912,8 +926,7 @@ static int spi_nor_check(struct spi_nor *nor)
 
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 {
-	const struct spi_device_id	*id = NULL;
-	struct flash_info		*info;
+	const struct flash_info	*info = NULL;
 	struct device *dev = nor->dev;
 	struct mtd_info *mtd = nor->mtd;
 	struct device_node *np = dev->of_node;
@@ -924,19 +937,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	if (ret)
 		return ret;
 
-	id = spi_nor_match_id(name);
-	if (!id)
+	info = spi_nor_info_by_name(name);
+	if (!info)
 		return -ENODEV;
 
-	info = (void *)id->driver_data;
-
 	if (info->jedec_id) {
-		const struct spi_device_id *jid;
+		const struct flash_info *jinfo;
 
-		jid = spi_nor_read_id(nor);
-		if (IS_ERR(jid)) {
-			return PTR_ERR(jid);
-		} else if (jid != id) {
+		jinfo = spi_nor_info_probe(nor);
+		if (IS_ERR(jinfo)) {
+			return PTR_ERR(jinfo);
+		} else if (jinfo != info) {
 			/*
 			 * JEDEC knows better, so overwrite platform ID. We
 			 * can't trust partitions any longer, but we'll let
@@ -945,9 +956,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 			 * information, even if it's not 100% accurate.
 			 */
 			dev_warn(dev, "found %s, expected %s\n",
-				 jid->name, id->name);
-			id = jid;
-			info = (void *)jid->driver_data;
+				 jinfo->name, info->name);
+			info = jinfo;
 		}
 	}
 
@@ -1093,7 +1103,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 
 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
 
-	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
 			(long long)mtd->size >> 10);
 
 	dev_dbg(dev,
@@ -1116,18 +1126,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-static const struct spi_device_id *spi_nor_match_id(const char *name)
-{
-	const struct spi_device_id *id = spi_nor_ids;
-
-	while (id->name[0]) {
-		if (!strcmp(name, id->name))
-			return id;
-		id++;
-	}
-	return NULL;
-}
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
 MODULE_AUTHOR("Mike Lavender");


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 4/5] spi-nor: Replace struct spi_device_id with struct flash_info
@ 2014-09-30  2:15   ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: linux-arm-kernel

spi-nor does not depend on the SPI layer, so its use of struct
spi_device_id adds an unnecessary indirection.  Add the chip type name
to struct flash_info and remove the wrapping struct spi_device_id.

It also doesn't need a terminating zero entry in the array any
more, so remove that.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  |   2 +-
 drivers/mtd/spi-nor/spi-nor.c | 340 +++++++++++++++++++++---------------------
 2 files changed, 170 insertions(+), 172 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index d9578b9..79bc27a 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -264,7 +264,7 @@ static int m25p_remove(struct spi_device *spi)
 

 /*
- * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
+ * XXX This needs to be kept in sync with spi_nor_info.  We can't share
  * it with spi-nor, because if this is built as a module then modpost
  * won't be able to read it and add appropriate aliases.
  */
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 171c665..2449ee5 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,8 +28,6 @@
 
 #define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
 
-static const struct spi_device_id *spi_nor_match_id(const char *name);
-
 /*
  * Read the status register, returning its value in the location
  * Return the status register value.
@@ -425,6 +423,8 @@ err:
 }
 
 struct flash_info {
+	const char	name[SPI_NAME_SIZE];
+
 	/* JEDEC id zero means "no ID" (most older chips); otherwise it has
 	 * a high byte of zero plus three data bytes: the manufacturer id,
 	 * then a two byte device id.
@@ -452,201 +452,215 @@ struct flash_info {
 #define	USE_FSR			0x80	/* use flag status register */
 };
 
-#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
-	((kernel_ulong_t)&(struct flash_info) {				\
+#define INFO(_name, _jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
+	{								\
+		.name = (_name),					\
 		.jedec_id = (_jedec_id),				\
 		.ext_id = (_ext_id),					\
 		.sector_size = (_sector_size),				\
 		.n_sectors = (_n_sectors),				\
 		.page_size = 256,					\
 		.flags = (_flags),					\
-	})
+	}
 
-#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width, _flags)	\
-	((kernel_ulong_t)&(struct flash_info) {				\
+#define CAT25_INFO(_name, _sector_size, _n_sectors, _page_size,		\
+		   _addr_width, _flags)					\
+	{								\
+		.name = (_name),					\
 		.sector_size = (_sector_size),				\
 		.n_sectors = (_n_sectors),				\
 		.page_size = (_page_size),				\
 		.addr_width = (_addr_width),				\
 		.flags = (_flags),					\
-	})
+	}
 
 /* NOTE: double check command sets and memory organization when you add
  * more nor chips.  This current list focusses on newer chips, which
  * have been converging on command sets which including JEDEC ID.
  */
-static const struct spi_device_id spi_nor_ids[] = {
+static const struct flash_info spi_nor_info[] = {
 	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
-	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
-	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
+	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),
+	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),
 
-	{ "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8, SECT_4K) },
-	{ "at25df321a", INFO(0x1f4701, 0, 64 * 1024,  64, SECT_4K) },
-	{ "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) },
+	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),
+	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),
+	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),
 
-	{ "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8, SECT_4K) },
-	{ "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) },
-	{ "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) },
-	{ "at26df321",  INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) },
+	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),
+	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),
+	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),
+	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),
 
-	{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) },
+	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),
 
 	/* EON -- en25xxx */
-	{ "en25f32",    INFO(0x1c3116, 0, 64 * 1024,   64, SECT_4K) },
-	{ "en25p32",    INFO(0x1c2016, 0, 64 * 1024,   64, 0) },
-	{ "en25q32b",   INFO(0x1c3016, 0, 64 * 1024,   64, 0) },
-	{ "en25p64",    INFO(0x1c2017, 0, 64 * 1024,  128, 0) },
-	{ "en25q64",    INFO(0x1c3017, 0, 64 * 1024,  128, SECT_4K) },
-	{ "en25qh128",  INFO(0x1c7018, 0, 64 * 1024,  256, 0) },
-	{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512, 0) },
+	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),
+	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),
+	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),
+	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),
+	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),
+	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),
+	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),
 
 	/* ESMT */
-	{ "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) },
+	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),
 
 	/* Everspin */
-	{ "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "mr25h10",  CAT25_INFO(128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
+	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
 
 	/* GigaDevice */
-	{ "gd25q32", INFO(0xc84016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SECT_4K) },
+	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),
 
 	/* Intel/Numonyx -- xxxs33b */
-	{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, 0) },
-	{ "320s33b",  INFO(0x898912, 0, 64 * 1024,  64, 0) },
-	{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, 0) },
+	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),
+	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),
+	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),
 
 	/* Macronix */
-	{ "mx25l2005a",  INFO(0xc22012, 0, 64 * 1024,   4, SECT_4K) },
-	{ "mx25l4005a",  INFO(0xc22013, 0, 64 * 1024,   8, SECT_4K) },
-	{ "mx25l8005",   INFO(0xc22014, 0, 64 * 1024,  16, 0) },
-	{ "mx25l1606e",  INFO(0xc22015, 0, 64 * 1024,  32, SECT_4K) },
-	{ "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, 0) },
-	{ "mx25l3255e",  INFO(0xc29e16, 0, 64 * 1024,  64, SECT_4K) },
-	{ "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, 0) },
-	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
-	{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
-	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
-	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
-	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
-	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
+	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),
+	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),
+	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),
+	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),
+	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),
+	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),
+	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),
+	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),
+	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),
+	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),
+	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),
+	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ),
+	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ),
 
 	/* Micron */
-	{ "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
-	{ "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, 0) },
-	{ "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, 0) },
-	{ "n25q256a",    INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K) },
-	{ "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
-	{ "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
-	{ "n25q00",      INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
+	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),
+	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),
+	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),
+	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),
+	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),
+	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),
+	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),
 
 	/* PMC */
-	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
-	{ "pm25lv010",   INFO(0,        0, 32 * 1024,    4, SECT_4K_PMC) },
-	{ "pm25lq032",   INFO(0x7f9d46, 0, 64 * 1024,   64, SECT_4K) },
+	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),
+	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),
+	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),
 
 	/* Spansion -- single (large) sector size only, at least
 	 * for the chips listed here (without boot sectors).
 	 */
-	{ "s25sl032p",  INFO(0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 0) },
-	{ "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
-	{ "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
-	{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
-	{ "s25sl12801", INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
-	{ "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024,  64, 0) },
-	{ "s25fl129p1", INFO(0x012018, 0x4d01,  64 * 1024, 256, 0) },
-	{ "s25sl004a",  INFO(0x010212,      0,  64 * 1024,   8, 0) },
-	{ "s25sl008a",  INFO(0x010213,      0,  64 * 1024,  16, 0) },
-	{ "s25sl016a",  INFO(0x010214,      0,  64 * 1024,  32, 0) },
-	{ "s25sl032a",  INFO(0x010215,      0,  64 * 1024,  64, 0) },
-	{ "s25sl064a",  INFO(0x010216,      0,  64 * 1024, 128, 0) },
-	{ "s25fl008k",  INFO(0xef4014,      0,  64 * 1024,  16, SECT_4K) },
-	{ "s25fl016k",  INFO(0xef4015,      0,  64 * 1024,  32, SECT_4K) },
-	{ "s25fl064k",  INFO(0xef4017,      0,  64 * 1024, 128, SECT_4K) },
+	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),
+	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),
+	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
+	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),
+	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),
+	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),
+	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),
+	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),
+	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),
+	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),
+	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),
+	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),
+	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),
+	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),
+	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),
+	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),
 
 	/* SST -- large erase sizes are "overlays", "sectors" are 4K */
-	{ "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
-	{ "sst25vf080b", INFO(0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) },
-	{ "sst25vf016b", INFO(0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE) },
-	{ "sst25vf032b", INFO(0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE) },
-	{ "sst25vf064c", INFO(0xbf254b, 0, 64 * 1024, 128, SECT_4K) },
-	{ "sst25wf512",  INFO(0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE) },
-	{ "sst25wf010",  INFO(0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE) },
-	{ "sst25wf020",  INFO(0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE) },
-	{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) },
+	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
+	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE),
+	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE),
+	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE),
+	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),
+	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE),
+	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE),
+	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE),
+	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
 
 	/* ST Microelectronics -- newer production may have feature updates */
-	{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
-	{ "m25p10",  INFO(0x202011,  0,  32 * 1024,   4, 0) },
-	{ "m25p20",  INFO(0x202012,  0,  64 * 1024,   4, 0) },
-	{ "m25p40",  INFO(0x202013,  0,  64 * 1024,   8, 0) },
-	{ "m25p80",  INFO(0x202014,  0,  64 * 1024,  16, 0) },
-	{ "m25p16",  INFO(0x202015,  0,  64 * 1024,  32, 0) },
-	{ "m25p32",  INFO(0x202016,  0,  64 * 1024,  64, 0) },
-	{ "m25p64",  INFO(0x202017,  0,  64 * 1024, 128, 0) },
-	{ "m25p128", INFO(0x202018,  0, 256 * 1024,  64, 0) },
-	{ "n25q032", INFO(0x20ba16,  0,  64 * 1024,  64, 0) },
-
-	{ "m25p05-nonjedec",  INFO(0, 0,  32 * 1024,   2, 0) },
-	{ "m25p10-nonjedec",  INFO(0, 0,  32 * 1024,   4, 0) },
-	{ "m25p20-nonjedec",  INFO(0, 0,  64 * 1024,   4, 0) },
-	{ "m25p40-nonjedec",  INFO(0, 0,  64 * 1024,   8, 0) },
-	{ "m25p80-nonjedec",  INFO(0, 0,  64 * 1024,  16, 0) },
-	{ "m25p16-nonjedec",  INFO(0, 0,  64 * 1024,  32, 0) },
-	{ "m25p32-nonjedec",  INFO(0, 0,  64 * 1024,  64, 0) },
-	{ "m25p64-nonjedec",  INFO(0, 0,  64 * 1024, 128, 0) },
-	{ "m25p128-nonjedec", INFO(0, 0, 256 * 1024,  64, 0) },
-
-	{ "m45pe10", INFO(0x204011,  0, 64 * 1024,    2, 0) },
-	{ "m45pe80", INFO(0x204014,  0, 64 * 1024,   16, 0) },
-	{ "m45pe16", INFO(0x204015,  0, 64 * 1024,   32, 0) },
-
-	{ "m25pe20", INFO(0x208012,  0, 64 * 1024,  4,       0) },
-	{ "m25pe80", INFO(0x208014,  0, 64 * 1024, 16,       0) },
-	{ "m25pe16", INFO(0x208015,  0, 64 * 1024, 32, SECT_4K) },
-
-	{ "m25px16",    INFO(0x207115,  0, 64 * 1024, 32, SECT_4K) },
-	{ "m25px32",    INFO(0x207116,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px32-s0", INFO(0x207316,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px32-s1", INFO(0x206316,  0, 64 * 1024, 64, SECT_4K) },
-	{ "m25px64",    INFO(0x207117,  0, 64 * 1024, 128, 0) },
-	{ "m25px80",    INFO(0x207114,  0, 64 * 1024, 16, 0) },
+	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),
+	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),
+	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),
+	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),
+	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),
+	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),
+	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),
+	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),
+	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),
+	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),
+
+	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),
+	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),
+	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),
+	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),
+	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),
+	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),
+	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),
+	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),
+	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),
+
+	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),
+	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),
+	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),
+
+	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),
+	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),
+	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),
+
+	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),
+	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),
+	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),
 
 	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-	{ "w25x10", INFO(0xef3011, 0, 64 * 1024,  2,  SECT_4K) },
-	{ "w25x20", INFO(0xef3012, 0, 64 * 1024,  4,  SECT_4K) },
-	{ "w25x40", INFO(0xef3013, 0, 64 * 1024,  8,  SECT_4K) },
-	{ "w25x80", INFO(0xef3014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25x16", INFO(0xef3015, 0, 64 * 1024,  32, SECT_4K) },
-	{ "w25x32", INFO(0xef3016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25q32", INFO(0xef4016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024,  64, SECT_4K) },
-	{ "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
-	{ "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) },
-	{ "w25q80", INFO(0xef5014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25q80bl", INFO(0xef4014, 0, 64 * 1024,  16, SECT_4K) },
-	{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
-	{ "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) },
+	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),
+	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),
+	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),
+	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),
+	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),
+	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),
+	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),
+	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),
+	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),
+	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),
 
 	/* Catalyst / On Semiconductor -- non-JEDEC */
-	{ "cat25c11", CAT25_INFO(  16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c03", CAT25_INFO(  32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c09", CAT25_INFO( 128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25c17", CAT25_INFO( 256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
-	{ },
+	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
 };
 
-static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
+static const struct flash_info *spi_nor_info_by_name(const char *name)
+{
+	const struct flash_info *info;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(spi_nor_info); i++) {
+		info = &spi_nor_info[i];
+		if (!strcmp(name, info->name))
+			return info;
+	}
+	return NULL;
+}
+
+static const struct flash_info *spi_nor_info_probe(struct spi_nor *nor)
 {
 	int			tmp;
 	u8			id[5];
 	u32			jedec;
 	u16                     ext_jedec;
-	struct flash_info	*info;
+	const struct flash_info	*info;
 
 	tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, 5);
 	if (tmp < 0) {
@@ -661,11 +675,11 @@ static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
 
 	ext_jedec = id[3] << 8 | id[4];
 
-	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
-		info = (void *)spi_nor_ids[tmp].driver_data;
+	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_info); tmp++) {
+		info = &spi_nor_info[tmp];
 		if (info->jedec_id == jedec) {
 			if (info->ext_id == 0 || info->ext_id == ext_jedec)
-				return &spi_nor_ids[tmp];
+				return info;
 		}
 	}
 	dev_err(nor->dev, "unrecognized JEDEC id %06x\n", jedec);
@@ -912,8 +926,7 @@ static int spi_nor_check(struct spi_nor *nor)
 
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 {
-	const struct spi_device_id	*id = NULL;
-	struct flash_info		*info;
+	const struct flash_info	*info = NULL;
 	struct device *dev = nor->dev;
 	struct mtd_info *mtd = nor->mtd;
 	struct device_node *np = dev->of_node;
@@ -924,19 +937,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 	if (ret)
 		return ret;
 
-	id = spi_nor_match_id(name);
-	if (!id)
+	info = spi_nor_info_by_name(name);
+	if (!info)
 		return -ENODEV;
 
-	info = (void *)id->driver_data;
-
 	if (info->jedec_id) {
-		const struct spi_device_id *jid;
+		const struct flash_info *jinfo;
 
-		jid = spi_nor_read_id(nor);
-		if (IS_ERR(jid)) {
-			return PTR_ERR(jid);
-		} else if (jid != id) {
+		jinfo = spi_nor_info_probe(nor);
+		if (IS_ERR(jinfo)) {
+			return PTR_ERR(jinfo);
+		} else if (jinfo != info) {
 			/*
 			 * JEDEC knows better, so overwrite platform ID. We
 			 * can't trust partitions any longer, but we'll let
@@ -945,9 +956,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 			 * information, even if it's not 100% accurate.
 			 */
 			dev_warn(dev, "found %s, expected %s\n",
-				 jid->name, id->name);
-			id = jid;
-			info = (void *)jid->driver_data;
+				 jinfo->name, info->name);
+			info = jinfo;
 		}
 	}
 
@@ -1093,7 +1103,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 
 	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
 
-	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
 			(long long)mtd->size >> 10);
 
 	dev_dbg(dev,
@@ -1116,18 +1126,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 }
 EXPORT_SYMBOL_GPL(spi_nor_scan);
 
-static const struct spi_device_id *spi_nor_match_id(const char *name)
-{
-	const struct spi_device_id *id = spi_nor_ids;
-
-	while (id->name[0]) {
-		if (!strcmp(name, id->name))
-			return id;
-		id++;
-	}
-	return NULL;
-}
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
 MODULE_AUTHOR("Mike Lavender");


-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/bf538649/attachment-0001.sig>

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
  2014-09-30  2:13 ` Ben Hutchings
@ 2014-09-30  2:15   ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

Move the list of chip type information to a macro in spi-nor.h, but
leave the definitions of INFO and CAT25_INFO in spi-nor.

In m25p80, define the INFO and CAT25_INFO macros to initialise a
struct spi_device_id with the name, ignoring the remaining parameters.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  |  47 +-----------
 drivers/mtd/spi-nor/spi-nor.c | 165 +---------------------------------------
 include/linux/mtd/spi-nor.h   | 173 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 177 insertions(+), 208 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 79bc27a..d13ac07 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -263,51 +263,10 @@ static int m25p_remove(struct spi_device *spi)
 }
 

-/*
- * XXX This needs to be kept in sync with spi_nor_info.  We can't share
- * it with spi-nor, because if this is built as a module then modpost
- * won't be able to read it and add appropriate aliases.
- */
 static const struct spi_device_id m25p_ids[] = {
-	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
-	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
-	{"at26df321"},	{"at45db081d"},
-	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
-	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
-	{"f25l32pa"},
-	{"mr25h256"},	{"mr25h10"},
-	{"gd25q32"},	{"gd25q64"},
-	{"160s33b"},	{"320s33b"},	{"640s33b"},
-	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
-	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
-	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
-	{"mx66l1g55g"},
-	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
-	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
-	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
-	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
-	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
-	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
-	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
-	{"s25fl016k"},	{"s25fl064k"},
-	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
-	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
-	{"sst25wf040"},
-	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
-	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
-	{"m25p128"},	{"n25q032"},
-	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
-	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
-	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
-	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
-	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
-	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
-	{"m25px64"},
-	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
-	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
-	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
-	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
-	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
+#define INFO(name, ...) { name }
+#define CAT25_INFO(name, ...) { name }
+	SPI_NOR_INFO
 	{ },
 };
 MODULE_DEVICE_TABLE(spi, m25p_ids);
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 2449ee5..d98c6e0 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -474,171 +474,8 @@ struct flash_info {
 		.flags = (_flags),					\
 	}
 
-/* NOTE: double check command sets and memory organization when you add
- * more nor chips.  This current list focusses on newer chips, which
- * have been converging on command sets which including JEDEC ID.
- */
 static const struct flash_info spi_nor_info[] = {
-	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
-	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),
-	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),
-
-	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),
-	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),
-	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),
-
-	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),
-	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),
-	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),
-	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),
-
-	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),
-
-	/* EON -- en25xxx */
-	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),
-	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),
-	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),
-	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),
-	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),
-	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),
-	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),
-
-	/* ESMT */
-	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),
-
-	/* Everspin */
-	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-
-	/* GigaDevice */
-	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),
-
-	/* Intel/Numonyx -- xxxs33b */
-	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),
-	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),
-	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),
-
-	/* Macronix */
-	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),
-	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),
-	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),
-	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),
-	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),
-	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),
-	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),
-	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),
-	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),
-	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),
-	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),
-	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ),
-	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ),
-
-	/* Micron */
-	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),
-	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),
-	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),
-	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),
-	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),
-	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),
-	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),
-
-	/* PMC */
-	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),
-	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),
-	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),
-
-	/* Spansion -- single (large) sector size only, at least
-	 * for the chips listed here (without boot sectors).
-	 */
-	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),
-	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),
-	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),
-	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),
-	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),
-	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),
-	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),
-	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),
-	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),
-	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),
-	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),
-	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),
-	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),
-	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),
-	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),
-
-	/* SST -- large erase sizes are "overlays", "sectors" are 4K */
-	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
-	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE),
-	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE),
-	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE),
-	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),
-	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE),
-	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE),
-	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE),
-	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
-
-	/* ST Microelectronics -- newer production may have feature updates */
-	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),
-	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),
-	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),
-	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),
-	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),
-	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),
-	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),
-	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),
-	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),
-	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),
-
-	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),
-	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),
-	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),
-	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),
-	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),
-	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),
-	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),
-	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),
-	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),
-
-	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),
-	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),
-	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),
-
-	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),
-	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),
-	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),
-
-	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),
-	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),
-
-	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),
-	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),
-	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),
-	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),
-	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),
-	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),
-	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),
-	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),
-
-	/* Catalyst / On Semiconductor -- non-JEDEC */
-	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	SPI_NOR_INFO
 };
 
 static const struct flash_info *spi_nor_info_by_name(const char *name)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index c48ad49..8cc7281 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -195,4 +195,177 @@ struct spi_nor {
  */
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
 
+/* NOTE: double check command sets and memory organization when you add
+ * more nor chips.  This current list focusses on newer chips, which
+ * have been converging on command sets which including JEDEC ID.
+ *
+ * Caller must define the macros:
+ *	INFO(name, jedec_id, ext_id, sector_size, n_sectors, flags)
+ *	CAT25_INFO(name, sector_size, n_sectors, page_size, addr_width, flags)
+ */
+#define SPI_NOR_INFO							\
+	/* Atmel -- some are (confusingly) marketed as "DataFlash" */	\
+	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),	\
+	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),	\
+									\
+	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),	\
+	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),	\
+	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),	\
+									\
+	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),	\
+	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),	\
+	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),	\
+	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),	\
+									\
+	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),	\
+									\
+	/* EON -- en25xxx */						\
+	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),	\
+	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),		\
+	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),		\
+	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),		\
+	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),	\
+	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),		\
+	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),		\
+									\
+	/* ESMT */							\
+	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),		\
+									\
+	/* Everspin */							\
+	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+									\
+	/* GigaDevice */						\
+	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),		\
+									\
+	/* Intel/Numonyx -- xxxs33b */					\
+	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),		\
+	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),		\
+	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),		\
+									\
+	/* Macronix */							\
+	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),	\
+	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),	\
+	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),		\
+	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),	\
+	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),		\
+	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),	\
+	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),		\
+	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),		\
+	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),		\
+	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),		\
+	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),		\
+	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ), \
+	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ), \
+									\
+	/* Micron */							\
+	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),		\
+	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),		\
+	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),		\
+	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),	\
+	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),	\
+	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),	\
+	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),	\
+									\
+	/* PMC */							\
+	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),	\
+	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),	\
+	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),	\
+									\
+	/* Spansion -- single (large), sector size only, at least	\
+	 * for the chips listed here (without boot sectors),.		\
+	 */								\
+	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),	\
+	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),	\
+	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),	\
+	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),	\
+	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),	\
+	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),	\
+	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),	\
+	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),	\
+	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),	\
+	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),	\
+	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),	\
+	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),	\
+	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),	\
+	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),	\
+	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),	\
+									\
+	/* SST -- large erase sizes are "overlays", "sectors" are 4K */	\
+	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE), \
+	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE), \
+	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE), \
+	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE), \
+	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),	\
+	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE), \
+	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE), \
+	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE), \
+	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE), \
+									\
+	/* ST Microelectronics -- newer production may have feature updates */ \
+	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),		\
+	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),		\
+	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),		\
+	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),		\
+	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),		\
+	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),		\
+	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),		\
+	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),		\
+	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),		\
+	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),		\
+									\
+	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),		\
+	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),		\
+	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),		\
+	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),		\
+	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),		\
+	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),		\
+	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),		\
+	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),		\
+	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),		\
+									\
+	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),		\
+	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),		\
+	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),		\
+									\
+	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),		\
+	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),		\
+	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),		\
+									\
+	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),	\
+	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),		\
+									\
+	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */	\
+	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),		\
+	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),		\
+	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),		\
+	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),		\
+	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),		\
+	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),		\
+	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),		\
+	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),		\
+									\
+	/* Catalyst / On Semiconductor -- non-JEDEC */			\
+	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+									\
+	/* end SPI_NOR_INFO */
+
+
 #endif

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
@ 2014-09-30  2:15   ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30  2:15 UTC (permalink / raw)
  To: linux-arm-kernel

Move the list of chip type information to a macro in spi-nor.h, but
leave the definitions of INFO and CAT25_INFO in spi-nor.

In m25p80, define the INFO and CAT25_INFO macros to initialise a
struct spi_device_id with the name, ignoring the remaining parameters.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/mtd/devices/m25p80.c  |  47 +-----------
 drivers/mtd/spi-nor/spi-nor.c | 165 +---------------------------------------
 include/linux/mtd/spi-nor.h   | 173 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 177 insertions(+), 208 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 79bc27a..d13ac07 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -263,51 +263,10 @@ static int m25p_remove(struct spi_device *spi)
 }
 

-/*
- * XXX This needs to be kept in sync with spi_nor_info.  We can't share
- * it with spi-nor, because if this is built as a module then modpost
- * won't be able to read it and add appropriate aliases.
- */
 static const struct spi_device_id m25p_ids[] = {
-	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
-	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
-	{"at26df321"},	{"at45db081d"},
-	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
-	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
-	{"f25l32pa"},
-	{"mr25h256"},	{"mr25h10"},
-	{"gd25q32"},	{"gd25q64"},
-	{"160s33b"},	{"320s33b"},	{"640s33b"},
-	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
-	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
-	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
-	{"mx66l1g55g"},
-	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
-	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
-	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
-	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
-	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
-	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
-	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
-	{"s25fl016k"},	{"s25fl064k"},
-	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
-	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
-	{"sst25wf040"},
-	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
-	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
-	{"m25p128"},	{"n25q032"},
-	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
-	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
-	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
-	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
-	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
-	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
-	{"m25px64"},
-	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
-	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
-	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
-	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
-	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
+#define INFO(name, ...) { name }
+#define CAT25_INFO(name, ...) { name }
+	SPI_NOR_INFO
 	{ },
 };
 MODULE_DEVICE_TABLE(spi, m25p_ids);
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 2449ee5..d98c6e0 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -474,171 +474,8 @@ struct flash_info {
 		.flags = (_flags),					\
 	}
 
-/* NOTE: double check command sets and memory organization when you add
- * more nor chips.  This current list focusses on newer chips, which
- * have been converging on command sets which including JEDEC ID.
- */
 static const struct flash_info spi_nor_info[] = {
-	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
-	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),
-	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),
-
-	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),
-	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),
-	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),
-
-	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),
-	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),
-	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),
-	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),
-
-	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),
-
-	/* EON -- en25xxx */
-	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),
-	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),
-	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),
-	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),
-	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),
-	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),
-	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),
-
-	/* ESMT */
-	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),
-
-	/* Everspin */
-	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-
-	/* GigaDevice */
-	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),
-
-	/* Intel/Numonyx -- xxxs33b */
-	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),
-	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),
-	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),
-
-	/* Macronix */
-	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),
-	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),
-	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),
-	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),
-	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),
-	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),
-	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),
-	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),
-	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),
-	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),
-	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),
-	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ),
-	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ),
-
-	/* Micron */
-	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),
-	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),
-	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),
-	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),
-	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),
-	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),
-	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),
-
-	/* PMC */
-	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),
-	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),
-	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),
-
-	/* Spansion -- single (large) sector size only, at least
-	 * for the chips listed here (without boot sectors).
-	 */
-	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),
-	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),
-	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ),
-	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),
-	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),
-	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),
-	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),
-	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),
-	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),
-	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),
-	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),
-	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),
-	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),
-	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),
-	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),
-	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),
-
-	/* SST -- large erase sizes are "overlays", "sectors" are 4K */
-	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
-	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE),
-	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE),
-	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE),
-	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),
-	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE),
-	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE),
-	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE),
-	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE),
-
-	/* ST Microelectronics -- newer production may have feature updates */
-	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),
-	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),
-	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),
-	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),
-	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),
-	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),
-	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),
-	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),
-	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),
-	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),
-
-	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),
-	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),
-	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),
-	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),
-	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),
-	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),
-	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),
-	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),
-	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),
-
-	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),
-	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),
-	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),
-
-	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),
-	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),
-	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),
-
-	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),
-	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),
-	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),
-
-	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),
-	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),
-	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),
-	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),
-	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),
-	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),
-	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),
-	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),
-	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),
-	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),
-
-	/* Catalyst / On Semiconductor -- non-JEDEC */
-	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
-	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR),
+	SPI_NOR_INFO
 };
 
 static const struct flash_info *spi_nor_info_by_name(const char *name)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index c48ad49..8cc7281 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -195,4 +195,177 @@ struct spi_nor {
  */
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
 
+/* NOTE: double check command sets and memory organization when you add
+ * more nor chips.  This current list focusses on newer chips, which
+ * have been converging on command sets which including JEDEC ID.
+ *
+ * Caller must define the macros:
+ *	INFO(name, jedec_id, ext_id, sector_size, n_sectors, flags)
+ *	CAT25_INFO(name, sector_size, n_sectors, page_size, addr_width, flags)
+ */
+#define SPI_NOR_INFO							\
+	/* Atmel -- some are (confusingly) marketed as "DataFlash" */	\
+	INFO("at25fs010",  0x1f6601, 0, 32 * 1024,   4, SECT_4K),	\
+	INFO("at25fs040",  0x1f6604, 0, 64 * 1024,   8, SECT_4K),	\
+									\
+	INFO("at25df041a", 0x1f4401, 0, 64 * 1024,   8, SECT_4K),	\
+	INFO("at25df321a", 0x1f4701, 0, 64 * 1024,  64, SECT_4K),	\
+	INFO("at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K),	\
+									\
+	INFO("at26f004",   0x1f0400, 0, 64 * 1024,  8, SECT_4K),	\
+	INFO("at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K),	\
+	INFO("at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K),	\
+	INFO("at26df321",  0x1f4700, 0, 64 * 1024, 64, SECT_4K),	\
+									\
+	INFO("at45db081d", 0x1f2500, 0, 64 * 1024, 16, SECT_4K),	\
+									\
+	/* EON -- en25xxx */						\
+	INFO("en25f32",    0x1c3116, 0, 64 * 1024,   64, SECT_4K),	\
+	INFO("en25p32",    0x1c2016, 0, 64 * 1024,   64, 0),		\
+	INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0),		\
+	INFO("en25p64",    0x1c2017, 0, 64 * 1024,  128, 0),		\
+	INFO("en25q64",    0x1c3017, 0, 64 * 1024,  128, SECT_4K),	\
+	INFO("en25qh128",  0x1c7018, 0, 64 * 1024,  256, 0),		\
+	INFO("en25qh256",  0x1c7019, 0, 64 * 1024,  512, 0),		\
+									\
+	/* ESMT */							\
+	INFO("f25l32pa", 0x8c2016, 0, 64 * 1024, 64, SECT_4K),		\
+									\
+	/* Everspin */							\
+	CAT25_INFO("mr25h256",  32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("mr25h10",  128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+									\
+	/* GigaDevice */						\
+	INFO("gd25q32", 0xc84016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("gd25q64", 0xc84017, 0, 64 * 1024, 128, SECT_4K),		\
+									\
+	/* Intel/Numonyx -- xxxs33b */					\
+	INFO("160s33b",  0x898911, 0, 64 * 1024,  32, 0),		\
+	INFO("320s33b",  0x898912, 0, 64 * 1024,  64, 0),		\
+	INFO("640s33b",  0x898913, 0, 64 * 1024, 128, 0),		\
+									\
+	/* Macronix */							\
+	INFO("mx25l2005a",  0xc22012, 0, 64 * 1024,   4, SECT_4K),	\
+	INFO("mx25l4005a",  0xc22013, 0, 64 * 1024,   8, SECT_4K),	\
+	INFO("mx25l8005",   0xc22014, 0, 64 * 1024,  16, 0),		\
+	INFO("mx25l1606e",  0xc22015, 0, 64 * 1024,  32, SECT_4K),	\
+	INFO("mx25l3205d",  0xc22016, 0, 64 * 1024,  64, 0),		\
+	INFO("mx25l3255e",  0xc29e16, 0, 64 * 1024,  64, SECT_4K),	\
+	INFO("mx25l6405d",  0xc22017, 0, 64 * 1024, 128, 0),		\
+	INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, 0),		\
+	INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0),		\
+	INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, 0),		\
+	INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0),		\
+	INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ), \
+	INFO("mx66l1g55g",  0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ), \
+									\
+	/* Micron */							\
+	INFO("n25q064",     0x20ba17, 0, 64 * 1024,  128, 0),		\
+	INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, 0),		\
+	INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, 0),		\
+	INFO("n25q256a",    0x20ba19, 0, 64 * 1024,  512, SECT_4K),	\
+	INFO("n25q512a",    0x20bb20, 0, 64 * 1024, 1024, SECT_4K),	\
+	INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, USE_FSR),	\
+	INFO("n25q00",      0x20ba21, 0, 64 * 1024, 2048, USE_FSR),	\
+									\
+	/* PMC */							\
+	INFO("pm25lv512",   0,        0, 32 * 1024,    2, SECT_4K_PMC),	\
+	INFO("pm25lv010",   0,        0, 32 * 1024,    4, SECT_4K_PMC),	\
+	INFO("pm25lq032",   0x7f9d46, 0, 64 * 1024,   64, SECT_4K),	\
+									\
+	/* Spansion -- single (large), sector size only, at least	\
+	 * for the chips listed here (without boot sectors),.		\
+	 */								\
+	INFO("s25sl032p",  0x010215, 0x4d00,  64 * 1024,  64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s25sl064p",  0x010216, 0x4d00,  64 * 1024, 128, 0),	\
+	INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, 0),	\
+	INFO("s25fl256s1", 0x010219, 0x4d01,  64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s25fl512s",  0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ), \
+	INFO("s70fl01gs",  0x010221, 0x4d00, 256 * 1024, 256, 0),	\
+	INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024,  64, 0),	\
+	INFO("s25sl12801", 0x012018, 0x0301,  64 * 1024, 256, 0),	\
+	INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024,  64, 0),	\
+	INFO("s25fl129p1", 0x012018, 0x4d01,  64 * 1024, 256, 0),	\
+	INFO("s25sl004a",  0x010212,      0,  64 * 1024,   8, 0),	\
+	INFO("s25sl008a",  0x010213,      0,  64 * 1024,  16, 0),	\
+	INFO("s25sl016a",  0x010214,      0,  64 * 1024,  32, 0),	\
+	INFO("s25sl032a",  0x010215,      0,  64 * 1024,  64, 0),	\
+	INFO("s25sl064a",  0x010216,      0,  64 * 1024, 128, 0),	\
+	INFO("s25fl008k",  0xef4014,      0,  64 * 1024,  16, SECT_4K),	\
+	INFO("s25fl016k",  0xef4015,      0,  64 * 1024,  32, SECT_4K),	\
+	INFO("s25fl064k",  0xef4017,      0,  64 * 1024, 128, SECT_4K),	\
+									\
+	/* SST -- large erase sizes are "overlays", "sectors" are 4K */	\
+	INFO("sst25vf040b", 0xbf258d, 0, 64 * 1024,  8, SECT_4K | SST_WRITE), \
+	INFO("sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K | SST_WRITE), \
+	INFO("sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K | SST_WRITE), \
+	INFO("sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K | SST_WRITE), \
+	INFO("sst25vf064c", 0xbf254b, 0, 64 * 1024, 128, SECT_4K),	\
+	INFO("sst25wf512",  0xbf2501, 0, 64 * 1024,  1, SECT_4K | SST_WRITE), \
+	INFO("sst25wf010",  0xbf2502, 0, 64 * 1024,  2, SECT_4K | SST_WRITE), \
+	INFO("sst25wf020",  0xbf2503, 0, 64 * 1024,  4, SECT_4K | SST_WRITE), \
+	INFO("sst25wf040",  0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE), \
+									\
+	/* ST Microelectronics -- newer production may have feature updates */ \
+	INFO("m25p05",  0x202010,  0,  32 * 1024,   2, 0),		\
+	INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0),		\
+	INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0),		\
+	INFO("m25p40",  0x202013,  0,  64 * 1024,   8, 0),		\
+	INFO("m25p80",  0x202014,  0,  64 * 1024,  16, 0),		\
+	INFO("m25p16",  0x202015,  0,  64 * 1024,  32, 0),		\
+	INFO("m25p32",  0x202016,  0,  64 * 1024,  64, 0),		\
+	INFO("m25p64",  0x202017,  0,  64 * 1024, 128, 0),		\
+	INFO("m25p128", 0x202018,  0, 256 * 1024,  64, 0),		\
+	INFO("n25q032", 0x20ba16,  0,  64 * 1024,  64, 0),		\
+									\
+	INFO("m25p05-nonjedec",  0, 0,  32 * 1024,   2, 0),		\
+	INFO("m25p10-nonjedec",  0, 0,  32 * 1024,   4, 0),		\
+	INFO("m25p20-nonjedec",  0, 0,  64 * 1024,   4, 0),		\
+	INFO("m25p40-nonjedec",  0, 0,  64 * 1024,   8, 0),		\
+	INFO("m25p80-nonjedec",  0, 0,  64 * 1024,  16, 0),		\
+	INFO("m25p16-nonjedec",  0, 0,  64 * 1024,  32, 0),		\
+	INFO("m25p32-nonjedec",  0, 0,  64 * 1024,  64, 0),		\
+	INFO("m25p64-nonjedec",  0, 0,  64 * 1024, 128, 0),		\
+	INFO("m25p128-nonjedec", 0, 0, 256 * 1024,  64, 0),		\
+									\
+	INFO("m45pe10", 0x204011,  0, 64 * 1024,    2, 0),		\
+	INFO("m45pe80", 0x204014,  0, 64 * 1024,   16, 0),		\
+	INFO("m45pe16", 0x204015,  0, 64 * 1024,   32, 0),		\
+									\
+	INFO("m25pe20", 0x208012,  0, 64 * 1024,  4,       0),		\
+	INFO("m25pe80", 0x208014,  0, 64 * 1024, 16,       0),		\
+	INFO("m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K),		\
+									\
+	INFO("m25px16",    0x207115,  0, 64 * 1024, 32, SECT_4K),	\
+	INFO("m25px32",    0x207116,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px32-s0", 0x207316,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px32-s1", 0x206316,  0, 64 * 1024, 64, SECT_4K),	\
+	INFO("m25px64",    0x207117,  0, 64 * 1024, 128, 0),		\
+									\
+	/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */	\
+	INFO("w25x10", 0xef3011, 0, 64 * 1024,  2,  SECT_4K),		\
+	INFO("w25x20", 0xef3012, 0, 64 * 1024,  4,  SECT_4K),		\
+	INFO("w25x40", 0xef3013, 0, 64 * 1024,  8,  SECT_4K),		\
+	INFO("w25x80", 0xef3014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25x16", 0xef3015, 0, 64 * 1024,  32, SECT_4K),		\
+	INFO("w25x32", 0xef3016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25q32", 0xef4016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25q32dw", 0xef6016, 0, 64 * 1024,  64, SECT_4K),		\
+	INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K),		\
+	INFO("w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K),		\
+	INFO("w25q80", 0xef5014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25q80bl", 0xef4014, 0, 64 * 1024,  16, SECT_4K),		\
+	INFO("w25q128", 0xef4018, 0, 64 * 1024, 256, SECT_4K),		\
+	INFO("w25q256", 0xef4019, 0, 64 * 1024, 512, SECT_4K),		\
+									\
+	/* Catalyst / On Semiconductor -- non-JEDEC */			\
+	CAT25_INFO("cat25c11",   16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c03",   32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c09",  128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25c17",  256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+	CAT25_INFO("cat25128", 2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR), \
+									\
+	/* end SPI_NOR_INFO */
+
+
 #endif

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/31d15c5a/attachment.sig>

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

* Re: [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
  2014-09-30  2:15   ` Ben Hutchings
@ 2014-09-30  5:14     ` Rafał Miłecki
  -1 siblings, 0 replies; 34+ messages in thread
From: Rafał Miłecki @ 2014-09-30  5:14 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, MTD Maling List, Ian Campbell,
	Geert Uytterhoeven, Brian Norris, Huang Shijie, linux-arm-kernel,
	debian-kernel

On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> @@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
>          * If that's the case, respect "type" and ignore a "name".
>          */
>         if (data && data->type)
> -               id = spi_nor_match_id(data->type);
> +               name = data->type;
>
>         /* If we didn't get name from platform, simply use "modalias". */
> -       if (!id) {
> -               id = spi_nor_match_id(spi_get_device_id(spi)->name);
> -               if (WARN_ON(!id))
> -                       return -ENODEV;
> -       }
> +       if (!name)
> +               name = spi_get_device_id(spi)->name;

Huh? Iterating the whole id_table, checking the entries (looking for
one with name equal to the spi->modalias) and then... getting that
name?

Did it hurt to use the patch I've sent
mtd: m25p80: get rid of spi_get_device_id
https://patchwork.ozlabs.org/patch/394328/

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

* [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
@ 2014-09-30  5:14     ` Rafał Miłecki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafał Miłecki @ 2014-09-30  5:14 UTC (permalink / raw)
  To: linux-arm-kernel

On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> @@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
>          * If that's the case, respect "type" and ignore a "name".
>          */
>         if (data && data->type)
> -               id = spi_nor_match_id(data->type);
> +               name = data->type;
>
>         /* If we didn't get name from platform, simply use "modalias". */
> -       if (!id) {
> -               id = spi_nor_match_id(spi_get_device_id(spi)->name);
> -               if (WARN_ON(!id))
> -                       return -ENODEV;
> -       }
> +       if (!name)
> +               name = spi_get_device_id(spi)->name;

Huh? Iterating the whole id_table, checking the entries (looking for
one with name equal to the spi->modalias) and then... getting that
name?

Did it hurt to use the patch I've sent
mtd: m25p80: get rid of spi_get_device_id
https://patchwork.ozlabs.org/patch/394328/

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

* Re: [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
  2014-09-30  2:15   ` Ben Hutchings
@ 2014-09-30  7:22     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2014-09-30  7:22 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Brian Norris, Huang Shijie,
	linux-arm-kernel, debian-kernel

Hi Ben,

On Tue, Sep 30, 2014 at 4:15 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
> Move the list of chip type information to a macro in spi-nor.h, but
> leave the definitions of INFO and CAT25_INFO in spi-nor.
>
> In m25p80, define the INFO and CAT25_INFO macros to initialise a
> struct spi_device_id with the name, ignoring the remaining parameters.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Thanks!

I didn't have an in-depth look, but this looks much better, and has less
opportunities for getting out-of-sync.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
@ 2014-09-30  7:22     ` Geert Uytterhoeven
  0 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2014-09-30  7:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ben,

On Tue, Sep 30, 2014 at 4:15 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
> Move the list of chip type information to a macro in spi-nor.h, but
> leave the definitions of INFO and CAT25_INFO in spi-nor.
>
> In m25p80, define the INFO and CAT25_INFO macros to initialise a
> struct spi_device_id with the name, ignoring the remaining parameters.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Thanks!

I didn't have an in-depth look, but this looks much better, and has less
opportunities for getting out-of-sync.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
  2014-09-30  2:15   ` Ben Hutchings
@ 2014-09-30  8:02     ` Rafał Miłecki
  -1 siblings, 0 replies; 34+ messages in thread
From: Rafał Miłecki @ 2014-09-30  8:02 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, MTD Maling List, Ian Campbell,
	Geert Uytterhoeven, Brian Norris, Huang Shijie, linux-arm-kernel,
	debian-kernel

On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> Move the list of chip type information to a macro in spi-nor.h, but
> leave the definitions of INFO and CAT25_INFO in spi-nor.
>
> In m25p80, define the INFO and CAT25_INFO macros to initialise a
> struct spi_device_id with the name, ignoring the remaining parameters.

Anyone would consider my idea proposed in 1/5 thread?

We could simply follow the way Linux-specific platform data works. We
could always use
compatible = "m25p80";
and then for some rare cases (where JEDEC fails) add something like
model = "at25df321a";

Using above way we could use a one single "compatible" in m25p80.c and
avoid this messy share of id_table.

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
@ 2014-09-30  8:02     ` Rafał Miłecki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafał Miłecki @ 2014-09-30  8:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> Move the list of chip type information to a macro in spi-nor.h, but
> leave the definitions of INFO and CAT25_INFO in spi-nor.
>
> In m25p80, define the INFO and CAT25_INFO macros to initialise a
> struct spi_device_id with the name, ignoring the remaining parameters.

Anyone would consider my idea proposed in 1/5 thread?

We could simply follow the way Linux-specific platform data works. We
could always use
compatible = "m25p80";
and then for some rare cases (where JEDEC fails) add something like
model = "at25df321a";

Using above way we could use a one single "compatible" in m25p80.c and
avoid this messy share of id_table.

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

* Re: [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
  2014-09-30  8:02     ` Rafał Miłecki
@ 2014-09-30 11:36       ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30 11:36 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Andrew Lunn, Jason Cooper, MTD Maling List, Ian Campbell,
	Geert Uytterhoeven, Brian Norris, Huang Shijie, linux-arm-kernel,
	debian-kernel

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

On Tue, 2014-09-30 at 10:02 +0200, Rafał Miłecki wrote:
> On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > Move the list of chip type information to a macro in spi-nor.h, but
> > leave the definitions of INFO and CAT25_INFO in spi-nor.
> >
> > In m25p80, define the INFO and CAT25_INFO macros to initialise a
> > struct spi_device_id with the name, ignoring the remaining parameters.
> 
> Anyone would consider my idea proposed in 1/5 thread?
> 
> We could simply follow the way Linux-specific platform data works. We
> could always use
> compatible = "m25p80";
> and then for some rare cases (where JEDEC fails) add something like
> model = "at25df321a";
> 
> Using above way we could use a one single "compatible" in m25p80.c and
> avoid this messy share of id_table.

You *cannot* define a DT compatible string by reference to out-of-band
information about all the chips that has to be updated for each new
chip.

That is not 'compatible'.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
@ 2014-09-30 11:36       ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30 11:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2014-09-30 at 10:02 +0200, Rafa? Mi?ecki wrote:
> On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > Move the list of chip type information to a macro in spi-nor.h, but
> > leave the definitions of INFO and CAT25_INFO in spi-nor.
> >
> > In m25p80, define the INFO and CAT25_INFO macros to initialise a
> > struct spi_device_id with the name, ignoring the remaining parameters.
> 
> Anyone would consider my idea proposed in 1/5 thread?
> 
> We could simply follow the way Linux-specific platform data works. We
> could always use
> compatible = "m25p80";
> and then for some rare cases (where JEDEC fails) add something like
> model = "at25df321a";
> 
> Using above way we could use a one single "compatible" in m25p80.c and
> avoid this messy share of id_table.

You *cannot* define a DT compatible string by reference to out-of-band
information about all the chips that has to be updated for each new
chip.

That is not 'compatible'.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/63ecbf08/attachment.sig>

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

* Re: [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
  2014-09-30  5:14     ` Rafał Miłecki
@ 2014-09-30 11:38       ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30 11:38 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Andrew Lunn, Jason Cooper, MTD Maling List, Ian Campbell,
	Geert Uytterhoeven, Brian Norris, Huang Shijie, linux-arm-kernel,
	debian-kernel

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

On Tue, 2014-09-30 at 07:14 +0200, Rafał Miłecki wrote:
> On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > @@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
> >          * If that's the case, respect "type" and ignore a "name".
> >          */
> >         if (data && data->type)
> > -               id = spi_nor_match_id(data->type);
> > +               name = data->type;
> >
> >         /* If we didn't get name from platform, simply use "modalias". */
> > -       if (!id) {
> > -               id = spi_nor_match_id(spi_get_device_id(spi)->name);
> > -               if (WARN_ON(!id))
> > -                       return -ENODEV;
> > -       }
> > +       if (!name)
> > +               name = spi_get_device_id(spi)->name;
> 
> Huh? Iterating the whole id_table, checking the entries (looking for
> one with name equal to the spi->modalias) and then... getting that
> name?

Ah, I didn't realise what spi_get_device_id() was doing.

> Did it hurt to use the patch I've sent
> mtd: m25p80: get rid of spi_get_device_id
> https://patchwork.ozlabs.org/patch/394328/

It would make sense to insert that before this.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
@ 2014-09-30 11:38       ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-09-30 11:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2014-09-30 at 07:14 +0200, Rafa? Mi?ecki wrote:
> On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > @@ -236,16 +236,13 @@ static int m25p_probe(struct spi_device *spi)
> >          * If that's the case, respect "type" and ignore a "name".
> >          */
> >         if (data && data->type)
> > -               id = spi_nor_match_id(data->type);
> > +               name = data->type;
> >
> >         /* If we didn't get name from platform, simply use "modalias". */
> > -       if (!id) {
> > -               id = spi_nor_match_id(spi_get_device_id(spi)->name);
> > -               if (WARN_ON(!id))
> > -                       return -ENODEV;
> > -       }
> > +       if (!name)
> > +               name = spi_get_device_id(spi)->name;
> 
> Huh? Iterating the whole id_table, checking the entries (looking for
> one with name equal to the spi->modalias) and then... getting that
> name?

Ah, I didn't realise what spi_get_device_id() was doing.

> Did it hurt to use the patch I've sent
> mtd: m25p80: get rid of spi_get_device_id
> https://patchwork.ozlabs.org/patch/394328/

It would make sense to insert that before this.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/a819adbf/attachment.sig>

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

* Re: [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
  2014-09-30  2:14   ` Ben Hutchings
@ 2014-10-10  4:51     ` Brian Norris
  -1 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-10  4:51 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> its use was also removed at the same time.  Now if m25p80 is built as
> a module it doesn't get the necessary aliases to be loaded
> automatically.
> 
> A clean solution to this will involve defining the list of device
> IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> API, but this is quite a large change.
> 
> As a quick fix suitable for stable, copy the device IDs back into
> m25p80.
> 
> Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> Cc: stable <stable@vger.kernel.org> # 3.16.x
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Can I get any acks/tested-by's? I'll try to test this out when I get
back to the office, but I'd like to be able to send this in the 3.18
cycle still.

As for the rest of the series, well we still have a few things to agree
on...

> ---
>  drivers/mtd/devices/m25p80.c  | 59 ++++++++++++++++++++++++++++++++++++++++---
>  drivers/mtd/spi-nor/spi-nor.c |  5 ++--
>  include/linux/mtd/spi-nor.h   |  3 +--
>  3 files changed, 59 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index dcda628..204bec1 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -239,8 +239,11 @@ static int m25p_probe(struct spi_device *spi)
>  		id = spi_nor_match_id(data->type);
>  
>  	/* If we didn't get name from platform, simply use "modalias". */
> -	if (!id)
> -		id = spi_get_device_id(spi);
> +	if (!id) {
> +		id = spi_nor_match_id(spi_get_device_id(spi)->name);
> +		if (WARN_ON(!id))
> +			return -ENODEV;
> +	}
>  
>  	ret = spi_nor_scan(nor, id, mode);
>  	if (ret)
> @@ -263,12 +266,62 @@ static int m25p_remove(struct spi_device *spi)
>  }
>  
> 
> +/*
> + * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
> + * it with spi-nor, because if this is built as a module then modpost
> + * won't be able to read it and add appropriate aliases.
> + */
> +static const struct spi_device_id m25p_ids[] = {
> +	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
> +	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
> +	{"at26df321"},	{"at45db081d"},
> +	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
> +	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
> +	{"f25l32pa"},
> +	{"mr25h256"},	{"mr25h10"},
> +	{"gd25q32"},	{"gd25q64"},
> +	{"160s33b"},	{"320s33b"},	{"640s33b"},
> +	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
> +	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
> +	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
> +	{"mx66l1g55g"},
> +	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
> +	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
> +	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
> +	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
> +	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
> +	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
> +	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
> +	{"s25fl016k"},	{"s25fl064k"},
> +	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
> +	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
> +	{"sst25wf040"},
> +	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
> +	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
> +	{"m25p128"},	{"n25q032"},
> +	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
> +	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
> +	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
> +	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
> +	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
> +	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
> +	{"m25px64"},
> +	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
> +	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
> +	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
> +	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
> +	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(spi, m25p_ids);
> +
> +
>  static struct spi_driver m25p80_driver = {
>  	.driver = {
>  		.name	= "m25p80",
>  		.owner	= THIS_MODULE,
>  	},
> -	.id_table	= spi_nor_ids,
> +	.id_table	= m25p_ids,
>  	.probe	= m25p_probe,
>  	.remove	= m25p_remove,
>  
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index ae16aa2..53783ed 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -473,7 +473,7 @@ struct flash_info {
>   * more nor chips.  This current list focusses on newer chips, which
>   * have been converging on command sets which including JEDEC ID.
>   */
> -const struct spi_device_id spi_nor_ids[] = {
> +static const struct spi_device_id spi_nor_ids[] = {
>  	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
>  	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
>  	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
> @@ -637,7 +637,6 @@ const struct spi_device_id spi_nor_ids[] = {
>  	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
>  	{ },
>  };
> -EXPORT_SYMBOL_GPL(spi_nor_ids);
>  
>  static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
>  {
> @@ -1113,7 +1112,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
>  }
>  EXPORT_SYMBOL_GPL(spi_nor_scan);
>  
> -const struct spi_device_id *spi_nor_match_id(char *name)
> +const struct spi_device_id *spi_nor_match_id(const char *name)
>  {
>  	const struct spi_device_id *id = spi_nor_ids;
>  
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index 9e6294f..5ec84cc 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -201,7 +201,6 @@ struct spi_nor {
>   */
>  int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
>  			enum read_mode mode);
> -extern const struct spi_device_id spi_nor_ids[];
>  
>  /**
>   * spi_nor_match_id() - find the spi_device_id by the name
> @@ -213,6 +212,6 @@ extern const struct spi_device_id spi_nor_ids[];
>   * Return: returns the right spi_device_id pointer on success,
>   *         and returns NULL on failure.
>   */
> -const struct spi_device_id *spi_nor_match_id(char *name);
> +const struct spi_device_id *spi_nor_match_id(const char *name);
>  
>  #endif
> 
> 

Brian

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
@ 2014-10-10  4:51     ` Brian Norris
  0 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-10  4:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> its use was also removed at the same time.  Now if m25p80 is built as
> a module it doesn't get the necessary aliases to be loaded
> automatically.
> 
> A clean solution to this will involve defining the list of device
> IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> API, but this is quite a large change.
> 
> As a quick fix suitable for stable, copy the device IDs back into
> m25p80.
> 
> Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> Cc: stable <stable@vger.kernel.org> # 3.16.x
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Can I get any acks/tested-by's? I'll try to test this out when I get
back to the office, but I'd like to be able to send this in the 3.18
cycle still.

As for the rest of the series, well we still have a few things to agree
on...

> ---
>  drivers/mtd/devices/m25p80.c  | 59 ++++++++++++++++++++++++++++++++++++++++---
>  drivers/mtd/spi-nor/spi-nor.c |  5 ++--
>  include/linux/mtd/spi-nor.h   |  3 +--
>  3 files changed, 59 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index dcda628..204bec1 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -239,8 +239,11 @@ static int m25p_probe(struct spi_device *spi)
>  		id = spi_nor_match_id(data->type);
>  
>  	/* If we didn't get name from platform, simply use "modalias". */
> -	if (!id)
> -		id = spi_get_device_id(spi);
> +	if (!id) {
> +		id = spi_nor_match_id(spi_get_device_id(spi)->name);
> +		if (WARN_ON(!id))
> +			return -ENODEV;
> +	}
>  
>  	ret = spi_nor_scan(nor, id, mode);
>  	if (ret)
> @@ -263,12 +266,62 @@ static int m25p_remove(struct spi_device *spi)
>  }
>  
> 
> +/*
> + * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
> + * it with spi-nor, because if this is built as a module then modpost
> + * won't be able to read it and add appropriate aliases.
> + */
> +static const struct spi_device_id m25p_ids[] = {
> +	{"at25fs010"},	{"at25fs040"},	{"at25df041a"},	{"at25df321a"},
> +	{"at25df641"},	{"at26f004"},	{"at26df081a"},	{"at26df161a"},
> +	{"at26df321"},	{"at45db081d"},
> +	{"en25f32"},	{"en25p32"},	{"en25q32b"},	{"en25p64"},
> +	{"en25q64"},	{"en25qh128"},	{"en25qh256"},
> +	{"f25l32pa"},
> +	{"mr25h256"},	{"mr25h10"},
> +	{"gd25q32"},	{"gd25q64"},
> +	{"160s33b"},	{"320s33b"},	{"640s33b"},
> +	{"mx25l2005a"},	{"mx25l4005a"},	{"mx25l8005"},	{"mx25l1606e"},
> +	{"mx25l3205d"},	{"mx25l3255e"},	{"mx25l6405d"},	{"mx25l12805d"},
> +	{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
> +	{"mx66l1g55g"},
> +	{"n25q064"},	{"n25q128a11"},	{"n25q128a13"},	{"n25q256a"},
> +	{"n25q512a"},	{"n25q512ax3"},	{"n25q00"},
> +	{"pm25lv512"},	{"pm25lv010"},	{"pm25lq032"},
> +	{"s25sl032p"},	{"s25sl064p"},	{"s25fl256s0"},	{"s25fl256s1"},
> +	{"s25fl512s"},	{"s70fl01gs"},	{"s25sl12800"},	{"s25sl12801"},
> +	{"s25fl129p0"},	{"s25fl129p1"},	{"s25sl004a"},	{"s25sl008a"},
> +	{"s25sl016a"},	{"s25sl032a"},	{"s25sl064a"},	{"s25fl008k"},
> +	{"s25fl016k"},	{"s25fl064k"},
> +	{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
> +	{"sst25vf064c"},{"sst25wf512"},	{"sst25wf010"},	{"sst25wf020"},
> +	{"sst25wf040"},
> +	{"m25p05"},	{"m25p10"},	{"m25p20"},	{"m25p40"},
> +	{"m25p80"},	{"m25p16"},	{"m25p32"},	{"m25p64"},
> +	{"m25p128"},	{"n25q032"},
> +	{"m25p05-nonjedec"},	{"m25p10-nonjedec"},	{"m25p20-nonjedec"},
> +	{"m25p40-nonjedec"},	{"m25p80-nonjedec"},	{"m25p16-nonjedec"},
> +	{"m25p32-nonjedec"},	{"m25p64-nonjedec"},	{"m25p128-nonjedec"},
> +	{"m45pe10"},	{"m45pe80"},	{"m45pe16"},
> +	{"m25pe20"},	{"m25pe80"},	{"m25pe16"},
> +	{"m25px16"},	{"m25px32"},	{"m25px32-s0"},	{"m25px32-s1"},
> +	{"m25px64"},
> +	{"w25x10"},	{"w25x20"},	{"w25x40"},	{"w25x80"},
> +	{"w25x16"},	{"w25x32"},	{"w25q32"},	{"w25q32dw"},
> +	{"w25x64"},	{"w25q64"},	{"w25q128"},	{"w25q80"},
> +	{"w25q80bl"},	{"w25q128"},	{"w25q256"},	{"cat25c11"},
> +	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(spi, m25p_ids);
> +
> +
>  static struct spi_driver m25p80_driver = {
>  	.driver = {
>  		.name	= "m25p80",
>  		.owner	= THIS_MODULE,
>  	},
> -	.id_table	= spi_nor_ids,
> +	.id_table	= m25p_ids,
>  	.probe	= m25p_probe,
>  	.remove	= m25p_remove,
>  
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index ae16aa2..53783ed 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -473,7 +473,7 @@ struct flash_info {
>   * more nor chips.  This current list focusses on newer chips, which
>   * have been converging on command sets which including JEDEC ID.
>   */
> -const struct spi_device_id spi_nor_ids[] = {
> +static const struct spi_device_id spi_nor_ids[] = {
>  	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
>  	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
>  	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
> @@ -637,7 +637,6 @@ const struct spi_device_id spi_nor_ids[] = {
>  	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
>  	{ },
>  };
> -EXPORT_SYMBOL_GPL(spi_nor_ids);
>  
>  static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
>  {
> @@ -1113,7 +1112,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
>  }
>  EXPORT_SYMBOL_GPL(spi_nor_scan);
>  
> -const struct spi_device_id *spi_nor_match_id(char *name)
> +const struct spi_device_id *spi_nor_match_id(const char *name)
>  {
>  	const struct spi_device_id *id = spi_nor_ids;
>  
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index 9e6294f..5ec84cc 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -201,7 +201,6 @@ struct spi_nor {
>   */
>  int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
>  			enum read_mode mode);
> -extern const struct spi_device_id spi_nor_ids[];
>  
>  /**
>   * spi_nor_match_id() - find the spi_device_id by the name
> @@ -213,6 +212,6 @@ extern const struct spi_device_id spi_nor_ids[];
>   * Return: returns the right spi_device_id pointer on success,
>   *         and returns NULL on failure.
>   */
> -const struct spi_device_id *spi_nor_match_id(char *name);
> +const struct spi_device_id *spi_nor_match_id(const char *name);
>  
>  #endif
> 
> 

Brian

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

* Re: [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
  2014-09-30 11:36       ` Ben Hutchings
@ 2014-10-10  4:55         ` Brian Norris
  -1 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-10  4:55 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

On Tue, Sep 30, 2014 at 12:36:03PM +0100, Ben Hutchings wrote:
> On Tue, 2014-09-30 at 10:02 +0200, Rafał Miłecki wrote:
> > On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > > Move the list of chip type information to a macro in spi-nor.h, but
> > > leave the definitions of INFO and CAT25_INFO in spi-nor.
> > >
> > > In m25p80, define the INFO and CAT25_INFO macros to initialise a
> > > struct spi_device_id with the name, ignoring the remaining parameters.
> > 
> > Anyone would consider my idea proposed in 1/5 thread?
> > 
> > We could simply follow the way Linux-specific platform data works. We
> > could always use
> > compatible = "m25p80";
> > and then for some rare cases (where JEDEC fails) add something like
> > model = "at25df321a";
> > 
> > Using above way we could use a one single "compatible" in m25p80.c and
> > avoid this messy share of id_table.
> 
> You *cannot* define a DT compatible string by reference to out-of-band
> information about all the chips that has to be updated for each new
> chip.
> 
> That is not 'compatible'.

Well, for the DT case at least, what is the problem with including two
(or more) compatible strings in the board DT, but the driver only
binding against the common one ("m25p80" or something like
"spi-nor,jedec-id") unless necessary? You can still follow best DT
practices formally without always binding to the most specific string
when that doesn't buy you anything.

The true board file / platform data cases are slightly different, but in
those cases, the board file can evolve in sync with drivers, I think.

Brian

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

* [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again
@ 2014-10-10  4:55         ` Brian Norris
  0 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-10  4:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 30, 2014 at 12:36:03PM +0100, Ben Hutchings wrote:
> On Tue, 2014-09-30 at 10:02 +0200, Rafa? Mi?ecki wrote:
> > On 30 September 2014 04:15, Ben Hutchings <ben@decadent.org.uk> wrote:
> > > Move the list of chip type information to a macro in spi-nor.h, but
> > > leave the definitions of INFO and CAT25_INFO in spi-nor.
> > >
> > > In m25p80, define the INFO and CAT25_INFO macros to initialise a
> > > struct spi_device_id with the name, ignoring the remaining parameters.
> > 
> > Anyone would consider my idea proposed in 1/5 thread?
> > 
> > We could simply follow the way Linux-specific platform data works. We
> > could always use
> > compatible = "m25p80";
> > and then for some rare cases (where JEDEC fails) add something like
> > model = "at25df321a";
> > 
> > Using above way we could use a one single "compatible" in m25p80.c and
> > avoid this messy share of id_table.
> 
> You *cannot* define a DT compatible string by reference to out-of-band
> information about all the chips that has to be updated for each new
> chip.
> 
> That is not 'compatible'.

Well, for the DT case at least, what is the problem with including two
(or more) compatible strings in the board DT, but the driver only
binding against the common one ("m25p80" or something like
"spi-nor,jedec-id") unless necessary? You can still follow best DT
practices formally without always binding to the most specific string
when that doesn't buy you anything.

The true board file / platform data cases are slightly different, but in
those cases, the board file can evolve in sync with drivers, I think.

Brian

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

* Re: [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
  2014-10-10  4:51     ` Brian Norris
@ 2014-10-17 16:23       ` Brian Norris
  -1 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-17 16:23 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > its use was also removed at the same time.  Now if m25p80 is built as
> > a module it doesn't get the necessary aliases to be loaded
> > automatically.
> > 
> > A clean solution to this will involve defining the list of device
> > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > API, but this is quite a large change.
> > 
> > As a quick fix suitable for stable, copy the device IDs back into
> > m25p80.
> > 
> > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> 
> Can I get any acks/tested-by's? I'll try to test this out when I get
> back to the office, but I'd like to be able to send this in the 3.18
> cycle still.

Applied this patch to l2-mtd/master. Thanks!

Acks/tested-by's are still welcome. I plan to send this out in 3.18
(maybe for -rc2) if things look good.

Brian

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
@ 2014-10-17 16:23       ` Brian Norris
  0 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-17 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > its use was also removed at the same time.  Now if m25p80 is built as
> > a module it doesn't get the necessary aliases to be loaded
> > automatically.
> > 
> > A clean solution to this will involve defining the list of device
> > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > API, but this is quite a large change.
> > 
> > As a quick fix suitable for stable, copy the device IDs back into
> > m25p80.
> > 
> > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> 
> Can I get any acks/tested-by's? I'll try to test this out when I get
> back to the office, but I'd like to be able to send this in the 3.18
> cycle still.

Applied this patch to l2-mtd/master. Thanks!

Acks/tested-by's are still welcome. I plan to send this out in 3.18
(maybe for -rc2) if things look good.

Brian

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

* Re: [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
  2014-10-17 16:23       ` Brian Norris
@ 2014-10-17 16:35         ` Brian Norris
  -1 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-17 16:35 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

On Fri, Oct 17, 2014 at 09:23:35AM -0700, Brian Norris wrote:
> On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> > On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > > its use was also removed at the same time.  Now if m25p80 is built as
> > > a module it doesn't get the necessary aliases to be loaded
> > > automatically.
> > > 
> > > A clean solution to this will involve defining the list of device
> > > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > > API, but this is quite a large change.
> > > 
> > > As a quick fix suitable for stable, copy the device IDs back into
> > > m25p80.
> > > 
> > > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > 
> > Can I get any acks/tested-by's? I'll try to test this out when I get
> > back to the office, but I'd like to be able to send this in the 3.18
> > cycle still.
> 
> Applied this patch to l2-mtd/master. Thanks!

Scratch that; I took Rafal's rebased version found at:

  git://git.infradead.org/users/rafal/mtd.git

Brian

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
@ 2014-10-17 16:35         ` Brian Norris
  0 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-17 16:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 17, 2014 at 09:23:35AM -0700, Brian Norris wrote:
> On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> > On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > > its use was also removed at the same time.  Now if m25p80 is built as
> > > a module it doesn't get the necessary aliases to be loaded
> > > automatically.
> > > 
> > > A clean solution to this will involve defining the list of device
> > > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > > API, but this is quite a large change.
> > > 
> > > As a quick fix suitable for stable, copy the device IDs back into
> > > m25p80.
> > > 
> > > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > 
> > Can I get any acks/tested-by's? I'll try to test this out when I get
> > back to the office, but I'd like to be able to send this in the 3.18
> > cycle still.
> 
> Applied this patch to l2-mtd/master. Thanks!

Scratch that; I took Rafal's rebased version found at:

  git://git.infradead.org/users/rafal/mtd.git

Brian

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

* Re: [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
  2014-10-17 16:35         ` Brian Norris
@ 2014-10-17 16:41           ` Ben Hutchings
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-10-17 16:41 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

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

On Fri, 2014-10-17 at 09:35 -0700, Brian Norris wrote:
> On Fri, Oct 17, 2014 at 09:23:35AM -0700, Brian Norris wrote:
> > On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> > > On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > > > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > > > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > > > its use was also removed at the same time.  Now if m25p80 is built as
> > > > a module it doesn't get the necessary aliases to be loaded
> > > > automatically.
> > > > 
> > > > A clean solution to this will involve defining the list of device
> > > > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > > > API, but this is quite a large change.
> > > > 
> > > > As a quick fix suitable for stable, copy the device IDs back into
> > > > m25p80.
> > > > 
> > > > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > > > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > > > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > > 
> > > Can I get any acks/tested-by's? I'll try to test this out when I get
> > > back to the office, but I'd like to be able to send this in the 3.18
> > > cycle still.
> > 
> > Applied this patch to l2-mtd/master. Thanks!
> 
> Scratch that; I took Rafal's rebased version found at:
> 
>   git://git.infradead.org/users/rafal/mtd.git

Thanks!

Ben.

-- 
Ben Hutchings
Life is what happens to you while you're busy making other plans.
                                                               - John Lennon

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

* [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80
@ 2014-10-17 16:41           ` Ben Hutchings
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Hutchings @ 2014-10-17 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2014-10-17 at 09:35 -0700, Brian Norris wrote:
> On Fri, Oct 17, 2014 at 09:23:35AM -0700, Brian Norris wrote:
> > On Thu, Oct 09, 2014 at 09:51:26PM -0700, Brian Norris wrote:
> > > On Tue, Sep 30, 2014 at 03:14:55AM +0100, Ben Hutchings wrote:
> > > > m25p80's device ID table is now spi_nor_ids, defined in spi-nor.  The
> > > > MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but
> > > > its use was also removed at the same time.  Now if m25p80 is built as
> > > > a module it doesn't get the necessary aliases to be loaded
> > > > automatically.
> > > > 
> > > > A clean solution to this will involve defining the list of device
> > > > IDs in spi-nor.h and removing struct spi_device_id from the spi-nor
> > > > API, but this is quite a large change.
> > > > 
> > > > As a quick fix suitable for stable, copy the device IDs back into
> > > > m25p80.
> > > > 
> > > > Fixes: 03e296f613af ("mtd: m25p80: use the SPI nor framework")
> > > > Cc: stable <stable@vger.kernel.org> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80
> > > > Cc: stable <stable@vger.kernel.org> # 3.16.x
> > > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > > 
> > > Can I get any acks/tested-by's? I'll try to test this out when I get
> > > back to the office, but I'd like to be able to send this in the 3.18
> > > cycle still.
> > 
> > Applied this patch to l2-mtd/master. Thanks!
> 
> Scratch that; I took Rafal's rebased version found at:
> 
>   git://git.infradead.org/users/rafal/mtd.git

Thanks!

Ben.

-- 
Ben Hutchings
Life is what happens to you while you're busy making other plans.
                                                               - John Lennon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141017/6fe4715f/attachment.sig>

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

* Re: [PATCH v2 2/5] spi-nor: Remove spi_nor::read_id operation
  2014-09-30  2:15   ` Ben Hutchings
@ 2014-10-22  8:30     ` Brian Norris
  -1 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-22  8:30 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andrew Lunn, Jason Cooper, Rafał Miłecki,
	MTD Maling List, Ian Campbell, Geert Uytterhoeven, Huang Shijie,
	linux-arm-kernel, debian-kernel

On Tue, Sep 30, 2014 at 03:15:04AM +0100, Ben Hutchings wrote:
> There is currently no useful way to override the default
> implementation of this operation.  The returned struct spi_device_id
> must have a pointer to struct flash_info in its private data, but this
> structure is defined inside spi-nor.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Applied this one to l2-mtd.git. Thanks!

Brian

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

* [PATCH v2 2/5] spi-nor: Remove spi_nor::read_id operation
@ 2014-10-22  8:30     ` Brian Norris
  0 siblings, 0 replies; 34+ messages in thread
From: Brian Norris @ 2014-10-22  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 30, 2014 at 03:15:04AM +0100, Ben Hutchings wrote:
> There is currently no useful way to override the default
> implementation of this operation.  The returned struct spi_device_id
> must have a pointer to struct flash_info in its private data, but this
> structure is defined inside spi-nor.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Applied this one to l2-mtd.git. Thanks!

Brian

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

end of thread, other threads:[~2014-10-22  8:30 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30  2:13 [PATCH v2 0/5] m25p80,spi-nor: Fix module aliases for m25p80; clean up chip identification Ben Hutchings
2014-09-30  2:13 ` Ben Hutchings
2014-09-30  2:14 ` [PATCH v2 1/5] m25p80,spi-nor: Fix module aliases for m25p80 Ben Hutchings
2014-09-30  2:14   ` Ben Hutchings
2014-10-10  4:51   ` Brian Norris
2014-10-10  4:51     ` Brian Norris
2014-10-17 16:23     ` Brian Norris
2014-10-17 16:23       ` Brian Norris
2014-10-17 16:35       ` Brian Norris
2014-10-17 16:35         ` Brian Norris
2014-10-17 16:41         ` Ben Hutchings
2014-10-17 16:41           ` Ben Hutchings
2014-09-30  2:15 ` [PATCH v2 2/5] spi-nor: Remove spi_nor::read_id operation Ben Hutchings
2014-09-30  2:15   ` Ben Hutchings
2014-10-22  8:30   ` Brian Norris
2014-10-22  8:30     ` Brian Norris
2014-09-30  2:15 ` [PATCH v2 3/5] spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id Ben Hutchings
2014-09-30  2:15   ` Ben Hutchings
2014-09-30  5:14   ` Rafał Miłecki
2014-09-30  5:14     ` Rafał Miłecki
2014-09-30 11:38     ` Ben Hutchings
2014-09-30 11:38       ` Ben Hutchings
2014-09-30  2:15 ` [PATCH v2 4/5] spi-nor: Replace struct spi_device_id with struct flash_info Ben Hutchings
2014-09-30  2:15   ` Ben Hutchings
2014-09-30  2:15 ` [PATCH v2 5/5] m25p80,spi-nor: Share the list of supported chip type names again Ben Hutchings
2014-09-30  2:15   ` Ben Hutchings
2014-09-30  7:22   ` Geert Uytterhoeven
2014-09-30  7:22     ` Geert Uytterhoeven
2014-09-30  8:02   ` Rafał Miłecki
2014-09-30  8:02     ` Rafał Miłecki
2014-09-30 11:36     ` Ben Hutchings
2014-09-30 11:36       ` Ben Hutchings
2014-10-10  4:55       ` Brian Norris
2014-10-10  4:55         ` 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.