000-4.5-01-mtd-add-get-set-of_node-flash_node-helpers.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. From 28b8b26b308e656edfa9467867d5f79212da2ec3 Mon Sep 17 00:00:00 2001
  2. From: Brian Norris <computersforpeace@gmail.com>
  3. Date: Fri, 30 Oct 2015 20:33:20 -0700
  4. Subject: [PATCH] mtd: add get/set of_node/flash_node helpers
  5. We are going to begin using the mtd->dev.of_node field for MTD device
  6. nodes, so let's add helpers for it. Also, we'll be making some
  7. conversions on spi_nor (and nand_chip eventually) too, so get that ready
  8. with their own helpers.
  9. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  10. Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  11. ---
  12. include/linux/mtd/mtd.h | 11 +++++++++++
  13. include/linux/mtd/nand.h | 11 +++++++++++
  14. include/linux/mtd/spi-nor.h | 11 +++++++++++
  15. 3 files changed, 33 insertions(+)
  16. --- a/include/linux/mtd/mtd.h
  17. +++ b/include/linux/mtd/mtd.h
  18. @@ -258,6 +258,17 @@ struct mtd_info {
  19. int usecount;
  20. };
  21. +static inline void mtd_set_of_node(struct mtd_info *mtd,
  22. + struct device_node *np)
  23. +{
  24. + mtd->dev.of_node = np;
  25. +}
  26. +
  27. +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
  28. +{
  29. + return mtd->dev.of_node;
  30. +}
  31. +
  32. int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
  33. int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
  34. void **virt, resource_size_t *phys);
  35. --- a/include/linux/mtd/nand.h
  36. +++ b/include/linux/mtd/nand.h
  37. @@ -719,6 +719,17 @@ struct nand_chip {
  38. void *priv;
  39. };
  40. +static inline void nand_set_flash_node(struct nand_chip *chip,
  41. + struct device_node *np)
  42. +{
  43. + chip->flash_node = np;
  44. +}
  45. +
  46. +static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
  47. +{
  48. + return chip->flash_node;
  49. +}
  50. +
  51. /*
  52. * NAND Flash Manufacturer ID Codes
  53. */
  54. --- a/include/linux/mtd/spi-nor.h
  55. +++ b/include/linux/mtd/spi-nor.h
  56. @@ -184,6 +184,17 @@ struct spi_nor {
  57. void *priv;
  58. };
  59. +static inline void spi_nor_set_flash_node(struct spi_nor *nor,
  60. + struct device_node *np)
  61. +{
  62. + nor->flash_node = np;
  63. +}
  64. +
  65. +static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
  66. +{
  67. + return nor->flash_node;
  68. +}
  69. +
  70. /**
  71. * spi_nor_scan() - scan the SPI NOR
  72. * @nor: the spi_nor structure