]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/omap: dss: sdi: convert to devm_drm_bridge_alloc() API
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 9 May 2025 13:53:38 +0000 (15:53 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 21 May 2025 11:40:09 +0000 (13:40 +0200)
This is the new API for allocating DRM bridges.

Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.

Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250509-drm-bridge-convert-to-alloc-api-v3-12-b8bc1f16d7aa@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/omapdrm/dss/sdi.c

index e78826e4b560a2b9af2d8a5a38e181bd3e44d250..df4cbc683e2ca27ef5fc45f79b77dcdcd9ca529a 100644 (file)
@@ -284,7 +284,6 @@ static const struct drm_bridge_funcs sdi_bridge_funcs = {
 
 static void sdi_bridge_init(struct sdi_device *sdi)
 {
-       sdi->bridge.funcs = &sdi_bridge_funcs;
        sdi->bridge.of_node = sdi->pdev->dev.of_node;
        sdi->bridge.type = DRM_MODE_CONNECTOR_LVDS;
 
@@ -344,21 +343,19 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
        u32 datapairs;
        int r;
 
-       sdi = kzalloc(sizeof(*sdi), GFP_KERNEL);
-       if (!sdi)
-               return -ENOMEM;
+       sdi = devm_drm_bridge_alloc(&pdev->dev, struct sdi_device, bridge, &sdi_bridge_funcs);
+       if (IS_ERR(sdi))
+               return PTR_ERR(sdi);
 
        ep = of_graph_get_next_port_endpoint(port, NULL);
-       if (!ep) {
-               r = 0;
-               goto err_free;
-       }
+       if (!ep)
+               return 0;
 
        r = of_property_read_u32(ep, "datapairs", &datapairs);
        of_node_put(ep);
        if (r) {
                DSSERR("failed to parse datapairs\n");
-               goto err_free;
+               return r;
        }
 
        sdi->datapairs = datapairs;
@@ -372,19 +369,14 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
                r = PTR_ERR(sdi->vdds_sdi_reg);
                if (r != -EPROBE_DEFER)
                        DSSERR("can't get VDDS_SDI regulator\n");
-               goto err_free;
+               return r;
        }
 
        r = sdi_init_output(sdi);
        if (r)
-               goto err_free;
+               return r;
 
        return 0;
-
-err_free:
-       kfree(sdi);
-
-       return r;
 }
 
 void sdi_uninit_port(struct device_node *port)
@@ -395,5 +387,4 @@ void sdi_uninit_port(struct device_node *port)
                return;
 
        sdi_uninit_output(sdi);
-       kfree(sdi);
 }