Commit ac19f140 authored by Daniel Vetter's avatar Daniel Vetter

drm/vkms: Use drmm_add_final_kfree

With this we can drop the final kfree from the release function.

v2: After drm_dev_init/drmm_add_final_kfree we need to clean up
everything through a drm_dev_put. Rework the unwind code to match
that.
Reviewed-by: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Tested-by: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-15-daniel.vetter@ffwll.ch
parent 363de9e7
......@@ -21,6 +21,7 @@
#include <drm/drm_file.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>
......@@ -158,13 +159,14 @@ static int __init vkms_init(void)
&vkms_device->platform->dev);
if (ret)
goto out_unregister;
drmm_add_final_kfree(&vkms_device->drm, vkms_device);
ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev,
DMA_BIT_MASK(64));
if (ret) {
DRM_ERROR("Could not initialize DMA support\n");
goto out_fini;
goto out_put;
}
vkms_device->drm.irq_enabled = true;
......@@ -172,25 +174,25 @@ static int __init vkms_init(void)
ret = drm_vblank_init(&vkms_device->drm, 1);
if (ret) {
DRM_ERROR("Failed to vblank\n");
goto out_fini;
goto out_put;
}
ret = vkms_modeset_init(vkms_device);
if (ret)
goto out_fini;
goto out_put;
ret = drm_dev_register(&vkms_device->drm, 0);
if (ret)
goto out_fini;
goto out_put;
return 0;
out_fini:
drm_dev_fini(&vkms_device->drm);
out_put:
drm_dev_put(&vkms_device->drm);
return ret;
out_unregister:
platform_device_unregister(vkms_device->platform);
out_free:
kfree(vkms_device);
return ret;
......@@ -205,8 +207,6 @@ static void __exit vkms_exit(void)
drm_dev_unregister(&vkms_device->drm);
drm_dev_put(&vkms_device->drm);
kfree(vkms_device);
}
module_init(vkms_init);
......
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