From: Daniel Vetter Date: Wed, 15 Apr 2020 07:39:46 +0000 (+0200) Subject: drm/udl: Use devm_drm_dev_alloc X-Git-Tag: v5.15~303^2~28^2~2885 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50b9bbecaa5bdb78aaa51a39a01242016ed96314;p=platform%2Fkernel%2Flinux-starfive.git drm/udl: Use devm_drm_dev_alloc With Thomas' patch to clean up fbdev init this is a rather standard conversion to the new wrapper macro. v2: Rebase on top of Thomas' patches to remove the return value from drm_fbdev_generic_setup() v3: Update commit message to reflect the reality of the rebased patch (Sam) Reviewed-by: Thomas Zimmermann Acked-by: Sam Ravnborg Signed-off-by: Daniel Vetter Cc: Noralf Trønnes Cc: Dave Airlie Cc: Sean Paul Cc: Thomas Zimmermann Cc: Daniel Vetter Cc: Emil Velikov Cc: Sam Ravnborg Cc: Thomas Gleixner Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-12-daniel.vetter@ffwll.ch --- diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c index 9cc6d07..523f60e 100644 --- a/drivers/gpu/drm/udl/udl_drv.c +++ b/drivers/gpu/drm/udl/udl_drv.c @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface) struct udl_device *udl; int r; - udl = kzalloc(sizeof(*udl), GFP_KERNEL); - if (!udl) - return ERR_PTR(-ENOMEM); - - r = drm_dev_init(&udl->drm, &driver, &interface->dev); - if (r) { - kfree(udl); - return ERR_PTR(r); - } + udl = devm_drm_dev_alloc(&interface->dev, &driver, + struct udl_device, drm); + if (IS_ERR(udl)) + return udl; udl->udev = udev; udl->drm.dev_private = udl; - drmm_add_final_kfree(&udl->drm, udl); r = udl_init(udl); - if (r) { - drm_dev_put(&udl->drm); + if (r) return ERR_PTR(r); - } usb_set_intfdata(interface, udl); + return udl; } @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface, r = drm_dev_register(&udl->drm, 0); if (r) - goto err_free; + return r; DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index); drm_fbdev_generic_setup(&udl->drm, 0); return 0; - -err_free: - drm_dev_put(&udl->drm); - return r; } static void udl_usb_disconnect(struct usb_interface *interface) @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface) drm_kms_helper_poll_fini(dev); udl_drop_usb(dev); drm_dev_unplug(dev); - drm_dev_put(dev); } /*