aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2014-09-28 16:36:54 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-09-28 18:27:03 -0400
commit32f1b7c8352fd33d41bcec3cfb054ccdcfd40a42 (patch)
tree2d00a33a1d12b52cc13d4be89e4072973d27e771 /drivers/mtd/devices
parent57cf26c1b28572976c57f6dec9818be38bf37cbb (diff)
mtd: move support for struct flash_platform_data into m25p80
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 <zajec5@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/m25p80.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index ed7e0a1bed3c..dcda6287228d 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -193,11 +193,14 @@ static int m25p_probe(struct spi_device *spi)
193{ 193{
194 struct mtd_part_parser_data ppdata; 194 struct mtd_part_parser_data ppdata;
195 struct flash_platform_data *data; 195 struct flash_platform_data *data;
196 const struct spi_device_id *id = NULL;
196 struct m25p *flash; 197 struct m25p *flash;
197 struct spi_nor *nor; 198 struct spi_nor *nor;
198 enum read_mode mode = SPI_NOR_NORMAL; 199 enum read_mode mode = SPI_NOR_NORMAL;
199 int ret; 200 int ret;
200 201
202 data = dev_get_platdata(&spi->dev);
203
201 flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL); 204 flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
202 if (!flash) 205 if (!flash)
203 return -ENOMEM; 206 return -ENOMEM;
@@ -223,11 +226,26 @@ static int m25p_probe(struct spi_device *spi)
223 mode = SPI_NOR_QUAD; 226 mode = SPI_NOR_QUAD;
224 else if (spi->mode & SPI_RX_DUAL) 227 else if (spi->mode & SPI_RX_DUAL)
225 mode = SPI_NOR_DUAL; 228 mode = SPI_NOR_DUAL;
226 ret = spi_nor_scan(nor, spi_get_device_id(spi), mode); 229
230 if (data && data->name)
231 flash->mtd.name = data->name;
232
233 /* For some (historical?) reason many platforms provide two different
234 * names in flash_platform_data: "name" and "type". Quite often name is
235 * set to "m25p80" and then "type" provides a real chip name.
236 * If that's the case, respect "type" and ignore a "name".
237 */
238 if (data && data->type)
239 id = spi_nor_match_id(data->type);
240
241 /* If we didn't get name from platform, simply use "modalias". */
242 if (!id)
243 id = spi_get_device_id(spi);
244
245 ret = spi_nor_scan(nor, id, mode);
227 if (ret) 246 if (ret)
228 return ret; 247 return ret;
229 248
230 data = dev_get_platdata(&spi->dev);
231 ppdata.of_node = spi->dev.of_node; 249 ppdata.of_node = spi->dev.of_node;
232 250
233 return mtd_device_parse_register(&flash->mtd, NULL, &ppdata, 251 return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,