All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 4/9] nvmem: layouts: Support fixed-layout as the nvmem device node itself
Date: Sat, 04 Jul 2026 13:45:53 +0000	[thread overview]
Message-ID: <20260704134553.979031F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703-block-as-nvmem-v8-4-98ae32bfc49a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Double parsing of NVMEM cells leading to duplicate sysfs entries and device probe failure when a legacy provider adds the `fixed-layout` compatible string.
--

commit 5ae6267ddd6db9a2a2626cb61243805bccbca0b9
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>

nvmem: layouts: Support fixed-layout as the nvmem device node itself

This commit modifies of_nvmem_layout_get_container() to return the nvmem
device node itself if it lacks an "nvmem-layout" child but has the
"fixed-layout" compatible string.

> diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
> index b90584e1b99ea..efa631ce7283b 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);

[Severity: Medium]
Could this lead to double parsing of NVMEM cells and device probe failures
for legacy providers?

If a legacy provider (which sets config->add_legacy_fixed_of_cells = true
in its driver) updates its device tree node to include the "fixed-layout"
compatible string, it looks like nvmem_register() might parse the cells
twice:

drivers/nvmem/core.c:nvmem_register() {
        ...
        if (config->add_legacy_fixed_of_cells) {
                rval = nvmem_add_cells_from_legacy_of(nvmem);
                if (rval)
                        goto err_remove_cells;
        }

        rval = nvmem_add_cells_from_fixed_layout(nvmem);
        if (rval)
                goto err_remove_cells;
        ...
}

Because of_nvmem_layout_get_container() now returns the nvmem device node
itself, both functions would process the same child nodes.

Would nvmem_populate_sysfs_cells() then fail with -EEXIST due to duplicate
sysfs entries and abort the device registration?

> +
> +	return NULL;
>  }
>  EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703-block-as-nvmem-v8-0-98ae32bfc49a@oss.qualcomm.com?part=4

  reply	other threads:[~2026-07-04 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 13:45 [PATCH v8 0/9] Support for block device NVMEM providers Loic Poulain
2026-07-03 13:45 ` [PATCH v8 1/9] dt-bindings: mmc: Document fixed-layout NVMEM provider support Loic Poulain
2026-07-03 16:12   ` Support for block device NVMEM providers bluez.test.bot
2026-07-03 13:45 ` [PATCH v8 2/9] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-07-03 13:45 ` [PATCH v8 3/9] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-07-03 13:45 ` [PATCH v8 4/9] nvmem: layouts: Support fixed-layout as the nvmem device node itself Loic Poulain
2026-07-04 13:45   ` sashiko-bot [this message]
2026-07-03 13:45 ` [PATCH v8 5/9] block: implement NVMEM provider Loic Poulain
2026-07-04 13:45   ` sashiko-bot
2026-07-03 13:45 ` [PATCH v8 6/9] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-07-03 13:45 ` [PATCH v8 7/9] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-07-03 13:45 ` [PATCH v8 8/9] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-07-03 13:45 ` [PATCH v8 9/9] arm64: dts: qcom: arduino-imola: Describe NVMEM layout for WiFi/BT addresses Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260704134553.979031F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.