From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Vladimir Zapolskiy <vz@mleia.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Michal Simek <michal.simek@amd.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Subject: Re: [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop
Date: Mon, 26 Aug 2024 10:10:29 +0200 [thread overview]
Message-ID: <20240826101029.5bde327c@xps-13> (raw)
In-Reply-To: <20240825135001.48963-2-krzysztof.kozlowski@linaro.org>
Hi Krzysztof,
krzysztof.kozlowski@linaro.org wrote on Sun, 25 Aug 2024 15:50:01 +0200:
> Use scoped for_each_available_child_of_node_scoped() when iterating over
> device nodes to make code a bit simpler.
>
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/memory/pl353-smc.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/memory/pl353-smc.c b/drivers/memory/pl353-smc.c
> index 994c7a792e34..28a8cc56003c 100644
> --- a/drivers/memory/pl353-smc.c
> +++ b/drivers/memory/pl353-smc.c
> @@ -74,7 +74,6 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
> struct device_node *of_node = adev->dev.of_node;
> const struct of_device_id *match = NULL;
> struct pl353_smc_data *pl353_smc;
> - struct device_node *child;
>
> pl353_smc = devm_kzalloc(&adev->dev, sizeof(*pl353_smc), GFP_KERNEL);
> if (!pl353_smc)
> @@ -93,12 +92,13 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
> amba_set_drvdata(adev, pl353_smc);
>
> /* Find compatible children. Only a single child is supported */
> - for_each_available_child_of_node(of_node, child) {
> + for_each_available_child_of_node_scoped(of_node, child) {
> match = of_match_node(pl353_smc_supported_children, child);
> if (!match) {
> dev_warn(&adev->dev, "unsupported child node\n");
> continue;
> }
> + of_platform_device_create(child, NULL, &adev->dev);
> break;
> }
> if (!match) {
> @@ -106,9 +106,6 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
> return -ENODEV;
> }
>
> - of_platform_device_create(child, NULL, &adev->dev);
> - of_node_put(child);
> -
> return 0;
> }
Nice. I didn't even know about the _scope() variant. Thanks Jonathan
for the heads up!
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cheers,
Miquèl
next prev parent reply other threads:[~2024-08-26 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 13:50 [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm Krzysztof Kozlowski
2024-08-25 13:50 ` [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-26 8:10 ` Miquel Raynal [this message]
2024-08-25 20:19 ` [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm Vladimir Zapolskiy
2024-08-31 5:45 ` Krzysztof Kozlowski
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=20240826101029.5bde327c@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=krzk@kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=vz@mleia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox