aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <[email protected]>2020-03-23 15:49:08 +0100
committerDaniel Vetter <[email protected]>2020-03-26 15:18:06 +0100
commitb6097727ae57dc782900e5955ac03c5d6158b28d (patch)
treeb5fe9fd754fe79483150190ac07f98c73773018d
parent7fb81e9d80738ee2673990f6be1e55494d5ea014 (diff)
drm/cirrus: Use drmm_add_final_kfree
With this we can drop the final kfree from the release function. I also noticed that cirrus forgot to call drm_dev_fini(). v2: Don't call kfree(cirrus) after we've handed overship of that to drm_device and the drmm_ stuff. Acked-by: Gerd Hoffmann <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: "Noralf Trønnes" <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: [email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
-rw-r--r--drivers/gpu/drm/cirrus/cirrus.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index d2ff63ce8eaf..2232556ce34c 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -35,6 +35,7 @@
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_ioctl.h>
+#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
@@ -527,10 +528,8 @@ static void cirrus_mode_config_init(struct cirrus_device *cirrus)
static void cirrus_release(struct drm_device *dev)
{
- struct cirrus_device *cirrus = dev->dev_private;
-
drm_mode_config_cleanup(dev);
- kfree(cirrus);
+ drm_dev_fini(dev);
}
DEFINE_DRM_GEM_FOPS(cirrus_fops);
@@ -575,9 +574,12 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
dev = &cirrus->dev;
ret = drm_dev_init(dev, &cirrus_driver, &pdev->dev);
- if (ret)
- goto err_free_cirrus;
+ if (ret) {
+ kfree(cirrus);
+ goto err_pci_release;
+ }
dev->dev_private = cirrus;
+ drmm_add_final_kfree(dev, cirrus);
ret = -ENOMEM;
cirrus->vram = ioremap(pci_resource_start(pdev, 0),
@@ -618,8 +620,6 @@ err_unmap_vram:
iounmap(cirrus->vram);
err_dev_put:
drm_dev_put(dev);
-err_free_cirrus:
- kfree(cirrus);
err_pci_release:
pci_release_regions(pdev);
return ret;