diff mbox series

[21/59] drm/gm12u320: Use devm_drm_dev_alloc

Message ID 20200415074034.175360-22-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series devm_drm_dev_alloc, v2 | expand

Commit Message

Daniel Vetter April 15, 2020, 7:39 a.m. UTC
Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Hans de Goede April 15, 2020, 3:04 p.m. UTC | #1
Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
> index 6f0ea2827d62..907739a67bf6 100644
> --- a/drivers/gpu/drm/tiny/gm12u320.c
> +++ b/drivers/gpu/drm/tiny/gm12u320.c
> @@ -631,22 +631,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
>   	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
>   		return -ENODEV;
>   
> -	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
> -	if (gm12u320 == NULL)
> -		return -ENOMEM;
> +	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
> +				      struct gm12u320_device, dev);
> +	if (IS_ERR(gm12u320))
> +		return PTR_ERR(gm12u320);
>   
>   	gm12u320->udev = interface_to_usbdev(interface);
>   	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
>   	mutex_init(&gm12u320->fb_update.lock);
>   
>   	dev = &gm12u320->dev;
> -	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
> -	if (ret) {
> -		kfree(gm12u320);
> -		return ret;
> -	}
>   	dev->dev_private = gm12u320;
> -	drmm_add_final_kfree(dev, gm12u320);
>   
>   	ret = drmm_mode_config_init(dev);
>   	if (ret)
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 6f0ea2827d62..907739a67bf6 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -631,22 +631,17 @@  static int gm12u320_usb_probe(struct usb_interface *interface,
 	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
-	if (gm12u320 == NULL)
-		return -ENOMEM;
+	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
+				      struct gm12u320_device, dev);
+	if (IS_ERR(gm12u320))
+		return PTR_ERR(gm12u320);
 
 	gm12u320->udev = interface_to_usbdev(interface);
 	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
 	mutex_init(&gm12u320->fb_update.lock);
 
 	dev = &gm12u320->dev;
-	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
-	if (ret) {
-		kfree(gm12u320);
-		return ret;
-	}
 	dev->dev_private = gm12u320;
-	drmm_add_final_kfree(dev, gm12u320);
 
 	ret = drmm_mode_config_init(dev);
 	if (ret)