Commit b6097727 authored by Daniel Vetter's avatar Daniel Vetter

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: default avatarGerd Hoffmann <kraxel@redhat.com>
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-10-daniel.vetter@ffwll.ch
parent 7fb81e9d
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <drm/drm_gem_shmem_helper.h> #include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_ioctl.h> #include <drm/drm_ioctl.h>
#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper_vtables.h> #include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h> #include <drm/drm_simple_kms_helper.h>
...@@ -527,10 +528,8 @@ static void cirrus_mode_config_init(struct cirrus_device *cirrus) ...@@ -527,10 +528,8 @@ static void cirrus_mode_config_init(struct cirrus_device *cirrus)
static void cirrus_release(struct drm_device *dev) static void cirrus_release(struct drm_device *dev)
{ {
struct cirrus_device *cirrus = dev->dev_private;
drm_mode_config_cleanup(dev); drm_mode_config_cleanup(dev);
kfree(cirrus); drm_dev_fini(dev);
} }
DEFINE_DRM_GEM_FOPS(cirrus_fops); DEFINE_DRM_GEM_FOPS(cirrus_fops);
...@@ -575,9 +574,12 @@ static int cirrus_pci_probe(struct pci_dev *pdev, ...@@ -575,9 +574,12 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
dev = &cirrus->dev; dev = &cirrus->dev;
ret = drm_dev_init(dev, &cirrus_driver, &pdev->dev); ret = drm_dev_init(dev, &cirrus_driver, &pdev->dev);
if (ret) if (ret) {
goto err_free_cirrus; kfree(cirrus);
goto err_pci_release;
}
dev->dev_private = cirrus; dev->dev_private = cirrus;
drmm_add_final_kfree(dev, cirrus);
ret = -ENOMEM; ret = -ENOMEM;
cirrus->vram = ioremap(pci_resource_start(pdev, 0), cirrus->vram = ioremap(pci_resource_start(pdev, 0),
...@@ -618,8 +620,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev, ...@@ -618,8 +620,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
iounmap(cirrus->vram); iounmap(cirrus->vram);
err_dev_put: err_dev_put:
drm_dev_put(dev); drm_dev_put(dev);
err_free_cirrus:
kfree(cirrus);
err_pci_release: err_pci_release:
pci_release_regions(pdev); pci_release_regions(pdev);
return ret; return ret;
......
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