From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 2/4] nvmem: Simplify with scoped for each OF child loop
Date: Fri, 16 Jan 2026 17:08:44 +0000 [thread overview]
Message-ID: <20260116170846.733558-3-srini@kernel.org> (raw)
In-Reply-To: <20260116170846.733558-1-srini@kernel.org>
From: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
drivers/nvmem/core.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index ff68fd5ad3d6..c6180cf1dd91 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -789,11 +789,10 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem)
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
{
struct device *dev = &nvmem->dev;
- struct device_node *child;
const __be32 *addr;
int len, ret;
- for_each_child_of_node(np, child) {
+ for_each_child_of_node_scoped(np, child) {
struct nvmem_cell_info info = {0};
addr = of_get_property(child, "reg", &len);
@@ -801,7 +800,6 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
continue;
if (len < 2 * sizeof(u32)) {
dev_err(dev, "nvmem: invalid reg on %pOF\n", child);
- of_node_put(child);
return -EINVAL;
}
@@ -817,7 +815,6 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
info.nbits < 1 ||
info.bit_offset + info.nbits > BITS_PER_BYTE * info.bytes) {
dev_err(dev, "nvmem: invalid bits on %pOF\n", child);
- of_node_put(child);
return -EINVAL;
}
}
@@ -830,7 +827,6 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
ret = nvmem_add_one_cell(nvmem, &info);
kfree(info.name);
if (ret) {
- of_node_put(child);
of_node_put(info.np);
return ret;
}
--
2.51.0
next prev parent reply other threads:[~2026-01-16 17:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 17:08 [PATCH 0/4] nvmem: patches (set 1) for 6.20 srini
2026-01-16 17:08 ` [PATCH 1/4] nvmem: Drop OF node reference on nvmem_add_one_cell() failure srini
2026-01-16 17:08 ` srini [this message]
2026-01-16 17:08 ` [PATCH 3/4] nvmem: an8855: drop an unused Kconfig symbol srini
2026-01-16 17:08 ` [PATCH 4/4] dt-bindings: nvmem: qfprom: Add sm8750 compatible srini
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=20260116170846.733558-3-srini@kernel.org \
--to=srini@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
/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.