[34/44] drm/ingenic: Use devm_drm_dev_alloc
diff mbox series

Message ID 20200403135828.2542770-35-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: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Sam Ravnborg April 8, 2020, 7:59 a.m. UTC | #1
On Fri, Apr 03, 2020 at 03:58:18PM +0200, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Paul Cercueil <paul@crapouillou.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/ingenic/ingenic-drm.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
> index a9bc6623b488..bb62d8e93985 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
> @@ -614,9 +614,10 @@ static int ingenic_drm_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> +	priv = devm_drm_dev_alloc(dev, &ingenic_drm_driver_data,
> +				  struct ingenic_drm, drm);
> +	if (IS_ERR(priv))
> +		return PTR_ERR(priv);
>  
>  	priv->soc_info = soc_info;
>  	priv->dev = dev;
> @@ -625,13 +626,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, priv);
>  
> -	ret = devm_drm_dev_init(dev, drm, &ingenic_drm_driver_data);
> -	if (ret) {
> -		kfree(priv);
> -		return ret;
> -	}
> -	drmm_add_final_kfree(drm, priv);
> -
>  	ret = drmm_mode_config_init(drm);
>  	if (ret)
>  		return ret;
> -- 
> 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/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index a9bc6623b488..bb62d8e93985 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -614,9 +614,10 @@  static int ingenic_drm_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	priv = devm_drm_dev_alloc(dev, &ingenic_drm_driver_data,
+				  struct ingenic_drm, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
 	priv->soc_info = soc_info;
 	priv->dev = dev;
@@ -625,13 +626,6 @@  static int ingenic_drm_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	ret = devm_drm_dev_init(dev, drm, &ingenic_drm_driver_data);
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, priv);
-
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;