Skip to content

Commit

Permalink
nvmem: core: export nvmem_add_cells_from_of()
Browse files Browse the repository at this point in the history
This symbol can be cleanly re-used by the fixed NVMEM layout driver.
Allow passing DT node as argument to make it a bit more generic.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  • Loading branch information
Rafał Miłecki authored and intel-lab-lkp committed Mar 17, 2023
1 parent a18c08f commit 70d21b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/nvmem/core.c
Expand Up @@ -694,15 +694,15 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem)
return 0;
}

static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
int nvmem_add_cells_from_of(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;
int len, ret;

for_each_child_of_node(dev->of_node, child) {
for_each_child_of_node(np, child) {
struct nvmem_cell_info info = {0};

addr = of_get_property(child, "reg", &len);
Expand Down Expand Up @@ -739,6 +739,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)

return 0;
}
EXPORT_SYMBOL_GPL(nvmem_add_cells_from_of);

int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner)
{
Expand Down Expand Up @@ -970,7 +971,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
if (rval)
goto err_remove_cells;

rval = nvmem_add_cells_from_of(nvmem);
rval = nvmem_add_cells_from_of(nvmem, nvmem->dev.of_node);
if (rval)
goto err_remove_cells;

Expand Down
7 changes: 7 additions & 0 deletions include/linux/nvmem-provider.h
Expand Up @@ -194,6 +194,8 @@ void nvmem_del_cell_table(struct nvmem_cell_table *table);
int nvmem_add_one_cell(struct nvmem_device *nvmem,
const struct nvmem_cell_info *info);

int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np);

int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner);
#define nvmem_layout_register(layout) \
__nvmem_layout_register(layout, THIS_MODULE)
Expand Down Expand Up @@ -225,6 +227,11 @@ static inline int nvmem_add_one_cell(struct nvmem_device *nvmem,
return -EOPNOTSUPP;
}

static int nvmem_add_cells_from_of(struct nvmem_device *nvmem, struct device_node *np)
{
return -EOPNOTSUPP;
}

static inline int nvmem_layout_register(struct nvmem_layout *layout)
{
return -EOPNOTSUPP;
Expand Down

0 comments on commit 70d21b7

Please sign in to comment.