819-v6.8-0004-nvmem-Move-and-rename-fixup_cell_info.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. From 1172460e716784ac7e1049a537bdca8edbf97360 Mon Sep 17 00:00:00 2001
  2. From: Miquel Raynal <[email protected]>
  3. Date: Fri, 15 Dec 2023 11:15:31 +0000
  4. Subject: [PATCH] nvmem: Move and rename ->fixup_cell_info()
  5. This hook is meant to be used by any provider and instantiating a layout
  6. just for this is useless. Let's instead move this hook to the nvmem
  7. device and add it to the config structure to be easily shared by the
  8. providers.
  9. While at moving this hook, rename it ->fixup_dt_cell_info() to clarify
  10. its main intended purpose.
  11. Signed-off-by: Miquel Raynal <[email protected]>
  12. Signed-off-by: Srinivas Kandagatla <[email protected]>
  13. Link: https://lore.kernel.org/r/[email protected]
  14. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  15. ---
  16. drivers/nvmem/core.c | 6 +++---
  17. drivers/nvmem/imx-ocotp.c | 11 +++--------
  18. drivers/nvmem/internals.h | 2 ++
  19. drivers/nvmem/mtk-efuse.c | 11 +++--------
  20. include/linux/nvmem-provider.h | 9 ++++-----
  21. 5 files changed, 15 insertions(+), 24 deletions(-)
  22. --- a/drivers/nvmem/core.c
  23. +++ b/drivers/nvmem/core.c
  24. @@ -675,7 +675,6 @@ static int nvmem_validate_keepouts(struc
  25. static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
  26. {
  27. - struct nvmem_layout *layout = nvmem->layout;
  28. struct device *dev = &nvmem->dev;
  29. struct device_node *child;
  30. const __be32 *addr;
  31. @@ -705,8 +704,8 @@ static int nvmem_add_cells_from_dt(struc
  32. info.np = of_node_get(child);
  33. - if (layout && layout->fixup_cell_info)
  34. - layout->fixup_cell_info(nvmem, layout, &info);
  35. + if (nvmem->fixup_dt_cell_info)
  36. + nvmem->fixup_dt_cell_info(nvmem, &info);
  37. ret = nvmem_add_one_cell(nvmem, &info);
  38. kfree(info.name);
  39. @@ -895,6 +894,7 @@ struct nvmem_device *nvmem_register(cons
  40. kref_init(&nvmem->refcnt);
  41. INIT_LIST_HEAD(&nvmem->cells);
  42. + nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info;
  43. nvmem->owner = config->owner;
  44. if (!nvmem->owner && config->dev->driver)
  45. --- a/drivers/nvmem/imx-ocotp.c
  46. +++ b/drivers/nvmem/imx-ocotp.c
  47. @@ -583,17 +583,12 @@ static const struct of_device_id imx_oco
  48. };
  49. MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
  50. -static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem,
  51. - struct nvmem_layout *layout,
  52. - struct nvmem_cell_info *cell)
  53. +static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
  54. + struct nvmem_cell_info *cell)
  55. {
  56. cell->read_post_process = imx_ocotp_cell_pp;
  57. }
  58. -static struct nvmem_layout imx_ocotp_layout = {
  59. - .fixup_cell_info = imx_ocotp_fixup_cell_info,
  60. -};
  61. -
  62. static int imx_ocotp_probe(struct platform_device *pdev)
  63. {
  64. struct device *dev = &pdev->dev;
  65. @@ -619,7 +614,7 @@ static int imx_ocotp_probe(struct platfo
  66. imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
  67. imx_ocotp_nvmem_config.dev = dev;
  68. imx_ocotp_nvmem_config.priv = priv;
  69. - imx_ocotp_nvmem_config.layout = &imx_ocotp_layout;
  70. + imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info;
  71. priv->config = &imx_ocotp_nvmem_config;
  72. --- a/drivers/nvmem/internals.h
  73. +++ b/drivers/nvmem/internals.h
  74. @@ -23,6 +23,8 @@ struct nvmem_device {
  75. struct bin_attribute eeprom;
  76. struct device *base_dev;
  77. struct list_head cells;
  78. + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
  79. + struct nvmem_cell_info *cell);
  80. const struct nvmem_keepout *keepout;
  81. unsigned int nkeepout;
  82. nvmem_reg_read_t reg_read;
  83. --- a/drivers/nvmem/mtk-efuse.c
  84. +++ b/drivers/nvmem/mtk-efuse.c
  85. @@ -45,9 +45,8 @@ static int mtk_efuse_gpu_speedbin_pp(voi
  86. return 0;
  87. }
  88. -static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem,
  89. - struct nvmem_layout *layout,
  90. - struct nvmem_cell_info *cell)
  91. +static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
  92. + struct nvmem_cell_info *cell)
  93. {
  94. size_t sz = strlen(cell->name);
  95. @@ -61,10 +60,6 @@ static void mtk_efuse_fixup_cell_info(st
  96. cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
  97. }
  98. -static struct nvmem_layout mtk_efuse_layout = {
  99. - .fixup_cell_info = mtk_efuse_fixup_cell_info,
  100. -};
  101. -
  102. static int mtk_efuse_probe(struct platform_device *pdev)
  103. {
  104. struct device *dev = &pdev->dev;
  105. @@ -91,7 +86,7 @@ static int mtk_efuse_probe(struct platfo
  106. econfig.priv = priv;
  107. econfig.dev = dev;
  108. if (pdata->uses_post_processing)
  109. - econfig.layout = &mtk_efuse_layout;
  110. + econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
  111. nvmem = devm_nvmem_register(dev, &econfig);
  112. return PTR_ERR_OR_ZERO(nvmem);
  113. --- a/include/linux/nvmem-provider.h
  114. +++ b/include/linux/nvmem-provider.h
  115. @@ -83,6 +83,8 @@ struct nvmem_cell_info {
  116. * @cells: Optional array of pre-defined NVMEM cells.
  117. * @ncells: Number of elements in cells.
  118. * @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
  119. + * @fixup_dt_cell_info: Will be called before a cell is added. Can be
  120. + * used to modify the nvmem_cell_info.
  121. * @keepout: Optional array of keepout ranges (sorted ascending by start).
  122. * @nkeepout: Number of elements in the keepout array.
  123. * @type: Type of the nvmem storage
  124. @@ -113,6 +115,8 @@ struct nvmem_config {
  125. const struct nvmem_cell_info *cells;
  126. int ncells;
  127. bool add_legacy_fixed_of_cells;
  128. + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
  129. + struct nvmem_cell_info *cell);
  130. const struct nvmem_keepout *keepout;
  131. unsigned int nkeepout;
  132. enum nvmem_type type;
  133. @@ -158,8 +162,6 @@ struct nvmem_cell_table {
  134. * @of_match_table: Open firmware match table.
  135. * @add_cells: Called to populate the layout using
  136. * nvmem_add_one_cell().
  137. - * @fixup_cell_info: Will be called before a cell is added. Can be
  138. - * used to modify the nvmem_cell_info.
  139. * @owner: Pointer to struct module.
  140. * @node: List node.
  141. *
  142. @@ -172,9 +174,6 @@ struct nvmem_layout {
  143. const char *name;
  144. const struct of_device_id *of_match_table;
  145. int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
  146. - void (*fixup_cell_info)(struct nvmem_device *nvmem,
  147. - struct nvmem_layout *layout,
  148. - struct nvmem_cell_info *cell);
  149. /* private */
  150. struct module *owner;