diff mbox series

[27/44] drm/tidss: Use devm_drm_dev_alloc

Message ID 20200403135828.2542770-28-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series devm_drm_dev_alloc, no more drmm_add_final_kfree | expand

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: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Sam Ravnborg April 8, 2020, 7:52 a.m. UTC | #1
On Fri, Apr 03, 2020 at 03:58:11PM +0200, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
> index ad449d104306..7d4465d58be8 100644
> --- a/drivers/gpu/drm/tidss/tidss_drv.c
> +++ b/drivers/gpu/drm/tidss/tidss_drv.c
> @@ -135,20 +135,13 @@ static int tidss_probe(struct platform_device *pdev)
>  
>  	dev_dbg(dev, "%s\n", __func__);
>  
> -	/* Can't use devm_* since drm_device's lifetime may exceed dev's */
> -	tidss = kzalloc(sizeof(*tidss), GFP_KERNEL);
> -	if (!tidss)
> -		return -ENOMEM;
> +	tidss = devm_drm_dev_alloc(&pdev->dev, &tidss_driver,
> +				   struct tidss_device, ddev);
> +	if (IS_ERR(tidss))
> +		return PTR_ERR(tidss);
>  
>  	ddev = &tidss->ddev;
>  
> -	ret = devm_drm_dev_init(&pdev->dev, ddev, &tidss_driver);
> -	if (ret) {
> -		kfree(ddev);
> -		return ret;
> -	}
> -	drmm_add_final_kfree(ddev, tidss);
> -
>  	tidss->dev = dev;
>  	tidss->feat = of_device_get_match_data(dev);
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Jyri Sarha April 14, 2020, 9:55 a.m. UTC | #2
On 03/04/2020 16:58, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>

Tested-by: Jyri Sarha <jsarha@ti.com>

> ---
>  drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
> index ad449d104306..7d4465d58be8 100644
> --- a/drivers/gpu/drm/tidss/tidss_drv.c
> +++ b/drivers/gpu/drm/tidss/tidss_drv.c
> @@ -135,20 +135,13 @@ static int tidss_probe(struct platform_device *pdev)
>  
>  	dev_dbg(dev, "%s\n", __func__);
>  
> -	/* Can't use devm_* since drm_device's lifetime may exceed dev's */
> -	tidss = kzalloc(sizeof(*tidss), GFP_KERNEL);
> -	if (!tidss)
> -		return -ENOMEM;
> +	tidss = devm_drm_dev_alloc(&pdev->dev, &tidss_driver,
> +				   struct tidss_device, ddev);
> +	if (IS_ERR(tidss))
> +		return PTR_ERR(tidss);
>  
>  	ddev = &tidss->ddev;
>  
> -	ret = devm_drm_dev_init(&pdev->dev, ddev, &tidss_driver);
> -	if (ret) {
> -		kfree(ddev);
> -		return ret;
> -	}
> -	drmm_add_final_kfree(ddev, tidss);
> -
>  	tidss->dev = dev;
>  	tidss->feat = of_device_get_match_data(dev);
>  
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index ad449d104306..7d4465d58be8 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -135,20 +135,13 @@  static int tidss_probe(struct platform_device *pdev)
 
 	dev_dbg(dev, "%s\n", __func__);
 
-	/* Can't use devm_* since drm_device's lifetime may exceed dev's */
-	tidss = kzalloc(sizeof(*tidss), GFP_KERNEL);
-	if (!tidss)
-		return -ENOMEM;
+	tidss = devm_drm_dev_alloc(&pdev->dev, &tidss_driver,
+				   struct tidss_device, ddev);
+	if (IS_ERR(tidss))
+		return PTR_ERR(tidss);
 
 	ddev = &tidss->ddev;
 
-	ret = devm_drm_dev_init(&pdev->dev, ddev, &tidss_driver);
-	if (ret) {
-		kfree(ddev);
-		return ret;
-	}
-	drmm_add_final_kfree(ddev, tidss);
-
 	tidss->dev = dev;
 	tidss->feat = of_device_get_match_data(dev);