[PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling

Johan Hovold posted 2 patches 4 months, 2 weeks ago
[PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
Posted by Johan Hovold 4 months, 2 weeks ago
Simplify the canvas lookup error handling by dropping the OF node
reference sooner.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/soc/amlogic/meson-canvas.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/amlogic/meson-canvas.c b/drivers/soc/amlogic/meson-canvas.c
index 0711088da5dc..79681afea8c6 100644
--- a/drivers/soc/amlogic/meson-canvas.c
+++ b/drivers/soc/amlogic/meson-canvas.c
@@ -60,12 +60,9 @@ struct meson_canvas *meson_canvas_get(struct device *dev)
 		return ERR_PTR(-ENODEV);
 
 	canvas_pdev = of_find_device_by_node(canvas_node);
-	if (!canvas_pdev) {
-		of_node_put(canvas_node);
-		return ERR_PTR(-EPROBE_DEFER);
-	}
-
 	of_node_put(canvas_node);
+	if (!canvas_pdev)
+		return ERR_PTR(-EPROBE_DEFER);
 
 	/*
 	 * If priv is NULL, it's probably because the canvas hasn't
-- 
2.49.1
Re: [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
Posted by Martin Blumenstingl 4 months ago
On Fri, Sep 26, 2025 at 4:25 PM Johan Hovold <johan@kernel.org> wrote:
>
> Simplify the canvas lookup error handling by dropping the OF node
> reference sooner.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Re: [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
Posted by Markus Elfring 4 months, 2 weeks ago
> Simplify the canvas lookup error handling by dropping the OF node
> reference sooner.

How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/of.h#L138

Regards,
Markus