450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch 1019 B

123456789101112131415161718192021222324252627282930313233343536
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Fri, 23 Feb 2018 17:12:16 +0100
  3. Subject: [PATCH] mtd: m25p80: allow fallback from spi_flash_read to regular
  4. SPI transfer
  5. Some flash controllers, e.g. on the ath79 platform can support a fast
  6. flash read via memory mapping, but only if the flash chip is in
  7. 3-byte address mode.
  8. Since spi_flash_read_supported does not have access to the same data as
  9. spi_flash_read, the driver can't detect an unsupported call until m25p80
  10. has decided to use spi_flash_read.
  11. Allow the driver to indicate a fallback to a regular SPI transfer by
  12. returning -EOPNOTSUPP
  13. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  14. ---
  15. --- a/drivers/mtd/devices/m25p80.c
  16. +++ b/drivers/mtd/devices/m25p80.c
  17. @@ -170,9 +170,11 @@ static ssize_t m25p80_read(struct spi_no
  18. msg.data_nbits = data_nbits;
  19. ret = spi_flash_read(spi, &msg);
  20. - if (ret < 0)
  21. - return ret;
  22. - return msg.retlen;
  23. + if (ret != -EOPNOTSUPP) {
  24. + if (ret < 0)
  25. + return ret;
  26. + return msg.retlen;
  27. + }
  28. }
  29. spi_message_init(&m);