Re: [PATCH v8 4/9] nvmem: layouts: Support fixed-layout as the nvmem device node itself

Bartosz Golaszewski <[email protected]>
Newsgroups org.kernel.vger.linux-block,org.infradead.lists.ath10k,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-bluetooth,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-mmc,org.kernel.vger.linux-wireless,org.kernel.vger.netdev
Message-ID <CAMRc=MeNHzEn+pizmbTUCU6YCiTWZS7cr_yEBSNis8NuYqYjig@mail.gmail.com>
On Wed, 15 Jul 2026 14:07:24 +0200, Bartosz Golaszewski <[email protected]> said:
> On Fri, 3 Jul 2026 15:45:17 +0200, Loic Poulain <[email protected]> said:
>> of_nvmem_layout_get_container() only looks for a child node named
>> "nvmem-layout" to locate the cell definitions. This does not cover
>> providers whose device tree node is itself the fixed-layout container,
>> such as an eMMC boot partition block device whose fwnode points directly
>> at a "fixed-layout" compatible partitions node.
>>
>> When no "nvmem-layout" child is present, fall back to returning the nvmem
>> device node itself if it is compatible with "fixed-layout", so that its
>> cells are parsed by nvmem_add_cells_from_fixed_layout().
>>
>> Signed-off-by: Loic Poulain <[email protected]>
>> ---
>>  drivers/nvmem/layouts.c | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
>> index b90584e1b99eab4217cbe7ec48373e18a7caf0dc..efa631ce7283bdd6c8ecda75915911b5e3a33c99 100644
>> --- a/drivers/nvmem/layouts.c
>> +++ b/drivers/nvmem/layouts.c
>> @@ -167,7 +167,18 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
>>
>>  struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
>>  {
>> -	return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
>> +	struct device_node *np;
>> +
>> +	/* Search for nvmem-layout child */
>> +	np = of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
>> +	if (np)
>> +		return np;
>> +
>> +	/* The nvmem of_node is itself a fixed-layout node */
>> +	if (of_device_is_compatible(nvmem->dev.of_node, "fixed-layout"))
>> +		return of_node_get(nvmem->dev.of_node);
>> +
>> +	return NULL;
>>  }
>>  EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
>>
>>
>> --
>> 2.34.1
>>
>>
>
> I have it on my TODO list to convert nvmem layouts to be fwnode-agnostic. While
> I'm not sure when I'll have the time to look into it, I think it makes sense
> to not introduce any new OF-specific interfaces. Can you make it into:
>
>   struct fwnode_handle *nvmem_layout_get_container_node(struct nvmem_device *nvmem);
>
> by replacing of_get_child_by_name() with fwnode_get_name_child_node() and
> of_device_is_compatible() with device_is_compatible()? That would mean less
> churn in the future.
>
> Other than that, it looks good.
>
> Bart
>

Scratch that, I didn't realize this isn't a new function but a rework of an
existing one.

Reviewed-by: Bartosz Golaszewski <[email protected]>

Bart
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.