]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/gud: rearrange gud_probe() to prepare for function splitting
authorRuben Wauters <rubenru09@aol.com>
Mon, 20 Oct 2025 13:56:04 +0000 (14:56 +0100)
committerRuben Wauters <rubenru09@aol.com>
Fri, 24 Oct 2025 18:36:45 +0000 (19:36 +0100)
gud_probe() is currently very large and does many things, including
pipeline setup and feature detection, as well as having USB functions.

This patch re-orders the code in gud_probe() to make it more organised
and easier to split apart in the future.

Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20251020140147.5017-1-rubenru09@aol.com/
drivers/gpu/drm/gud/gud_drv.c

index b7345c8d823def749a8dea580fd2cd8bed598377..42135a48d92eff078183fb66236c9cfffbf4ba3c 100644 (file)
@@ -249,7 +249,7 @@ int gud_usb_set_u8(struct gud_device *gdrm, u8 request, u8 val)
        return gud_usb_set(gdrm, request, 0, &val, sizeof(val));
 }
 
-static int gud_get_properties(struct gud_device *gdrm)
+static int gud_plane_add_properties(struct gud_device *gdrm)
 {
        struct gud_property_req *properties;
        unsigned int i, num_properties;
@@ -463,10 +463,6 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
                return PTR_ERR(gdrm);
 
        drm = &gdrm->drm;
-       drm->mode_config.funcs = &gud_mode_config_funcs;
-       ret = drmm_mode_config_init(drm);
-       if (ret)
-               return ret;
 
        gdrm->flags = le32_to_cpu(desc.flags);
        gdrm->compression = desc.compression & GUD_COMPRESSION_LZ4;
@@ -483,11 +479,28 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
        if (ret)
                return ret;
 
+       usb_set_intfdata(intf, gdrm);
+
+       dma_dev = usb_intf_get_dma_device(intf);
+       if (dma_dev) {
+               drm_dev_set_dma_dev(drm, dma_dev);
+               put_device(dma_dev);
+       } else {
+               dev_warn(dev, "buffer sharing not supported"); /* not an error */
+       }
+
+       /* Mode config init */
+       ret = drmm_mode_config_init(drm);
+       if (ret)
+               return ret;
+
        drm->mode_config.min_width = le32_to_cpu(desc.min_width);
        drm->mode_config.max_width = le32_to_cpu(desc.max_width);
        drm->mode_config.min_height = le32_to_cpu(desc.min_height);
        drm->mode_config.max_height = le32_to_cpu(desc.max_height);
+       drm->mode_config.funcs = &gud_mode_config_funcs;
 
+       /* Format init */
        formats_dev = devm_kmalloc(dev, GUD_FORMATS_MAX_NUM, GFP_KERNEL);
        /* Add room for emulated XRGB8888 */
        formats = devm_kmalloc_array(dev, GUD_FORMATS_MAX_NUM + 1, sizeof(*formats), GFP_KERNEL);
@@ -587,6 +600,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
                        return -ENOMEM;
        }
 
+       /* Pipeline init */
        ret = drm_universal_plane_init(drm, &gdrm->plane, 0,
                                       &gud_plane_funcs,
                                       formats, num_formats,
@@ -598,12 +612,9 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
        drm_plane_helper_add(&gdrm->plane, &gud_plane_helper_funcs);
        drm_plane_enable_fb_damage_clips(&gdrm->plane);
 
-       devm_kfree(dev, formats);
-       devm_kfree(dev, formats_dev);
-
-       ret = gud_get_properties(gdrm);
+       ret = gud_plane_add_properties(gdrm);
        if (ret) {
-               dev_err(dev, "Failed to get properties (error=%d)\n", ret);
+               dev_err(dev, "Failed to add properties (error=%d)\n", ret);
                return ret;
        }
 
@@ -621,16 +632,7 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
        }
 
        drm_mode_config_reset(drm);
-
-       usb_set_intfdata(intf, gdrm);
-
-       dma_dev = usb_intf_get_dma_device(intf);
-       if (dma_dev) {
-               drm_dev_set_dma_dev(drm, dma_dev);
-               put_device(dma_dev);
-       } else {
-               dev_warn(dev, "buffer sharing not supported"); /* not an error */
-       }
+       drm_kms_helper_poll_init(drm);
 
        drm_debugfs_add_file(drm, "stats", gud_stats_debugfs, NULL);
 
@@ -638,7 +640,8 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
        if (ret)
                return ret;
 
-       drm_kms_helper_poll_init(drm);
+       devm_kfree(dev, formats);
+       devm_kfree(dev, formats_dev);
 
        drm_client_setup(drm, NULL);