[PATCH v2 10/15] nvmem: core: add nvmem-layout support
Marco Felsch
m.felsch at pengutronix.de
Wed Aug 20 02:11:19 PDT 2025
On 25-08-20, Sascha Hauer wrote:
> On Mon, Aug 18, 2025 at 07:44:44PM +0200, Marco Felsch wrote:
> > This ports the Linux nvmem-layout core infrastructure required for the
> > actual nvmem-layout drivers. This commit doesn't add any specific
> > nvmem-layout driver.
> >
> > A nvmem-layout is the new way to describe the nvmem storage format. The
> > nvmem-layout driver parses the nvmem sotrage format and provides the
> > information via nvmem-cells.
> >
> > Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
> > ---
> > drivers/nvmem/Kconfig | 7 ++
> > drivers/nvmem/Makefile | 3 +
> > drivers/nvmem/core.c | 100 +++++++++++++++++++++++-
> > drivers/nvmem/internals.h | 22 ++++++
> > drivers/nvmem/layouts.c | 173 +++++++++++++++++++++++++++++++++++++++++
> > drivers/nvmem/layouts/Kconfig | 13 ++++
> > drivers/nvmem/layouts/Makefile | 7 ++
> > include/linux/nvmem-provider.h | 63 +++++++++++++++
> > 8 files changed, 385 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> > +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
> > +{
> > + return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
>
> This also needs an additional
>
> if (!nvmem->dev.of_node)
> return NULL;
>
> check. This also goes down to of_get_child_by_name doing a
> for_each_child_of_node() which is defines as:
>
> #define for_each_child_of_node(parent, child) \
> list_for_each_entry(child, &parent->children, parent_list)
>
> list_for_each_entry() does not work with NULL pointers. We might want to
> change this for Linux compatibility.
Thanks for testing and spotting this. I ran tests but of course all my
nvmem devices had an of_node :(
Regards,
Marco
More information about the barebox
mailing list