@@ -249,7 +249,7 @@ int gud_usb_set_u8(struct gud_device *gdrm, u8 request, u8 val)
249249 return gud_usb_set (gdrm , request , 0 , & val , sizeof (val ));
250250}
251251
252- static int gud_get_properties (struct gud_device * gdrm )
252+ static int gud_plane_add_properties (struct gud_device * gdrm )
253253{
254254 struct gud_property_req * properties ;
255255 unsigned int i , num_properties ;
@@ -463,10 +463,6 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
463463 return PTR_ERR (gdrm );
464464
465465 drm = & gdrm -> drm ;
466- drm -> mode_config .funcs = & gud_mode_config_funcs ;
467- ret = drmm_mode_config_init (drm );
468- if (ret )
469- return ret ;
470466
471467 gdrm -> flags = le32_to_cpu (desc .flags );
472468 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)
483479 if (ret )
484480 return ret ;
485481
482+ usb_set_intfdata (intf , gdrm );
483+
484+ dma_dev = usb_intf_get_dma_device (intf );
485+ if (dma_dev ) {
486+ drm_dev_set_dma_dev (drm , dma_dev );
487+ put_device (dma_dev );
488+ } else {
489+ dev_warn (dev , "buffer sharing not supported" ); /* not an error */
490+ }
491+
492+ /* Mode config init */
493+ ret = drmm_mode_config_init (drm );
494+ if (ret )
495+ return ret ;
496+
486497 drm -> mode_config .min_width = le32_to_cpu (desc .min_width );
487498 drm -> mode_config .max_width = le32_to_cpu (desc .max_width );
488499 drm -> mode_config .min_height = le32_to_cpu (desc .min_height );
489500 drm -> mode_config .max_height = le32_to_cpu (desc .max_height );
501+ drm -> mode_config .funcs = & gud_mode_config_funcs ;
490502
503+ /* Format init */
491504 formats_dev = devm_kmalloc (dev , GUD_FORMATS_MAX_NUM , GFP_KERNEL );
492505 /* Add room for emulated XRGB8888 */
493506 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)
587600 return - ENOMEM ;
588601 }
589602
603+ /* Pipeline init */
590604 ret = drm_universal_plane_init (drm , & gdrm -> plane , 0 ,
591605 & gud_plane_funcs ,
592606 formats , num_formats ,
@@ -598,12 +612,9 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
598612 drm_plane_helper_add (& gdrm -> plane , & gud_plane_helper_funcs );
599613 drm_plane_enable_fb_damage_clips (& gdrm -> plane );
600614
601- devm_kfree (dev , formats );
602- devm_kfree (dev , formats_dev );
603-
604- ret = gud_get_properties (gdrm );
615+ ret = gud_plane_add_properties (gdrm );
605616 if (ret ) {
606- dev_err (dev , "Failed to get properties (error=%d)\n" , ret );
617+ dev_err (dev , "Failed to add properties (error=%d)\n" , ret );
607618 return ret ;
608619 }
609620
@@ -621,24 +632,16 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
621632 }
622633
623634 drm_mode_config_reset (drm );
624-
625- usb_set_intfdata (intf , gdrm );
626-
627- dma_dev = usb_intf_get_dma_device (intf );
628- if (dma_dev ) {
629- drm_dev_set_dma_dev (drm , dma_dev );
630- put_device (dma_dev );
631- } else {
632- dev_warn (dev , "buffer sharing not supported" ); /* not an error */
633- }
635+ drm_kms_helper_poll_init (drm );
634636
635637 drm_debugfs_add_file (drm , "stats" , gud_stats_debugfs , NULL );
636638
637639 ret = drm_dev_register (drm , 0 );
638640 if (ret )
639641 return ret ;
640642
641- drm_kms_helper_poll_init (drm );
643+ devm_kfree (dev , formats );
644+ devm_kfree (dev , formats_dev );
642645
643646 drm_client_setup (drm , NULL );
644647
0 commit comments