Re: [PATCH V4 3/4] nvmem: core: export nvmem_add_cells_from_of()

From: Michael Walle
Date: Mon Mar 20 2023 - 04:23:23 EST


Am 2023-03-17 14:26, schrieb Rafał Miłecki:
From: Rafał Miłecki <rafal@xxxxxxxxxx>

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@xxxxxxxxxx>
---
drivers/nvmem/core.c | 7 ++++---
include/linux/nvmem-provider.h | 7 +++++++
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 212c5ba5789f..985a42cfb0a2 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -694,7 +694,7 @@ 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)

I'm not sure, how to feel about exposing an "internal" function to
the layouts module. I mean all these nvmem_add_cells_from_* are internal
to the core. Also the help text of the add_cells() callback tells you to
use nvmem_add_one_cell().

Although there is a bit of code duplication, I'd rather refactor
the nvmem_add_cells_from_of() to split it into parsing and adding.
Then re-use just the parsing from the fixed layout module and
call the appropriate nvmem_add_one_cell() yourself there.

-michael