Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmem: Move and rename ->fixup_cell_info()

This hook is meant to be used by any provider and instantiating a layout
just for this is useless. Let's instead move this hook to the nvmem
device and add it to the config structure to be easily shared by the
providers.

While at moving this hook, rename it ->fixup_dt_cell_info() to clarify
its main intended purpose.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231215111536.316972-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Miquel Raynal and committed by
Greg Kroah-Hartman
1172460e 1b7c298a

+15 -24
+3 -3
drivers/nvmem/core.c
··· 675 675 676 676 static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) 677 677 { 678 - struct nvmem_layout *layout = nvmem->layout; 679 678 struct device *dev = &nvmem->dev; 680 679 struct device_node *child; 681 680 const __be32 *addr; ··· 704 705 705 706 info.np = of_node_get(child); 706 707 707 - if (layout && layout->fixup_cell_info) 708 - layout->fixup_cell_info(nvmem, layout, &info); 708 + if (nvmem->fixup_dt_cell_info) 709 + nvmem->fixup_dt_cell_info(nvmem, &info); 709 710 710 711 ret = nvmem_add_one_cell(nvmem, &info); 711 712 kfree(info.name); ··· 894 895 895 896 kref_init(&nvmem->refcnt); 896 897 INIT_LIST_HEAD(&nvmem->cells); 898 + nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info; 897 899 898 900 nvmem->owner = config->owner; 899 901 if (!nvmem->owner && config->dev->driver)
+3 -8
drivers/nvmem/imx-ocotp.c
··· 583 583 }; 584 584 MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); 585 585 586 - static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem, 587 - struct nvmem_layout *layout, 588 - struct nvmem_cell_info *cell) 586 + static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem, 587 + struct nvmem_cell_info *cell) 589 588 { 590 589 cell->read_post_process = imx_ocotp_cell_pp; 591 590 } 592 - 593 - static struct nvmem_layout imx_ocotp_layout = { 594 - .fixup_cell_info = imx_ocotp_fixup_cell_info, 595 - }; 596 591 597 592 static int imx_ocotp_probe(struct platform_device *pdev) 598 593 { ··· 614 619 imx_ocotp_nvmem_config.size = 4 * priv->params->nregs; 615 620 imx_ocotp_nvmem_config.dev = dev; 616 621 imx_ocotp_nvmem_config.priv = priv; 617 - imx_ocotp_nvmem_config.layout = &imx_ocotp_layout; 622 + imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info; 618 623 619 624 priv->config = &imx_ocotp_nvmem_config; 620 625
+2
drivers/nvmem/internals.h
··· 23 23 struct bin_attribute eeprom; 24 24 struct device *base_dev; 25 25 struct list_head cells; 26 + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem, 27 + struct nvmem_cell_info *cell); 26 28 const struct nvmem_keepout *keepout; 27 29 unsigned int nkeepout; 28 30 nvmem_reg_read_t reg_read;
+3 -8
drivers/nvmem/mtk-efuse.c
··· 45 45 return 0; 46 46 } 47 47 48 - static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem, 49 - struct nvmem_layout *layout, 50 - struct nvmem_cell_info *cell) 48 + static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem, 49 + struct nvmem_cell_info *cell) 51 50 { 52 51 size_t sz = strlen(cell->name); 53 52 ··· 59 60 strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0) 60 61 cell->read_post_process = mtk_efuse_gpu_speedbin_pp; 61 62 } 62 - 63 - static struct nvmem_layout mtk_efuse_layout = { 64 - .fixup_cell_info = mtk_efuse_fixup_cell_info, 65 - }; 66 63 67 64 static int mtk_efuse_probe(struct platform_device *pdev) 68 65 { ··· 86 91 econfig.priv = priv; 87 92 econfig.dev = dev; 88 93 if (pdata->uses_post_processing) 89 - econfig.layout = &mtk_efuse_layout; 94 + econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info; 90 95 nvmem = devm_nvmem_register(dev, &econfig); 91 96 92 97 return PTR_ERR_OR_ZERO(nvmem);
+4 -5
include/linux/nvmem-provider.h
··· 83 83 * @cells: Optional array of pre-defined NVMEM cells. 84 84 * @ncells: Number of elements in cells. 85 85 * @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax. 86 + * @fixup_dt_cell_info: Will be called before a cell is added. Can be 87 + * used to modify the nvmem_cell_info. 86 88 * @keepout: Optional array of keepout ranges (sorted ascending by start). 87 89 * @nkeepout: Number of elements in the keepout array. 88 90 * @type: Type of the nvmem storage ··· 115 113 const struct nvmem_cell_info *cells; 116 114 int ncells; 117 115 bool add_legacy_fixed_of_cells; 116 + void (*fixup_dt_cell_info)(struct nvmem_device *nvmem, 117 + struct nvmem_cell_info *cell); 118 118 const struct nvmem_keepout *keepout; 119 119 unsigned int nkeepout; 120 120 enum nvmem_type type; ··· 162 158 * @of_match_table: Open firmware match table. 163 159 * @add_cells: Called to populate the layout using 164 160 * nvmem_add_one_cell(). 165 - * @fixup_cell_info: Will be called before a cell is added. Can be 166 - * used to modify the nvmem_cell_info. 167 161 * @owner: Pointer to struct module. 168 162 * @node: List node. 169 163 * ··· 174 172 const char *name; 175 173 const struct of_device_id *of_match_table; 176 174 int (*add_cells)(struct device *dev, struct nvmem_device *nvmem); 177 - void (*fixup_cell_info)(struct nvmem_device *nvmem, 178 - struct nvmem_layout *layout, 179 - struct nvmem_cell_info *cell); 180 175 181 176 /* private */ 182 177 struct module *owner;