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>
This commit is contained in:

committed by
Brian Norris

parent
57cf26c1b2
commit
32f1b7c835
@@ -193,11 +193,14 @@ 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;
|
||||
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 *spi)
|
||||
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,
|
||||
|
Reference in New Issue
Block a user