OSDN Git Service

drm/bochs: Drop explicit drm_mode_config_cleanup
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 23 Mar 2020 14:49:27 +0000 (15:49 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 26 Mar 2020 14:46:09 +0000 (15:46 +0100)
Instead rely on the automatic clean, for which we just need to check
that drm_mode_config_init succeeded. To avoid an inversion in the
cleanup we also have to move the dev_private allocation over to
drmm_kzalloc.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-29-daniel.vetter@ffwll.ch
drivers/gpu/drm/bochs/bochs.h
drivers/gpu/drm/bochs/bochs_drv.c
drivers/gpu/drm/bochs/bochs_kms.c

index 9177671..e5bd1d5 100644 (file)
@@ -92,7 +92,6 @@ void bochs_mm_fini(struct bochs_device *bochs);
 
 /* bochs_kms.c */
 int bochs_kms_init(struct bochs_device *bochs);
-void bochs_kms_fini(struct bochs_device *bochs);
 
 /* bochs_fbdev.c */
 extern const struct drm_mode_config_funcs bochs_mode_funcs;
index addb056..e18c51d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <drm/drm_drv.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_managed.h>
 
 #include "bochs.h"
 
@@ -21,10 +22,7 @@ static void bochs_unload(struct drm_device *dev)
 {
        struct bochs_device *bochs = dev->dev_private;
 
-       bochs_kms_fini(bochs);
        bochs_mm_fini(bochs);
-       kfree(bochs);
-       dev->dev_private = NULL;
 }
 
 static int bochs_load(struct drm_device *dev)
@@ -32,7 +30,7 @@ static int bochs_load(struct drm_device *dev)
        struct bochs_device *bochs;
        int ret;
 
-       bochs = kzalloc(sizeof(*bochs), GFP_KERNEL);
+       bochs = drmm_kzalloc(dev, sizeof(*bochs), GFP_KERNEL);
        if (bochs == NULL)
                return -ENOMEM;
        dev->dev_private = bochs;
index e8cc815..7f4bcfa 100644 (file)
@@ -134,7 +134,11 @@ const struct drm_mode_config_funcs bochs_mode_funcs = {
 
 int bochs_kms_init(struct bochs_device *bochs)
 {
-       drm_mode_config_init(bochs->dev);
+       int ret;
+
+       ret = drmm_mode_config_init(bochs->dev);
+       if (ret)
+               return ret;
 
        bochs->dev->mode_config.max_width = 8192;
        bochs->dev->mode_config.max_height = 8192;
@@ -160,11 +164,3 @@ int bochs_kms_init(struct bochs_device *bochs)
 
        return 0;
 }
-
-void bochs_kms_fini(struct bochs_device *bochs)
-{
-       if (!bochs->dev->mode_config.num_connector)
-               return;
-
-       drm_mode_config_cleanup(bochs->dev);
-}