drm/tilcdc: Allocate register storage based on the actual number registers

Allocate suspend/resume register storage based on the actual number
registers the driver is aware of. The static allocation for register
storage had fallen behind badly.

Reported-by: Michael Bode <michael@bumbleB.de>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
Jyri Sarha 2015-07-02 16:26:12 +03:00
parent 7974dff495
commit 29ddd6e171
2 changed files with 21 additions and 2 deletions

View File

@ -141,11 +141,14 @@ static int tilcdc_unload(struct drm_device *dev)
pm_runtime_disable(dev->dev); pm_runtime_disable(dev->dev);
kfree(priv->saved_register);
kfree(priv); kfree(priv);
return 0; return 0;
} }
static size_t tilcdc_num_regs(void);
static int tilcdc_load(struct drm_device *dev, unsigned long flags) static int tilcdc_load(struct drm_device *dev, unsigned long flags)
{ {
struct platform_device *pdev = dev->platformdev; struct platform_device *pdev = dev->platformdev;
@ -157,7 +160,12 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
int ret; int ret;
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) { if (priv)
priv->saved_register = kcalloc(tilcdc_num_regs(),
sizeof(*priv->saved_register),
GFP_KERNEL);
if (!priv || !priv->saved_register) {
kfree(priv);
dev_err(dev->dev, "failed to allocate private data\n"); dev_err(dev->dev, "failed to allocate private data\n");
return -ENOMEM; return -ENOMEM;
} }
@ -339,6 +347,7 @@ fail_free_wq:
fail_free_priv: fail_free_priv:
dev->dev_private = NULL; dev->dev_private = NULL;
kfree(priv->saved_register);
kfree(priv); kfree(priv);
return ret; return ret;
} }
@ -456,6 +465,16 @@ static const struct {
REG(2, true, LCDC_INT_ENABLE_SET_REG), REG(2, true, LCDC_INT_ENABLE_SET_REG),
#undef REG #undef REG
}; };
static size_t tilcdc_num_regs(void)
{
return ARRAY_SIZE(registers);
}
#else
static size_t tilcdc_num_regs(void)
{
return 0;
}
#endif #endif
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS

View File

@ -66,7 +66,7 @@ struct tilcdc_drm_private {
uint32_t max_width; uint32_t max_width;
/* register contents saved across suspend/resume: */ /* register contents saved across suspend/resume: */
u32 saved_register[12]; u32 *saved_register;
bool ctx_valid; bool ctx_valid;
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ