drm/i915: properly check for MODESET for kms driver ioctls
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 24 Apr 2012 07:55:08 +0000 (09:55 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 3 May 2012 09:18:13 +0000 (11:18 +0200)
Also ditch the cargo-culted dev_priv checks - either we have a
giant hole in our setup code or this is useless. Plainly bogus
to check for it in either case.

v2: Chris Wilson noticed that I've missed one bogus dev_priv check.

v3: The check in the overlay code is redundant (Chris)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_overlay.c
drivers/gpu/drm/i915/intel_sprite.c

index cf9dfcd7a94f594a134efa4dc4add488bc940d82..e1716be476565576c0f074a1968eee40c42b16b8 100644 (file)
@@ -6189,15 +6189,12 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
 int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
                                struct drm_file *file)
 {
-       drm_i915_private_t *dev_priv = dev->dev_private;
        struct drm_i915_get_pipe_from_crtc_id *pipe_from_crtc_id = data;
        struct drm_mode_object *drmmode_obj;
        struct intel_crtc *crtc;
 
-       if (!dev_priv) {
-               DRM_ERROR("called with no initialization\n");
-               return -EINVAL;
-       }
+       if (!drm_core_check_feature(dev, DRIVER_MODESET))
+               return -ENODEV;
 
        drmmode_obj = drm_mode_object_find(dev, pipe_from_crtc_id->crtc_id,
                        DRM_MODE_OBJECT_CRTC);
index 0f0fe31fc466d7e1af91223666d0f1c915621310..a0b5053c5a32761232009b21798a3ca3d62843c2 100644 (file)
@@ -1122,11 +1122,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
        struct put_image_params *params;
        int ret;
 
-       if (!dev_priv) {
-               DRM_ERROR("called with no initialization\n");
-               return -EINVAL;
-       }
-
+       /* No need to check for DRIVER_MODESET - we don't set it up then. */
        overlay = dev_priv->overlay;
        if (!overlay) {
                DRM_DEBUG("userspace bug: no overlay\n");
@@ -1323,11 +1319,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
        struct overlay_registers __iomem *regs;
        int ret;
 
-       if (!dev_priv) {
-               DRM_ERROR("called with no initialization\n");
-               return -EINVAL;
-       }
-
+       /* No need to check for DRIVER_MODESET - we don't set it up then. */
        overlay = dev_priv->overlay;
        if (!overlay) {
                DRM_DEBUG("userspace bug: no overlay\n");
index 44315674f4722ca6b53debbed67cd345224d17ab..2a20fb0781d7591018fdb7202d96ee7685e9cbba 100644 (file)
@@ -558,14 +558,13 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
                              struct drm_file *file_priv)
 {
        struct drm_intel_sprite_colorkey *set = data;
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_mode_object *obj;
        struct drm_plane *plane;
        struct intel_plane *intel_plane;
        int ret = 0;
 
-       if (!dev_priv)
-               return -EINVAL;
+       if (!drm_core_check_feature(dev, DRIVER_MODESET))
+               return -ENODEV;
 
        /* Make sure we don't try to enable both src & dest simultaneously */
        if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE))
@@ -592,14 +591,13 @@ int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
                              struct drm_file *file_priv)
 {
        struct drm_intel_sprite_colorkey *get = data;
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_mode_object *obj;
        struct drm_plane *plane;
        struct intel_plane *intel_plane;
        int ret = 0;
 
-       if (!dev_priv)
-               return -EINVAL;
+       if (!drm_core_check_feature(dev, DRIVER_MODESET))
+               return -ENODEV;
 
        mutex_lock(&dev->mode_config.mutex);