mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 23:12:32 +00:00
170 lines
6.0 KiB
Diff
170 lines
6.0 KiB
Diff
|
From 1172460e716784ac7e1049a537bdca8edbf97360 Mon Sep 17 00:00:00 2001
|
||
|
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||
|
Date: Fri, 15 Dec 2023 11:15:31 +0000
|
||
|
Subject: [PATCH] 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>
|
||
|
---
|
||
|
drivers/nvmem/core.c | 6 +++---
|
||
|
drivers/nvmem/imx-ocotp.c | 11 +++--------
|
||
|
drivers/nvmem/internals.h | 2 ++
|
||
|
drivers/nvmem/mtk-efuse.c | 11 +++--------
|
||
|
include/linux/nvmem-provider.h | 9 ++++-----
|
||
|
5 files changed, 15 insertions(+), 24 deletions(-)
|
||
|
|
||
|
--- a/drivers/nvmem/core.c
|
||
|
+++ b/drivers/nvmem/core.c
|
||
|
@@ -676,7 +676,6 @@ static int nvmem_validate_keepouts(struc
|
||
|
|
||
|
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
|
||
|
{
|
||
|
- struct nvmem_layout *layout = nvmem->layout;
|
||
|
struct device *dev = &nvmem->dev;
|
||
|
struct device_node *child;
|
||
|
const __be32 *addr;
|
||
|
@@ -706,8 +705,8 @@ static int nvmem_add_cells_from_dt(struc
|
||
|
|
||
|
info.np = of_node_get(child);
|
||
|
|
||
|
- if (layout && layout->fixup_cell_info)
|
||
|
- layout->fixup_cell_info(nvmem, layout, &info);
|
||
|
+ if (nvmem->fixup_dt_cell_info)
|
||
|
+ nvmem->fixup_dt_cell_info(nvmem, &info);
|
||
|
|
||
|
ret = nvmem_add_one_cell(nvmem, &info);
|
||
|
kfree(info.name);
|
||
|
@@ -896,6 +895,7 @@ struct nvmem_device *nvmem_register(cons
|
||
|
|
||
|
kref_init(&nvmem->refcnt);
|
||
|
INIT_LIST_HEAD(&nvmem->cells);
|
||
|
+ nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info;
|
||
|
|
||
|
nvmem->owner = config->owner;
|
||
|
if (!nvmem->owner && config->dev->driver)
|
||
|
--- a/drivers/nvmem/imx-ocotp.c
|
||
|
+++ b/drivers/nvmem/imx-ocotp.c
|
||
|
@@ -584,17 +584,12 @@ static const struct of_device_id imx_oco
|
||
|
};
|
||
|
MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
|
||
|
|
||
|
-static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem,
|
||
|
- struct nvmem_layout *layout,
|
||
|
- struct nvmem_cell_info *cell)
|
||
|
+static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||
|
+ struct nvmem_cell_info *cell)
|
||
|
{
|
||
|
cell->read_post_process = imx_ocotp_cell_pp;
|
||
|
}
|
||
|
|
||
|
-static struct nvmem_layout imx_ocotp_layout = {
|
||
|
- .fixup_cell_info = imx_ocotp_fixup_cell_info,
|
||
|
-};
|
||
|
-
|
||
|
static int imx_ocotp_probe(struct platform_device *pdev)
|
||
|
{
|
||
|
struct device *dev = &pdev->dev;
|
||
|
@@ -620,7 +615,7 @@ static int imx_ocotp_probe(struct platfo
|
||
|
imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
|
||
|
imx_ocotp_nvmem_config.dev = dev;
|
||
|
imx_ocotp_nvmem_config.priv = priv;
|
||
|
- imx_ocotp_nvmem_config.layout = &imx_ocotp_layout;
|
||
|
+ imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info;
|
||
|
|
||
|
priv->config = &imx_ocotp_nvmem_config;
|
||
|
|
||
|
--- a/drivers/nvmem/internals.h
|
||
|
+++ b/drivers/nvmem/internals.h
|
||
|
@@ -23,6 +23,8 @@ struct nvmem_device {
|
||
|
struct bin_attribute eeprom;
|
||
|
struct device *base_dev;
|
||
|
struct list_head cells;
|
||
|
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||
|
+ struct nvmem_cell_info *cell);
|
||
|
const struct nvmem_keepout *keepout;
|
||
|
unsigned int nkeepout;
|
||
|
nvmem_reg_read_t reg_read;
|
||
|
--- a/drivers/nvmem/mtk-efuse.c
|
||
|
+++ b/drivers/nvmem/mtk-efuse.c
|
||
|
@@ -45,9 +45,8 @@ static int mtk_efuse_gpu_speedbin_pp(voi
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem,
|
||
|
- struct nvmem_layout *layout,
|
||
|
- struct nvmem_cell_info *cell)
|
||
|
+static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||
|
+ struct nvmem_cell_info *cell)
|
||
|
{
|
||
|
size_t sz = strlen(cell->name);
|
||
|
|
||
|
@@ -61,10 +60,6 @@ static void mtk_efuse_fixup_cell_info(st
|
||
|
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
|
||
|
}
|
||
|
|
||
|
-static struct nvmem_layout mtk_efuse_layout = {
|
||
|
- .fixup_cell_info = mtk_efuse_fixup_cell_info,
|
||
|
-};
|
||
|
-
|
||
|
static int mtk_efuse_probe(struct platform_device *pdev)
|
||
|
{
|
||
|
struct device *dev = &pdev->dev;
|
||
|
@@ -91,7 +86,7 @@ static int mtk_efuse_probe(struct platfo
|
||
|
econfig.priv = priv;
|
||
|
econfig.dev = dev;
|
||
|
if (pdata->uses_post_processing)
|
||
|
- econfig.layout = &mtk_efuse_layout;
|
||
|
+ econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
|
||
|
nvmem = devm_nvmem_register(dev, &econfig);
|
||
|
|
||
|
return PTR_ERR_OR_ZERO(nvmem);
|
||
|
--- a/include/linux/nvmem-provider.h
|
||
|
+++ b/include/linux/nvmem-provider.h
|
||
|
@@ -83,6 +83,8 @@ struct nvmem_cell_info {
|
||
|
* @cells: Optional array of pre-defined NVMEM cells.
|
||
|
* @ncells: Number of elements in cells.
|
||
|
* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
|
||
|
+ * @fixup_dt_cell_info: Will be called before a cell is added. Can be
|
||
|
+ * used to modify the nvmem_cell_info.
|
||
|
* @keepout: Optional array of keepout ranges (sorted ascending by start).
|
||
|
* @nkeepout: Number of elements in the keepout array.
|
||
|
* @type: Type of the nvmem storage
|
||
|
@@ -113,6 +115,8 @@ struct nvmem_config {
|
||
|
const struct nvmem_cell_info *cells;
|
||
|
int ncells;
|
||
|
bool add_legacy_fixed_of_cells;
|
||
|
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||
|
+ struct nvmem_cell_info *cell);
|
||
|
const struct nvmem_keepout *keepout;
|
||
|
unsigned int nkeepout;
|
||
|
enum nvmem_type type;
|
||
|
@@ -158,8 +162,6 @@ struct nvmem_cell_table {
|
||
|
* @of_match_table: Open firmware match table.
|
||
|
* @add_cells: Called to populate the layout using
|
||
|
* nvmem_add_one_cell().
|
||
|
- * @fixup_cell_info: Will be called before a cell is added. Can be
|
||
|
- * used to modify the nvmem_cell_info.
|
||
|
* @owner: Pointer to struct module.
|
||
|
* @node: List node.
|
||
|
*
|
||
|
@@ -172,9 +174,6 @@ struct nvmem_layout {
|
||
|
const char *name;
|
||
|
const struct of_device_id *of_match_table;
|
||
|
int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||
|
- void (*fixup_cell_info)(struct nvmem_device *nvmem,
|
||
|
- struct nvmem_layout *layout,
|
||
|
- struct nvmem_cell_info *cell);
|
||
|
|
||
|
/* private */
|
||
|
struct module *owner;
|