drm/st7735r: Use devm_drm_dev_alloc

Already using devm_drm_dev_init, so very simple replacment.

Aside: There was an oddity in the old code, we allocated priv but in
the error path we've freed priv->dbidev ...

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-14-daniel.vetter@ffwll.ch
This commit is contained in:
Daniel Vetter 2020-04-15 09:39:48 +02:00
parent 6ae355a260
commit 14877bc715
1 changed files with 4 additions and 9 deletions

View File

@ -195,21 +195,16 @@ static int st7735r_probe(struct spi_device *spi)
if (!cfg) if (!cfg)
cfg = (void *)spi_get_device_id(spi)->driver_data; cfg = (void *)spi_get_device_id(spi)->driver_data;
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_drm_dev_alloc(dev, &st7735r_driver,
if (!priv) struct st7735r_priv, dbidev.drm);
return -ENOMEM; if (IS_ERR(priv))
return PTR_ERR(priv);
dbidev = &priv->dbidev; dbidev = &priv->dbidev;
priv->cfg = cfg; priv->cfg = cfg;
dbi = &dbidev->dbi; dbi = &dbidev->dbi;
drm = &dbidev->drm; drm = &dbidev->drm;
ret = devm_drm_dev_init(dev, drm, &st7735r_driver);
if (ret) {
kfree(dbidev);
return ret;
}
drmm_add_final_kfree(drm, dbidev);
dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) { if (IS_ERR(dbi->reset)) {