819-v6.8-0001-nvmem-Move-of_nvmem_layout_get_container-in-another-.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 4a1a40233b4a9fc159a5c7a27dc34c5c7bc5be55 Mon Sep 17 00:00:00 2001
  2. From: Miquel Raynal <[email protected]>
  3. Date: Fri, 15 Dec 2023 11:15:28 +0000
  4. Subject: [PATCH] nvmem: Move of_nvmem_layout_get_container() in another header
  5. nvmem-consumer.h is included by consumer devices, extracting data from
  6. NVMEM devices whereas nvmem-provider.h is included by devices providing
  7. NVMEM content.
  8. The only users of of_nvmem_layout_get_container() outside of the core
  9. are layout drivers, so better move its prototype to nvmem-provider.h.
  10. While we do so, we also move the kdoc associated with the function to
  11. the header rather than the .c file.
  12. Signed-off-by: Miquel Raynal <[email protected]>
  13. Signed-off-by: Srinivas Kandagatla <[email protected]>
  14. Link: https://lore.kernel.org/r/[email protected]
  15. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  16. ---
  17. drivers/nvmem/core.c | 8 --------
  18. include/linux/nvmem-consumer.h | 7 -------
  19. include/linux/nvmem-provider.h | 21 +++++++++++++++++++++
  20. 3 files changed, 21 insertions(+), 15 deletions(-)
  21. --- a/drivers/nvmem/core.c
  22. +++ b/drivers/nvmem/core.c
  23. @@ -847,14 +847,6 @@ static int nvmem_add_cells_from_layout(s
  24. }
  25. #if IS_ENABLED(CONFIG_OF)
  26. -/**
  27. - * of_nvmem_layout_get_container() - Get OF node to layout container.
  28. - *
  29. - * @nvmem: nvmem device.
  30. - *
  31. - * Return: a node pointer with refcount incremented or NULL if no
  32. - * container exists. Use of_node_put() on it when done.
  33. - */
  34. struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
  35. {
  36. return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
  37. --- a/include/linux/nvmem-consumer.h
  38. +++ b/include/linux/nvmem-consumer.h
  39. @@ -241,7 +241,6 @@ struct nvmem_cell *of_nvmem_cell_get(str
  40. const char *id);
  41. struct nvmem_device *of_nvmem_device_get(struct device_node *np,
  42. const char *name);
  43. -struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
  44. #else
  45. static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
  46. const char *id)
  47. @@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv
  48. {
  49. return ERR_PTR(-EOPNOTSUPP);
  50. }
  51. -
  52. -static inline struct device_node *
  53. -of_nvmem_layout_get_container(struct nvmem_device *nvmem)
  54. -{
  55. - return NULL;
  56. -}
  57. #endif /* CONFIG_NVMEM && CONFIG_OF */
  58. #endif /* ifndef _LINUX_NVMEM_CONSUMER_H */
  59. --- a/include/linux/nvmem-provider.h
  60. +++ b/include/linux/nvmem-provider.h
  61. @@ -244,6 +244,27 @@ nvmem_layout_get_match_data(struct nvmem
  62. #endif /* CONFIG_NVMEM */
  63. +#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
  64. +
  65. +/**
  66. + * of_nvmem_layout_get_container() - Get OF node of layout container
  67. + *
  68. + * @nvmem: nvmem device
  69. + *
  70. + * Return: a node pointer with refcount incremented or NULL if no
  71. + * container exists. Use of_node_put() on it when done.
  72. + */
  73. +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
  74. +
  75. +#else /* CONFIG_NVMEM && CONFIG_OF */
  76. +
  77. +static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
  78. +{
  79. + return NULL;
  80. +}
  81. +
  82. +#endif /* CONFIG_NVMEM && CONFIG_OF */
  83. +
  84. #define module_nvmem_layout_driver(__layout_driver) \
  85. module_driver(__layout_driver, nvmem_layout_register, \
  86. nvmem_layout_unregister)