1
0

044-backport-m25p80-jedec-probe.patch 1004 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --- a/drivers/mtd/devices/m25p80.c
  2. +++ b/drivers/mtd/devices/m25p80.c
  3. @@ -310,11 +310,21 @@ static const struct spi_device_id m25p_i
  4. };
  5. MODULE_DEVICE_TABLE(spi, m25p_ids);
  6. +static const struct of_device_id m25p_of_table[] = {
  7. + /*
  8. + * Generic compatibility for SPI NOR that can be identified by the
  9. + * JEDEC READ ID opcode (0x9F). Use this, if possible.
  10. + */
  11. + { .compatible = "jedec,spi-nor" },
  12. + {}
  13. +};
  14. +MODULE_DEVICE_TABLE(of, m25p_of_table);
  15. static struct spi_driver m25p80_driver = {
  16. .driver = {
  17. .name = "m25p80",
  18. .owner = THIS_MODULE,
  19. + .of_match_table = m25p_of_table,
  20. },
  21. .id_table = m25p_ids,
  22. .probe = m25p_probe,
  23. --- a/drivers/mtd/spi-nor/spi-nor.c
  24. +++ b/drivers/mtd/spi-nor/spi-nor.c
  25. @@ -927,8 +927,11 @@ int spi_nor_scan(struct spi_nor *nor, co
  26. if (ret)
  27. return ret;
  28. - id = spi_nor_match_id(name);
  29. + if (name)
  30. + id = spi_nor_match_id(name);
  31. if (!id)
  32. + id = nor->read_id(nor);
  33. + if (IS_ERR_OR_NULL(id))
  34. return -ENOENT;
  35. info = (void *)id->driver_data;