drm: Compile out legacy chunks from struct drm_device
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 4 Nov 2020 10:04:21 +0000 (11:04 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 6 Nov 2020 09:31:26 +0000 (10:31 +0100)
This means some very few #ifdef in code, but it allows us to
enlist the compiler to make sure this stuff isn't used anymore.

More important, only legacy drivers change drm_device (for the
legacy_dev_list shadow attach management), therefore this is
prep to allow modern drivers to have a const driver struct. Which
is nice, because there's a ton of function pointers in there.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Review-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20201104100425.1922351-2-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_file.c
drivers/gpu/drm/drm_vblank.c
include/drm/drm_drv.h

index 0ac4566ae3f450d5a7fdea59852c83a32c575db1..b50380fa80ce83389172cf4f3a053299aaaf46cc 100644 (file)
@@ -258,9 +258,11 @@ void drm_file_free(struct drm_file *file)
                  (long)old_encode_dev(file->minor->kdev->devt),
                  atomic_read(&dev->open_count));
 
+#ifdef CONFIG_DRM_LEGACY
        if (drm_core_check_feature(dev, DRIVER_LEGACY) &&
            dev->driver->preclose)
                dev->driver->preclose(dev, file);
+#endif
 
        if (drm_core_check_feature(dev, DRIVER_LEGACY))
                drm_legacy_lock_release(dev, file->filp);
index f135b79593dd206149223336550a51a2a52f489f..d30e2f2b8f3c47bf13d9e7bb531f676537ca2806 100644 (file)
@@ -209,9 +209,12 @@ static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 
                if (crtc->funcs->get_vblank_counter)
                        return crtc->funcs->get_vblank_counter(crtc);
-       } else if (dev->driver->get_vblank_counter) {
+       }
+#ifdef CONFIG_DRM_LEGACY
+       else if (dev->driver->get_vblank_counter) {
                return dev->driver->get_vblank_counter(dev, pipe);
        }
+#endif
 
        return drm_vblank_no_hw_counter(dev, pipe);
 }
@@ -429,9 +432,12 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
 
                if (crtc->funcs->disable_vblank)
                        crtc->funcs->disable_vblank(crtc);
-       } else {
+       }
+#ifdef CONFIG_DRM_LEGACY
+       else {
                dev->driver->disable_vblank(dev, pipe);
        }
+#endif
 }
 
 /*
@@ -1096,9 +1102,12 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
 
                if (crtc->funcs->enable_vblank)
                        return crtc->funcs->enable_vblank(crtc);
-       } else if (dev->driver->enable_vblank) {
+       }
+#ifdef CONFIG_DRM_LEGACY
+       else if (dev->driver->enable_vblank) {
                return dev->driver->enable_vblank(dev, pipe);
        }
+#endif
 
        return -EINVAL;
 }
index 023076255a7fd56ae6ba6e7e3fc8ccc4af4b9587..f0cb4ee6c851a023073a3f9d429078be90f3b69a 100644 (file)
@@ -495,6 +495,7 @@ struct drm_driver {
         */
        const struct file_operations *fops;
 
+#ifdef CONFIG_DRM_LEGACY
        /* Everything below here is for legacy driver, never use! */
        /* private: */
 
@@ -509,6 +510,7 @@ struct drm_driver {
        int (*enable_vblank)(struct drm_device *dev, unsigned int pipe);
        void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
        int dev_priv_size;
+#endif
 };
 
 void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,