Commit 90ad200b authored by Daniel Vetter's avatar Daniel Vetter

drm/armada: Use devm_drm_dev_alloc

Also remove the now no longer needed build bug on since that's already
not needed anymore with drmm_add_final_kfree. Conversion to managed
drm_device cleanup is easy, the final drm_dev_put() is already the
last thing in both the bind unbind as in the unbind flow.

Also, this relies on component.c correctly wrapping bind&unbind in
separate devres groups, which it does.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Cc: Russell King <linux@armlinux.org.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200904143941.110665-2-daniel.vetter@ffwll.ch
parent 8c3c818c
...@@ -87,24 +87,13 @@ static int armada_drm_bind(struct device *dev) ...@@ -87,24 +87,13 @@ static int armada_drm_bind(struct device *dev)
"armada-drm")) "armada-drm"))
return -EBUSY; return -EBUSY;
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_drm_dev_alloc(dev, &armada_drm_driver,
if (!priv) struct armada_private, drm);
return -ENOMEM; if (IS_ERR(priv)) {
dev_err(dev, "[" DRM_NAME ":%s] devm_drm_dev_alloc failed: %li\n",
/* __func__, PTR_ERR(priv));
* The drm_device structure must be at the start of return PTR_ERR(priv);
* armada_private for drm_dev_put() to work correctly.
*/
BUILD_BUG_ON(offsetof(struct armada_private, drm) != 0);
ret = drm_dev_init(&priv->drm, &armada_drm_driver, dev);
if (ret) {
dev_err(dev, "[" DRM_NAME ":%s] drm_dev_init failed: %d\n",
__func__, ret);
kfree(priv);
return ret;
} }
drmm_add_final_kfree(&priv->drm, priv);
/* Remove early framebuffers */ /* Remove early framebuffers */
ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
...@@ -174,7 +163,6 @@ static int armada_drm_bind(struct device *dev) ...@@ -174,7 +163,6 @@ static int armada_drm_bind(struct device *dev)
err_kms: err_kms:
drm_mode_config_cleanup(&priv->drm); drm_mode_config_cleanup(&priv->drm);
drm_mm_takedown(&priv->linear); drm_mm_takedown(&priv->linear);
drm_dev_put(&priv->drm);
return ret; return ret;
} }
...@@ -194,8 +182,6 @@ static void armada_drm_unbind(struct device *dev) ...@@ -194,8 +182,6 @@ static void armada_drm_unbind(struct device *dev)
drm_mode_config_cleanup(&priv->drm); drm_mode_config_cleanup(&priv->drm);
drm_mm_takedown(&priv->linear); drm_mm_takedown(&priv->linear);
drm_dev_put(&priv->drm);
} }
static int compare_of(struct device *dev, void *data) static int compare_of(struct device *dev, void *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment