[PATCH v2 09/21] drm/tilcdc: Allocate register storage based on the actual number registers

Tomi Valkeinen tomi.valkeinen at ti.com
Mon Feb 22 12:51:57 UTC 2016



On 16/02/16 16:18, Jyri Sarha wrote:
> Allocate suspend/resume register storage based on the actual number
> registers the driver is aware of. The static allocation for register
> storage had falen behind badly.

"fallen"

> 
> Reported-by: Michael Bode <michael at bumbleB.de>
> Signed-off-by: Jyri Sarha <jsarha at ti.com>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 21 ++++++++++++++++++++-
>  drivers/gpu/drm/tilcdc/tilcdc_drv.h |  2 +-
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 893ef18..ab1789b 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -141,11 +141,14 @@ static int tilcdc_unload(struct drm_device *dev)
>  
>  	pm_runtime_disable(dev->dev);
>  
> +	kfree(priv->saved_register);
>  	kfree(priv);
>  
>  	return 0;
>  }
>  
> +static size_t tilcdc_num_regs(void);
> +
>  static int tilcdc_load(struct drm_device *dev, unsigned long flags)
>  {
>  	struct platform_device *pdev = dev->platformdev;
> @@ -157,7 +160,12 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
>  	int ret;
>  
>  	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv) {
> +	if (priv)
> +		priv->saved_register = kcalloc(tilcdc_num_regs(),
> +					       sizeof(*priv->saved_register),
> +					       GFP_KERNEL);

devm_kzalloc() would clean this up a bit. For both 'priv' and
'saved_registers'.

 Tomi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20160222/03bc1f59/attachment-0001.sig>


More information about the dri-devel mailing list