* [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm
@ 2024-08-25 13:50 Krzysztof Kozlowski
2024-08-25 13:50 ` [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop Krzysztof Kozlowski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 13:50 UTC (permalink / raw)
To: Vladimir Zapolskiy, Krzysztof Kozlowski, Miquel Raynal,
Michal Simek, linux-arm-kernel, linux-kernel
Cc: Krzysztof Kozlowski, Jonathan Cameron
Use devm_add_action_or_reset() and dev_err_probe() to make the probe()
error handling simpler around amba_release_regions() cleanup. This
allows to drop the remove() callback entirely.
Suggested-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/memory/pl172.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/memory/pl172.c b/drivers/memory/pl172.c
index db5fbee34077..be7ba599cccf 100644
--- a/drivers/memory/pl172.c
+++ b/drivers/memory/pl172.c
@@ -187,6 +187,13 @@ static int pl172_parse_cs_config(struct amba_device *adev,
return -EINVAL;
}
+static void pl172_amba_release_regions(void *data)
+{
+ struct amba_device *adev = data;
+
+ amba_release_regions(adev);
+}
+
static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"};
static const char * const pl175_revisions[] = {"r1"};
static const char * const pl176_revisions[] = {"r0"};
@@ -232,13 +239,14 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
return ret;
}
+ ret = devm_add_action_or_reset(dev, pl172_amba_release_regions, adev);
+ if (ret)
+ return ret;
+
pl172->base = devm_ioremap(dev, adev->res.start,
resource_size(&adev->res));
- if (!pl172->base) {
- dev_err(dev, "ioremap failed\n");
- ret = -ENOMEM;
- goto err_no_ioremap;
- }
+ if (!pl172->base)
+ return dev_err_probe(dev, -ENOMEM, "ioremap failed\n");
amba_set_drvdata(adev, pl172);
@@ -256,15 +264,6 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id)
}
return 0;
-
-err_no_ioremap:
- amba_release_regions(adev);
- return ret;
-}
-
-static void pl172_remove(struct amba_device *adev)
-{
- amba_release_regions(adev);
}
static const struct amba_id pl172_ids[] = {
@@ -292,7 +291,6 @@ static struct amba_driver pl172_driver = {
.name = "memory-pl172",
},
.probe = pl172_probe,
- .remove = pl172_remove,
.id_table = pl172_ids,
};
module_amba_driver(pl172_driver);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop
2024-08-25 13:50 [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm Krzysztof Kozlowski
@ 2024-08-25 13:50 ` Krzysztof Kozlowski
2024-08-26 8:10 ` Miquel Raynal
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
2 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 13:50 UTC (permalink / raw)
To: Vladimir Zapolskiy, Krzysztof Kozlowski, Miquel Raynal,
Michal Simek, linux-arm-kernel, linux-kernel
Cc: Krzysztof Kozlowski, Jonathan Cameron
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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm
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-25 20:19 ` Vladimir Zapolskiy
2024-08-31 5:45 ` Krzysztof Kozlowski
2 siblings, 0 replies; 5+ messages in thread
From: Vladimir Zapolskiy @ 2024-08-25 20:19 UTC (permalink / raw)
To: Krzysztof Kozlowski, Krzysztof Kozlowski, Miquel Raynal,
Michal Simek, linux-arm-kernel, linux-kernel
Cc: Jonathan Cameron
On 8/25/24 16:50, Krzysztof Kozlowski wrote:
> Use devm_add_action_or_reset() and dev_err_probe() to make the probe()
> error handling simpler around amba_release_regions() cleanup. This
> allows to drop the remove() callback entirely.
>
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop
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
0 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2024-08-26 8:10 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Vladimir Zapolskiy, Krzysztof Kozlowski, Michal Simek,
linux-arm-kernel, linux-kernel, Jonathan Cameron
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm
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-25 20:19 ` [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm Vladimir Zapolskiy
@ 2024-08-31 5:45 ` Krzysztof Kozlowski
2 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-31 5:45 UTC (permalink / raw)
To: Vladimir Zapolskiy, Krzysztof Kozlowski, Miquel Raynal,
Michal Simek, linux-arm-kernel, linux-kernel, Krzysztof Kozlowski
Cc: Jonathan Cameron
On Sun, 25 Aug 2024 15:50:00 +0200, Krzysztof Kozlowski wrote:
> Use devm_add_action_or_reset() and dev_err_probe() to make the probe()
> error handling simpler around amba_release_regions() cleanup. This
> allows to drop the remove() callback entirely.
>
>
Applied, thanks!
[1/2] memory: pl172: simplify releasing AMBA regions with devm
https://git.kernel.org/krzk/linux-mem-ctrl/c/331b8a963137d182248599d500edd9b4a3783db5
[2/2] memory: pl353-smc: simplify with scoped for each OF child loop
https://git.kernel.org/krzk/linux-mem-ctrl/c/32960b4f25c248f13758b8bbe6cc4260828442a1
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-31 5:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox