]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/mxsfb/lcdif: simplify remote pointer management using __free
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 7 Apr 2026 12:24:15 +0000 (14:24 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 14 Apr 2026 11:52:31 +0000 (13:52 +0200)
Putting the remote device_node reference requires a of_node_put(remote) in
two places. Use a cleanup action to simplify the code.

Reviewed-by: Liu Ying <victor.liu@nxp.com>
Tested-by: Martyn Welch <martyn.welch@collabora.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> # TQMa8MPxL/MBa8MPxL
Link: https://patch.msgid.link/20260407-drm-lcdif-dbanc-v4-1-247a16e61ef9@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/mxsfb/lcdif_drv.c

index 47da1d9336b90a3d21c64fd7df3481da1fbb87de..7719629487da5c6ab9a7d4d3b627e210bd5671d5 100644 (file)
@@ -5,6 +5,7 @@
  * This code is based on drivers/gpu/drm/mxsfb/mxsfb*
  */
 
+#include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
@@ -53,16 +54,13 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
        int ret;
 
        for_each_endpoint_of_node(dev->of_node, ep) {
-               struct device_node *remote;
+               struct device_node *remote __free(device_node) =
+                       of_graph_get_remote_port_parent(ep);
                struct of_endpoint of_ep;
                struct drm_encoder *encoder;
 
-               remote = of_graph_get_remote_port_parent(ep);
-               if (!of_device_is_available(remote)) {
-                       of_node_put(remote);
+               if (!of_device_is_available(remote))
                        continue;
-               }
-               of_node_put(remote);
 
                ret = of_graph_parse_endpoint(ep, &of_ep);
                if (ret < 0) {