[32/44] drm/mcde: Use devm_drm_dev_alloc
diff mbox series

Message ID 20200403135828.2542770-33-daniel.vetter@ffwll.ch
State New
Headers show
Series
  • devm_drm_dev_alloc, no more drmm_add_final_kfree
Related show

Commit Message

Daniel Vetter April 3, 2020, 1:58 p.m. UTC
Already using devm_drm_dev_init, so very simple replacment.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_drv.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Sam Ravnborg April 8, 2020, 7:57 a.m. UTC | #1
On Fri, Apr 03, 2020 at 03:58:16PM +0200, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>

But one comment below.

> ---
>  drivers/gpu/drm/mcde/mcde_drv.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
> index 88cc6b4a7a64..bdb525e3c5d7 100644
> --- a/drivers/gpu/drm/mcde/mcde_drv.c
> +++ b/drivers/gpu/drm/mcde/mcde_drv.c
> @@ -307,24 +307,16 @@ static int mcde_probe(struct platform_device *pdev)
>  	int ret;
>  	int i;
>  
> -	mcde = kzalloc(sizeof(*mcde), GFP_KERNEL);
> -	if (!mcde)
> -		return -ENOMEM;
> -	mcde->dev = dev;
> -
> -	ret = devm_drm_dev_init(dev, &mcde->drm, &mcde_drm_driver);
> -	if (ret) {
> -		kfree(mcde);
> -		return ret;
> -	}
> +	mcde = devm_drm_dev_alloc(dev, &mcde_drm_driver, struct mcde, drm);
> +	if (IS_ERR(mcde))
> +		return PTR_ERR(mcde);
>  	drm = &mcde->drm;
>  	drm->dev_private = mcde;
> -	drmm_add_final_kfree(drm, mcde);
> +	mcde->dev = dev;
>  	platform_set_drvdata(pdev, drm);
>  
>  	/* Enable continuous updates: this is what Linux' framebuffer expects */
>  	mcde->oneshot_mode = false;
> -	drm->dev_private = mcde;
It is assinged twice - but this change really belongs in next patch.

>  
>  	/* First obtain and turn on the main power */
>  	mcde->epod = devm_regulator_get(dev, "epod");
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox series

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 88cc6b4a7a64..bdb525e3c5d7 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -307,24 +307,16 @@  static int mcde_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	mcde = kzalloc(sizeof(*mcde), GFP_KERNEL);
-	if (!mcde)
-		return -ENOMEM;
-	mcde->dev = dev;
-
-	ret = devm_drm_dev_init(dev, &mcde->drm, &mcde_drm_driver);
-	if (ret) {
-		kfree(mcde);
-		return ret;
-	}
+	mcde = devm_drm_dev_alloc(dev, &mcde_drm_driver, struct mcde, drm);
+	if (IS_ERR(mcde))
+		return PTR_ERR(mcde);
 	drm = &mcde->drm;
 	drm->dev_private = mcde;
-	drmm_add_final_kfree(drm, mcde);
+	mcde->dev = dev;
 	platform_set_drvdata(pdev, drm);
 
 	/* Enable continuous updates: this is what Linux' framebuffer expects */
 	mcde->oneshot_mode = false;
-	drm->dev_private = mcde;
 
 	/* First obtain and turn on the main power */
 	mcde->epod = devm_regulator_get(dev, "epod");