From 349f6d1c150d7db214c3148111b7139318f97b92 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 31 Oct 2014 01:46:13 +0000 Subject: [PATCH] m25p80: Fix module device ID table svn path=/dists/sid/linux/; revision=21993 --- debian/changelog | 1 + ...-m25p80-get-rid-of-spi_get_device_id.patch | 46 +++++ ...pi-nor-Fix-module-aliases-for-m25p80.patch | 125 ++++++++++++++ ...-for-struct-flash_platform_data-into.patch | 119 +++++++++++++ ...-spi_nor_scan-take-a-chip-type-name-.patch | 162 ++++++++++++++++++ debian/patches/series | 4 + 6 files changed, 457 insertions(+) create mode 100644 debian/patches/bugfix/all/mtd-m25p80-get-rid-of-spi_get_device_id.patch create mode 100644 debian/patches/bugfix/all/mtd-m25p80-spi-nor-Fix-module-aliases-for-m25p80.patch create mode 100644 debian/patches/bugfix/all/mtd-move-support-for-struct-flash_platform_data-into.patch create mode 100644 debian/patches/bugfix/all/mtd-spi-nor-make-spi_nor_scan-take-a-chip-type-name-.patch diff --git a/debian/changelog b/debian/changelog index a3a15ec1f..3b09bd59e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -122,6 +122,7 @@ linux (3.16.7-1) UNRELEASED; urgency=medium * vfs,fuse: Change iov_iter_get_pages() to take both maxsize and maxpages parameters (Closes: #764285) * lockd: Try to reconnect if statd has moved (Closes: #767219) + * m25p80: Fix module device ID table [ Mauricio Faria de Oliveira ] * [ppc64el] Disable CONFIG_CMDLINE{,_BOOL} usage for setting consoles diff --git a/debian/patches/bugfix/all/mtd-m25p80-get-rid-of-spi_get_device_id.patch b/debian/patches/bugfix/all/mtd-m25p80-get-rid-of-spi_get_device_id.patch new file mode 100644 index 000000000..e308907ed --- /dev/null +++ b/debian/patches/bugfix/all/mtd-m25p80-get-rid-of-spi_get_device_id.patch @@ -0,0 +1,46 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Mon, 29 Sep 2014 11:47:53 +0200 +Subject: [2/4] mtd: m25p80: get rid of spi_get_device_id +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Origin: http://git.infradead.org/l2-mtd.git/commit/90e55b3812a1245bb674afcc4410ddba7db402f6 + +This simplifies the way we use spi_nor framework and will allow us to +drop spi_nor_match_id. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Brian Norris +--- + drivers/mtd/devices/m25p80.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c +index dcda628..822209d 100644 +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -197,6 +197,7 @@ static int m25p_probe(struct spi_device *spi) + struct m25p *flash; + struct spi_nor *nor; + enum read_mode mode = SPI_NOR_NORMAL; ++ char *flash_name = NULL; + int ret; + + data = dev_get_platdata(&spi->dev); +@@ -236,12 +237,11 @@ 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); +- +- /* If we didn't get name from platform, simply use "modalias". */ +- if (!id) +- id = spi_get_device_id(spi); ++ flash_name = data->type; ++ else ++ flash_name = spi->modalias; + ++ id = spi_nor_match_id(flash_name); + ret = spi_nor_scan(nor, id, mode); + if (ret) + return ret; diff --git a/debian/patches/bugfix/all/mtd-m25p80-spi-nor-Fix-module-aliases-for-m25p80.patch b/debian/patches/bugfix/all/mtd-m25p80-spi-nor-Fix-module-aliases-for-m25p80.patch new file mode 100644 index 000000000..faa9fdf44 --- /dev/null +++ b/debian/patches/bugfix/all/mtd-m25p80-spi-nor-Fix-module-aliases-for-m25p80.patch @@ -0,0 +1,125 @@ +From: Ben Hutchings +Date: Tue, 30 Sep 2014 03:14:55 +0100 +Subject: [4/4] mtd: m25p80,spi-nor: Fix module aliases for m25p80 +Origin: http://git.infradead.org/l2-mtd.git/commit/a5b7616c55e188fe3d6ef686bef402d4703ecb62 + +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: # 3.16.x: 32f1b7c8352f: mtd: move support for struct flash_platform_data into m25p80 +Cc: # 3.16.x: 90e55b3812a1: mtd: m25p80: get rid of spi_get_device_id +Cc: # 3.16.x: 70f3ce0510af: mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id +Cc: # 3.16.x +Signed-off-by: Ben Hutchings +Signed-off-by: Brian Norris +--- + drivers/mtd/devices/m25p80.c | 52 ++++++++++++++++++++++++++++++++++++++++++- + drivers/mtd/spi-nor/spi-nor.c | 3 +-- + include/linux/mtd/spi-nor.h | 1 - + 3 files changed, 52 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -261,12 +261,62 @@ static int m25p_remove(struct spi_device + } + + ++/* ++ * 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, + +--- a/drivers/mtd/spi-nor/spi-nor.c ++++ b/drivers/mtd/spi-nor/spi-nor.c +@@ -429,7 +429,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) }, +@@ -590,7 +590,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) + { +--- a/include/linux/mtd/spi-nor.h ++++ b/include/linux/mtd/spi-nor.h +@@ -195,6 +195,5 @@ struct spi_nor { + * Return: 0 for success, others for failure. + */ + int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode); +-extern const struct spi_device_id spi_nor_ids[]; + + #endif diff --git a/debian/patches/bugfix/all/mtd-move-support-for-struct-flash_platform_data-into.patch b/debian/patches/bugfix/all/mtd-move-support-for-struct-flash_platform_data-into.patch new file mode 100644 index 000000000..4d1c73fcd --- /dev/null +++ b/debian/patches/bugfix/all/mtd-move-support-for-struct-flash_platform_data-into.patch @@ -0,0 +1,119 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Sun, 28 Sep 2014 22:36:54 +0200 +Subject: [1/4] mtd: move support for struct flash_platform_data into m25p80 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Origin: http://git.infradead.org/l2-mtd.git/commit/32f1b7c8352fd33d41bcec3cfb054ccdcfd40a42 + +This "type" seems to be an extra hint for m25p80 about the flash. Some +archs register flash_platform_data with "name" set to "m25p80" and then +with a real flash name set in "type". It seems to be a trick specific +to the m25p80 so let's move it out of spi-nor. +Btw switch to the spi_nor_match_id instead of iterating spi_nor_ids. + +Signed-off-by: Rafał Miłecki +Signed-off-by: Brian Norris +--- + drivers/mtd/devices/m25p80.c | 22 ++++++++++++++++++++-- + drivers/mtd/spi-nor/spi-nor.c | 28 +--------------------------- + 2 files changed, 21 insertions(+), 29 deletions(-) + +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -193,11 +193,14 @@ static int m25p_probe(struct spi_device + { + struct mtd_part_parser_data ppdata; + struct flash_platform_data *data; ++ const struct spi_device_id *id = NULL; + struct m25p *flash; + struct spi_nor *nor; + enum read_mode mode = SPI_NOR_NORMAL; + int ret; + ++ data = dev_get_platdata(&spi->dev); ++ + flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL); + if (!flash) + return -ENOMEM; +@@ -223,11 +226,26 @@ static int m25p_probe(struct spi_device + mode = SPI_NOR_QUAD; + else if (spi->mode & SPI_RX_DUAL) + mode = SPI_NOR_DUAL; +- ret = spi_nor_scan(nor, spi_get_device_id(spi), mode); ++ ++ if (data && data->name) ++ flash->mtd.name = data->name; ++ ++ /* For some (historical?) reason many platforms provide two different ++ * names in flash_platform_data: "name" and "type". Quite often name is ++ * set to "m25p80" and then "type" provides a real chip name. ++ * If that's the case, respect "type" and ignore a "name". ++ */ ++ if (data && data->type) ++ 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); ++ ++ ret = spi_nor_scan(nor, id, mode); + if (ret) + return ret; + +- data = dev_get_platdata(&spi->dev); + ppdata.of_node = spi->dev.of_node; + + return mtd_device_parse_register(&flash->mtd, NULL, &ppdata, +--- a/drivers/mtd/spi-nor/spi-nor.c ++++ b/drivers/mtd/spi-nor/spi-nor.c +@@ -871,7 +871,6 @@ int spi_nor_scan(struct spi_nor *nor, co + enum read_mode mode) + { + struct flash_info *info; +- struct flash_platform_data *data; + struct device *dev = nor->dev; + struct mtd_info *mtd = nor->mtd; + struct device_node *np = dev->of_node; +@@ -882,28 +881,6 @@ int spi_nor_scan(struct spi_nor *nor, co + if (ret) + return ret; + +- /* Platform data helps sort out which chip type we have, as +- * well as how this board partitions it. If we don't have +- * a chip ID, try the JEDEC id commands; they'll work for most +- * newer chips, even if we don't recognize the particular chip. +- */ +- data = dev_get_platdata(dev); +- if (data && data->type) { +- const struct spi_device_id *plat_id; +- +- for (i = 0; i < ARRAY_SIZE(spi_nor_ids) - 1; i++) { +- plat_id = &spi_nor_ids[i]; +- if (strcmp(data->type, plat_id->name)) +- continue; +- break; +- } +- +- if (i < ARRAY_SIZE(spi_nor_ids) - 1) +- id = plat_id; +- else +- dev_warn(dev, "unrecognized id %s\n", data->type); +- } +- + info = (void *)id->driver_data; + + if (info->jedec_id) { +@@ -941,11 +918,8 @@ int spi_nor_scan(struct spi_nor *nor, co + write_sr(nor, 0); + } + +- if (data && data->name) +- mtd->name = data->name; +- else ++ if (!mtd->name) + mtd->name = dev_name(dev); +- + mtd->type = MTD_NORFLASH; + mtd->writesize = 1; + mtd->flags = MTD_CAP_NORFLASH; diff --git a/debian/patches/bugfix/all/mtd-spi-nor-make-spi_nor_scan-take-a-chip-type-name-.patch b/debian/patches/bugfix/all/mtd-spi-nor-make-spi_nor_scan-take-a-chip-type-name-.patch new file mode 100644 index 000000000..9e580e756 --- /dev/null +++ b/debian/patches/bugfix/all/mtd-spi-nor-make-spi_nor_scan-take-a-chip-type-name-.patch @@ -0,0 +1,162 @@ +From: Ben Hutchings +Date: Mon, 29 Sep 2014 11:47:54 +0200 +Subject: [3/4] mtd: spi-nor: make spi_nor_scan() take a chip type name, not + spi_device_id +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Origin: http://git.infradead.org/l2-mtd.git/commit/70f3ce0510afdad7cbaf27ab7ab961377205c782 + +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 +Signed-off-by: Rafał Miłecki +Signed-off-by: Brian Norris +--- + drivers/mtd/devices/m25p80.c | 4 +--- + 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, 14 insertions(+), 30 deletions(-) + +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -193,7 +193,6 @@ static int m25p_probe(struct spi_device + { + struct mtd_part_parser_data ppdata; + struct flash_platform_data *data; +- const struct spi_device_id *id = NULL; + struct m25p *flash; + struct spi_nor *nor; + enum read_mode mode = SPI_NOR_NORMAL; +@@ -241,8 +240,7 @@ static int m25p_probe(struct spi_device + else + flash_name = spi->modalias; + +- id = spi_nor_match_id(flash_name); +- ret = spi_nor_scan(nor, id, mode); ++ ret = spi_nor_scan(nor, flash_name, mode); + if (ret) + return ret; + +--- 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 platfor + + /* 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 platfor + 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 platfor + /* 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; + +--- 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. +@@ -867,9 +869,9 @@ static int spi_nor_check(struct spi_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; +@@ -881,6 +883,10 @@ int spi_nor_scan(struct spi_nor *nor, co + if (ret) + return ret; + ++ id = spi_nor_match_id(name); ++ if (!id) ++ return -ENOENT; ++ + info = (void *)id->driver_data; + + if (info->jedec_id) { +@@ -1062,7 +1068,7 @@ int spi_nor_scan(struct spi_nor *nor, co + } + EXPORT_SYMBOL_GPL(spi_nor_scan); + +-const struct spi_device_id *spi_nor_match_id(char *name) ++static const struct spi_device_id *spi_nor_match_id(const char *name) + { + const struct spi_device_id *id = spi_nor_ids; + +@@ -1073,7 +1079,6 @@ const struct spi_device_id *spi_nor_matc + } + return NULL; + } +-EXPORT_SYMBOL_GPL(spi_nor_match_id); + + MODULE_LICENSE("GPL"); + MODULE_AUTHOR("Huang Shijie "); +--- a/include/linux/mtd/spi-nor.h ++++ b/include/linux/mtd/spi-nor.h +@@ -183,32 +183,18 @@ 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. ++ * The chip type name can be provided through the @name parameter. + * + * 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); ++int spi_nor_scan(struct spi_nor *nor, const char *name, 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 +- * @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(char *name); +- + #endif diff --git a/debian/patches/series b/debian/patches/series index f78ec2a32..bba21026f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -397,3 +397,7 @@ bugfix/all/switch-iov_iter_get_pages-to-passing-maximal-number-.patch bugfix/all/fuse-honour-max_read-and-max_write-in-direct_io-mode.patch bugfix/all/SUNRPC-Don-t-wake-tasks-during-connection-abort.patch bugfix/all/lockd-Try-to-reconnect-if-statd-has-moved.patch +bugfix/all/mtd-move-support-for-struct-flash_platform_data-into.patch +bugfix/all/mtd-m25p80-get-rid-of-spi_get_device_id.patch +bugfix/all/mtd-spi-nor-make-spi_nor_scan-take-a-chip-type-name-.patch +bugfix/all/mtd-m25p80-spi-nor-Fix-module-aliases-for-m25p80.patch