]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/gpu/drm/tinydrm/ili9225.c
drm/tinydrm: Use drm_dev_enter/exit()
[linux.git] / drivers / gpu / drm / tinydrm / ili9225.c
index 4d387a07c48bdb2de6a518dc98789ce654a77a22..0e9fde47b53bf67a95e1a10d163da32ea7828852 100644 (file)
@@ -89,13 +89,16 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
        bool swap = mipi->swap_bytes;
        u16 x_start, y_start;
        u16 x1, x2, y1, y2;
-       int ret = 0;
+       int idx, ret = 0;
        bool full;
        void *tr;
 
        if (!mipi->enabled)
                return;
 
+       if (!drm_dev_enter(fb->dev, &idx))
+               return;
+
        full = width == fb->width && height == fb->height;
 
        DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect));
@@ -158,6 +161,8 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
 err_msg:
        if (ret)
                dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
+
+       drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -191,9 +196,12 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
                .y1 = 0,
                .y2 = fb->height,
        };
-       int ret;
+       int ret, idx;
        u8 am_id;
 
+       if (!drm_dev_enter(pipe->crtc.dev, &idx))
+               return;
+
        DRM_DEBUG_KMS("\n");
 
        mipi_dbi_hw_reset(mipi);
@@ -207,7 +215,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
        ret = ili9225_command(mipi, ILI9225_POWER_CONTROL_1, 0x0000);
        if (ret) {
                DRM_DEV_ERROR(dev, "Error sending command %d\n", ret);
-               return;
+               goto out_exit;
        }
        ili9225_command(mipi, ILI9225_POWER_CONTROL_2, 0x0000);
        ili9225_command(mipi, ILI9225_POWER_CONTROL_3, 0x0000);
@@ -280,6 +288,8 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 
        mipi->enabled = true;
        ili9225_fb_dirty(fb, &rect);
+out_exit:
+       drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
@@ -288,6 +298,13 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
 
        DRM_DEBUG_KMS("\n");
 
+       /*
+        * This callback is not protected by drm_dev_enter/exit since we want to
+        * turn off the display on regular driver unload. It's highly unlikely
+        * that the underlying SPI controller is gone should this be called after
+        * unplug.
+        */
+
        if (!mipi->enabled)
                return;