m25p80,spi-nor: Fix module aliases for m25p80; clean up chip identification
Subsystems (2)
v2 cover m25p80,spi-nor: Fix module aliases for m25p80; clean up chip identification
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(-)
Signature · 9 lines
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>
PATCH v2 1/5 m25p80,spi-nor: Fix module aliases for m25p80
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.
--- 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(-)
drivers/mtd/devices/m25p80.c +56 -3
@@ -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,
drivers/mtd/spi-nor/spi-nor.c +2 -3
@@ -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;
include/linux/mtd/spi-nor.h +1 -2
@@ -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
Signature · 9 lines
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>
PATCH v2 1/5 m25p80,spi-nor: Fix module aliases for m25p80
Quoted 10 lines · Ben Hutchings
m25p80's device ID table is now
spi_nor_ids, defined in spi-nor. TheMODULE_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.hand removing structspi_device_idfrom the spi-nor API, but this is quite a large change.
Quoted 7 lines
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 <[email protected]> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80Cc stable <[email protected]> # 3.16.xSigned-off-by Ben Hutchings <[email protected]>
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...
Quoted 133 lines
--- 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(-)drivers/mtd/devices/m25p80.c +56
-3@@ -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,drivers/mtd/spi-nor/spi-nor.c +2
-3@@ -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;include/linux/mtd/spi-nor.h +0
-1@@ -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
include/linux/mtd/spi-nor.h extern const struct spi_device_id spi_nor_ids[]; · line 217
Quoted 7 lines
include/linux/mtd/spi-nor.h +1
-1@@ -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
Brian Norris
AppliedPATCH v2 1/5 m25p80,spi-nor: Fix module aliases for m25p80
Quoted 14 lines · Brian Norris
Quoted 13 lines · Ben Hutchings
m25p80's device ID table is now
spi_nor_ids, defined in spi-nor. TheMODULE_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.hand removing structspi_device_idfrom 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.
Quoted 8 lines
Quoted 4 lines
Fixes 03e296f613af ("mtd: m25p80: use the SPI nor framework")Cc stable <[email protected]> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80Cc stable <[email protected]> # 3.16.xSigned-off-by Ben Hutchings <[email protected]>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
PATCH v2 1/5 m25p80,spi-nor: Fix module aliases for m25p80
Quoted 20 lines · Brian Norris
Quoted 19 lines · Brian Norris
Quoted 17 lines · Ben Hutchings
m25p80's device ID table is now
spi_nor_ids, defined in spi-nor. TheMODULE_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.hand removing structspi_device_idfrom 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 <[email protected]> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80Cc stable <[email protected]> # 3.16.xSigned-off-by Ben Hutchings <[email protected]>
Quoted 5 lines
Quoted 3 lines
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
PATCH v2 1/5 m25p80,spi-nor: Fix module aliases for m25p80
Quoted 25 lines · Brian Norris
Quoted 24 lines · Brian Norris
Quoted 22 lines · Brian Norris
Quoted 10 lines · Ben Hutchings
m25p80's device ID table is now
spi_nor_ids, defined in spi-nor. TheMODULE_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.hand removing structspi_device_idfrom the spi-nor API, but this is quite a large change.Quoted 7 lines
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 <[email protected]> # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80Cc stable <[email protected]> # 3.16.xSigned-off-by Ben Hutchings <[email protected]>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.
Quoted 5 lines
Quoted 1 line
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.
Signature · 10 lines
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>PATCH v2 2/5 spi-nor: Remove spi_nor::read_id operation
In reply to Ben HutchingsThere 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.
--- drivers/mtd/spi-nor/spi-nor.c | 4 +--- include/linux/mtd/spi-nor.h | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +1 -3
@@ -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) {
include/linux/mtd/spi-nor.h +0 -3
@@ -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,
Signature · 9 lines
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>
Brian Norris
AppliedPATCH v2 2/5 spi-nor: Remove spi_nor::read_id operation
Quoted 6 lines · Ben Hutchings
There is currently no useful way to override the default implementation of this operation. The returned struct
spi_device_idmust have a pointer to structflash_infoin its private data, but this structure is defined inside spi-nor.Signed-off-by Ben Hutchings <[email protected]>
Applied this one to l2-mtd.git. Thanks!
Brian
PATCH v2 3/5 spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
In reply to Ben HutchingsDrivers 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.
--- 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(-)
drivers/mtd/devices/m25p80.c +5 -8
@@ -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;
drivers/mtd/spi-nor/fsl-quadspi.c +1 -6
@@ -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;
drivers/mtd/spi-nor/spi-nor.c +9 -4
@@ -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 <[email protected]>" );
include/linux/mtd/spi-nor.h +2 -18
@@ -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
Signature · 9 lines
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>
PATCH v2 3/5 spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
Quoted 5 lines · Ben Hutchings
drivers/mtd/devices/m25p80.c +0
-1@@ -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);
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 243
Quoted 10 lines
drivers/mtd/devices/m25p80.c +3
-5+ 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/
PATCH v2 3/5 spi-nor: Make spi_nor_scan() take a chip type name, not an spi_device_id
Quoted 8 lines · Rafa? Mi?ecki
Quoted 7 lines · Ben Hutchings
drivers/mtd/devices/m25p80.c +1
-1@@ -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;
Quoted 12 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 243
Quoted 8 lines
drivers/mtd/devices/m25p80.c +2
-5/* 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 thespi->modalias) and then... getting that name?
Ah, I didn't realise what spi_get_device_id() was doing.
Quoted 3 lines
Did it hurt to use the patch I've sent
mtd: m25p80: get rid ofspi_get_device_id
https://patchwork.ozlabs.org/patch/394328/
It would make sense to insert that before this.
Ben.
Signature · 9 lines
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>
PATCH v2 4/5 spi-nor: Replace struct spi_device_id with struct flash_info
In reply to Ben Hutchingsspi-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.
--- drivers/mtd/devices/m25p80.c | 2 +- drivers/mtd/spi-nor/spi-nor.c | 340 +++++++++++++++++++++--------------------- 2 files changed, 170 insertions(+), 172 deletions(-)
drivers/mtd/devices/m25p80.c +1 -1
@@ -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. */
drivers/mtd/spi-nor/spi-nor.c +169 -171
456 lines not on this page · raw message
Signature · 9 lines
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>
PATCH v2 5/5 m25p80,spi-nor: Share the list of supported chip type names again
In reply to Ben HutchingsMove 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.
--- 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(-)
drivers/mtd/devices/m25p80.c +3 -44
@@ -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);
drivers/mtd/spi-nor/spi-nor.c +1 -164
172 lines not on this page · raw message
include/linux/mtd/spi-nor.h +173 -0
177 lines not on this page · raw message
Signature · 9 lines
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>
PATCH v2 5/5 m25p80,spi-nor: Share the list of supported chip type names again
Hi Ben,
Quoted 7 lines · Ben Hutchings
Move the list of chip type information to a macro in
spi-nor.h, but leave the definitions of INFO andCAT25_INFOin spi-nor.In m25p80, define the INFO and
CAT25_INFOmacros to initialise a structspi_device_idwith the name, ignoring the remaining parameters.Signed-off-by Ben Hutchings <[email protected]>
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
PATCH v2 5/5 m25p80,spi-nor: Share the list of supported chip type names again
In reply to Ben HutchingsQuoted 5 lines · Ben Hutchings
Move the list of chip type information to a macro in
spi-nor.h, but leave the definitions of INFO andCAT25_INFOin spi-nor.In m25p80, define the INFO and
CAT25_INFOmacros to initialise a structspi_device_idwith 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.
PATCH v2 5/5 m25p80,spi-nor: Share the list of supported chip type names again
Quoted 9 lines · Rafa? Mi?ecki
Quoted 5 lines · Ben Hutchings
Move the list of chip type information to a macro in
spi-nor.h, but leave the definitions of INFO andCAT25_INFOin spi-nor.In m25p80, define the INFO and
CAT25_INFOmacros to initialise a structspi_device_idwith the name, ignoring the remaining parameters.Anyone would consider my idea proposed in 1/5 thread?
Quoted 8 lines
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.cand avoid this messy share ofid_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.
Signature · 9 lines
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>
PATCH v2 5/5 m25p80,spi-nor: Share the list of supported chip type names again
Quoted 16 lines · Ben Hutchings
Quoted 15 lines · Rafa? Mi?ecki
Quoted 5 lines · Ben Hutchings
Move the list of chip type information to a macro in
spi-nor.h, but leave the definitions of INFO andCAT25_INFOin spi-nor.In m25p80, define the INFO and
CAT25_INFOmacros to initialise a structspi_device_idwith 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";
Quoted 8 lines
Quoted 2 lines
Using above way we could use a one single "compatible" in
m25p80.cand avoid this messy share ofid_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