From: sashiko-bot@kernel.org
To: "Hongmei Xu" <hongmei.xu@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/2] nvmem: core: add byte-mask support for non-contiguous cell bytes
Date: Mon, 16 Nov 2026 03:13:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-216112@kernel.org> (raw)
In-Reply-To: <20261116-nvmem-byte-mask-for-split-macaddr-v2-2-96f4a0c08264@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] nvmem: core: unaligned raw_len in
nvmem_cell_info_to_nvmem_cell_entry_nodup()
- [Low] nvmem: core: redundant nvmem_validate_byte_mask() in
nvmem_add_cells_from_dt()
--
commit ef65d0ead813d5be4bc32f2283c1a2c9aee24659
Author: Hongmei Xu <hongmei.xu@oss.qualcomm.com>
nvmem: core: add byte-mask support for non-contiguous cell bytes
This commit adds a byte-mask cell property to select and pack
non-contiguous physical bytes from an NVMEM region into a logical cell
value.
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 7d4cce8e27424..7e96b84bc4e28 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
[ ... ]
> @@ -603,12 +645,22 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
>
> cell->bit_offset = info->bit_offset;
> cell->nbits = info->nbits;
> + cell->byte_mask = info->byte_mask;
> cell->np = info->np;
>
> + if (cell->byte_mask) {
> + int rc = nvmem_validate_byte_mask(nvmem, info);
> +
> + if (rc)
> + return rc;
> + }
> +
> if (cell->nbits) {
> cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
> BITS_PER_BYTE);
> cell->raw_len = ALIGN(cell->bytes, nvmem->word_size);
> + } else if (cell->byte_mask) {
> + cell->raw_len = fls(info->byte_mask);
> }
[Severity: Medium]
Should cell->raw_len be aligned to nvmem->word_size here, as the
cell->nbits branch and nvmem_validate_byte_mask() do?
Leaving cell->raw_len as fls(info->byte_mask) triggers the
!IS_ALIGNED(cell->raw_len, nvmem->word_size) check just below whenever
nvmem->word_size > 1 and fls(info->byte_mask) is not a multiple of
word_size:
drivers/nvmem/core.c:nvmem_cell_info_to_nvmem_cell_entry_nodup() {
...
if (!IS_ALIGNED(cell->raw_len, nvmem->word_size)) {
dev_err(&nvmem->dev,
"cell %s raw len %zd unaligned to nvmem word size %d\n",
cell->name ?: "<unknown>", cell->raw_len,
nvmem->word_size);
if (info->raw_len)
return -EINVAL;
cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size);
}
}
That logs a false error and, if info->raw_len was set (for example by a
fixup_dt_cell_info callback), fails cell registration with -EINVAL.
[ ... ]
> @@ -829,16 +881,27 @@ int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
[ ... ]
> + of_property_read_u32(child, "byte-mask", &info.byte_mask);
> +
> info.np = of_node_get(child);
>
> if (nvmem->fixup_dt_cell_info)
> nvmem->fixup_dt_cell_info(nvmem, &info);
>
> + if (info.byte_mask) {
> + ret = nvmem_validate_byte_mask(nvmem, &info);
> + if (ret)
> + goto err_free_name;
> + }
> +
> ret = nvmem_add_one_cell(nvmem, &info);
[Severity: Low]
This isn't a bug, but nvmem_add_one_cell() ->
nvmem_cell_info_to_nvmem_cell_entry() ->
nvmem_cell_info_to_nvmem_cell_entry_nodup() already calls
nvmem_validate_byte_mask(nvmem, &info), so this check in
nvmem_add_cells_from_dt() is redundant.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-nvmem-byte-mask-for-split-macaddr-v2-0-96f4a0c08264@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-11-16 3:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 2:58 [PATCH v2 0/2] nvmem: Add byte-mask support for non-contiguous byte selection Hongmei Xu
2026-11-16 2:58 ` [PATCH v2 1/2] dt-bindings: nvmem: add byte-mask property " Hongmei Xu
2026-11-16 3:05 ` sashiko-bot
2026-11-17 3:15 ` Hongmei Xu
2026-11-16 2:58 ` [PATCH v2 2/2] nvmem: core: add byte-mask support for non-contiguous cell bytes Hongmei Xu
2026-11-16 3:13 ` sashiko-bot [this message]
2026-11-17 5:41 ` Hongmei Xu
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=sashiko-outbox-216112@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hongmei.xu@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.