enum pipe pipe,
                               enum intel_pipe_crc_source source)
 {
-       struct drm_device *dev = &dev_priv->drm;
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-       struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev, pipe);
+       struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
        enum intel_display_power_domain power_domain;
        u32 val = 0; /* shut up gcc */
        int ret;
 
                              struct timeval *vblank_time,
                              unsigned flags)
 {
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct intel_crtc *crtc;
 
-       if (pipe >= INTEL_INFO(dev)->num_pipes) {
+       if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
                DRM_ERROR("Invalid crtc %u\n", pipe);
                return -EINVAL;
        }
 
        /* Get drm_crtc to timestamp: */
-       crtc = intel_get_crtc_for_pipe(dev, pipe);
+       crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
        if (crtc == NULL) {
                DRM_ERROR("Invalid crtc %u\n", pipe);
                return -EINVAL;
 
                if (pipe_config->fdi_lanes <= 2)
                        return 0;
 
-               other_crtc = intel_get_crtc_for_pipe(dev, PIPE_C);
+               other_crtc = intel_get_crtc_for_pipe(dev_priv, PIPE_C);
                other_crtc_state =
                        intel_atomic_get_crtc_state(state, other_crtc);
                if (IS_ERR(other_crtc_state))
                        return -EINVAL;
                }
 
-               other_crtc = intel_get_crtc_for_pipe(dev, PIPE_B);
+               other_crtc = intel_get_crtc_for_pipe(dev_priv, PIPE_B);
                other_crtc_state =
                        intel_atomic_get_crtc_state(state, other_crtc);
                if (IS_ERR(other_crtc_state))
 int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
                     const struct dpll *dpll)
 {
-       struct intel_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+       struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
        struct intel_crtc_state *pipe_config;
 
        pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL);
 
 }
 
 static inline struct intel_crtc *
-intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
+intel_get_crtc_for_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        return dev_priv->pipe_to_crtc_mapping[pipe];
 }
 
 static inline struct intel_crtc *
-intel_get_crtc_for_plane(struct drm_device *dev, int plane)
+intel_get_crtc_for_plane(struct drm_i915_private *dev_priv, enum plane plane)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        return dev_priv->plane_to_crtc_mapping[plane];
 }
 
 static inline void
 intel_wait_for_vblank_if_active(struct drm_i915_private *dev_priv, int pipe)
 {
-       const struct intel_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+       const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 
        if (crtc->active)
                intel_wait_for_vblank(dev_priv, pipe);
 
                struct intel_crtc *crtc;
                int pipe = (dvo_val & DVO_PIPE_B_SELECT) ? 1 : 0;
 
-               crtc = intel_get_crtc_for_pipe(dev, pipe);
+               crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
                if (crtc) {
                        mode = intel_crtc_mode_get(dev, &crtc->base);
                        if (mode) {
 
                goto failed;
 
        pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
-       crtc = intel_get_crtc_for_pipe(dev, pipe);
+       crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
 
        if (crtc && (lvds & LVDS_PORT_EN)) {
                fixed_mode = intel_crtc_mode_get(dev, &crtc->base);
 
        int line_time_us, line_count;
        int entries, tlb_miss;
 
-       crtc = intel_get_crtc_for_plane(&dev_priv->drm, plane);
+       crtc = intel_get_crtc_for_plane(dev_priv, plane);
        if (!intel_crtc_active(crtc)) {
                *cursor_wm = cursor->guard_size;
                *plane_wm = display->guard_size;
                return false;
        }
 
-       crtc = intel_get_crtc_for_plane(&dev_priv->drm, plane);
+       crtc = intel_get_crtc_for_plane(dev_priv, plane);
        adjusted_mode = &crtc->config->base.adjusted_mode;
        fb = crtc->base.primary->state->fb;
        clock = adjusted_mode->crtc_clock;
 
 static void g4x_update_wm(struct intel_crtc *crtc)
 {
-       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        static const int sr_latency_ns = 12000;
-       struct drm_i915_private *dev_priv = to_i915(dev);
        int planea_wm, planeb_wm, cursora_wm, cursorb_wm;
        int plane_sr, cursor_sr;
        unsigned int enabled = 0;
                wm_info = &i830_a_wm_info;
 
        fifo_size = dev_priv->display.get_fifo_size(dev, 0);
-       crtc = intel_get_crtc_for_plane(dev, 0);
+       crtc = intel_get_crtc_for_plane(dev_priv, 0);
        if (intel_crtc_active(crtc)) {
                const struct drm_display_mode *adjusted_mode =
                        &crtc->config->base.adjusted_mode;
                wm_info = &i830_bc_wm_info;
 
        fifo_size = dev_priv->display.get_fifo_size(dev, 1);
-       crtc = intel_get_crtc_for_plane(dev, 1);
+       crtc = intel_get_crtc_for_plane(dev_priv, 1);
        if (intel_crtc_active(crtc)) {
                const struct drm_display_mode *adjusted_mode =
                        &crtc->config->base.adjusted_mode;