0006-mtd-add-get-set-of_node-flash_node-helpers.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From cb0416f4be60979f3fd3e99a9baff17ac9b8381f 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 06/33] 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. diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
  17. index f17fa75..cc84923 100644
  18. --- a/include/linux/mtd/mtd.h
  19. +++ b/include/linux/mtd/mtd.h
  20. @@ -254,6 +254,17 @@ struct mtd_info {
  21. int usecount;
  22. };
  23. +static inline void mtd_set_of_node(struct mtd_info *mtd,
  24. + struct device_node *np)
  25. +{
  26. + mtd->dev.of_node = np;
  27. +}
  28. +
  29. +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
  30. +{
  31. + return mtd->dev.of_node;
  32. +}
  33. +
  34. int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
  35. int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
  36. void **virt, resource_size_t *phys);
  37. diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
  38. index 5a9d1d4..4f7c9b9 100644
  39. --- a/include/linux/mtd/nand.h
  40. +++ b/include/linux/mtd/nand.h
  41. @@ -719,6 +719,17 @@ struct nand_chip {
  42. void *priv;
  43. };
  44. +static inline void nand_set_flash_node(struct nand_chip *chip,
  45. + struct device_node *np)
  46. +{
  47. + chip->flash_node = np;
  48. +}
  49. +
  50. +static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
  51. +{
  52. + return chip->flash_node;
  53. +}
  54. +
  55. /*
  56. * NAND Flash Manufacturer ID Codes
  57. */
  58. diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
  59. index 12a4611..823c5381 100644
  60. --- a/include/linux/mtd/spi-nor.h
  61. +++ b/include/linux/mtd/spi-nor.h
  62. @@ -184,6 +184,17 @@ struct spi_nor {
  63. void *priv;
  64. };
  65. +static inline void spi_nor_set_flash_node(struct spi_nor *nor,
  66. + struct device_node *np)
  67. +{
  68. + nor->flash_node = np;
  69. +}
  70. +
  71. +static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
  72. +{
  73. + return nor->flash_node;
  74. +}
  75. +
  76. /**
  77. * spi_nor_scan() - scan the SPI NOR
  78. * @nor: the spi_nor structure
  79. --
  80. 2.8.1