drm/gud: rearrange gud_probe() to prepare for function splitting
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ruben Wauters
maintainerPATCH v2 1/1 drm/gud: rearrange gud_probe() to prepare for function splitting
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.
---
Changelog:
v2
- rename gud_get_properties to gud_plane_add_properties and move function call to proper location
- move usb_set_intfdata and block with dma setup to just under gdrm init
- add proper spacing for init comments
--- drivers/gpu/drm/gud/gud_drv.c | 45 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/gpu/drm/gud/gud_drv.c +24 -21
@@ -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 );
Signature · 1 line
2.51.0
Hi,
looks good.
Am 20.10.25 um 15:56 schrieb Ruben Wauters:
Quoted 7 lines
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 <[email protected]>
If I'm not mistaken, you should by now have commit rights to the drm-misc repo. Give it a few more days for others to review and if nothing comes in, you're welcome to merge the patch into drm-misc-next.
Best regards
Thomas
Quoted 116 lines
---
Changelog:v2
- renamegud_get_propertiestogud_plane_add_propertiesand move function call to proper location
- moveusb_set_intfdataand block with dma setup to just under gdrm init
- add proper spacing for init comments--- drivers/gpu/drm/gud/gud_drv.c | 45 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-)drivers/gpu/drm/gud/gud_drv.c +24
-21@@ -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 );
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)