Re: [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 15, 2020 at 09:40:13AM +0200, Daniel Vetter wrote:
> Luckily we're already well set up in the main driver, with
> drm_dev_put() being the last thing in both the unload error case and
> the pci remove function.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>

Pushed to drm-misc-next with Jani's irc-ack.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 17 ++++-------------
>  drivers/gpu/drm/i915/i915_pci.c |  2 --
>  2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 641f5e03b661..ff9a5b1b4c6d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		(struct intel_device_info *)ent->driver_data;
>  	struct intel_device_info *device_info;
>  	struct drm_i915_private *i915;
> -	int err;
>  
> -	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
> -	if (!i915)
> -		return ERR_PTR(-ENOMEM);
> -
> -	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
> -	if (err) {
> -		kfree(i915);
> -		return ERR_PTR(err);
> -	}
> -
> -	drmm_add_final_kfree(&i915->drm, i915);
> +	i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct drm_i915_private, drm);
> +	if (IS_ERR(i915))
> +		return i915;
>  
>  	i915->drm.pdev = pdev;
>  	pci_set_drvdata(pdev, i915);
> @@ -1006,7 +998,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_disable_device(pdev);
>  out_fini:
>  	i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
> -	drm_dev_put(&i915->drm);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 66738f2c4f28..2741fb3e30cb 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -941,8 +941,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
>  
>  	i915_driver_remove(i915);
>  	pci_set_drvdata(pdev, NULL);
> -
> -	drm_dev_put(&i915->drm);
>  }
>  
>  /* is device_id present in comma separated list of ids */
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux