drm/sti: Fix sparse warnings
[cascardo/linux.git] / drivers / gpu / drm / sti / sti_gdp.c
index ff33c38..27b617d 100644 (file)
@@ -208,14 +208,8 @@ static int gdp_dbg_show(struct seq_file *s, void *data)
 {
        struct drm_info_node *node = s->private;
        struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
-       struct drm_device *dev = node->minor->dev;
        struct drm_plane *drm_plane = &gdp->plane.drm_plane;
        struct drm_crtc *crtc = drm_plane->crtc;
-       int ret;
-
-       ret = mutex_lock_interruptible(&dev->struct_mutex);
-       if (ret)
-               return ret;
 
        seq_printf(s, "%s: (vaddr = 0x%p)",
                   sti_plane_to_str(&gdp->plane), gdp->regs);
@@ -248,7 +242,6 @@ static int gdp_dbg_show(struct seq_file *s, void *data)
                seq_printf(s, "  Connected to DRM CRTC #%d (%s)\n",
                           crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)));
 
-       mutex_unlock(&dev->struct_mutex);
        return 0;
 }
 
@@ -279,13 +272,7 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg)
 {
        struct drm_info_node *node = s->private;
        struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
-       struct drm_device *dev = node->minor->dev;
        unsigned int b;
-       int ret;
-
-       ret = mutex_lock_interruptible(&dev->struct_mutex);
-       if (ret)
-               return ret;
 
        for (b = 0; b < GDP_NODE_NB_BANK; b++) {
                seq_printf(s, "\n%s[%d].top", sti_plane_to_str(&gdp->plane), b);
@@ -294,7 +281,6 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg)
                gdp_node_dump_node(s, gdp->node_list[b].btm_field);
        }
 
-       mutex_unlock(&dev->struct_mutex);
        return 0;
 }
 
@@ -487,8 +473,8 @@ static void sti_gdp_disable(struct sti_gdp *gdp)
  * RETURNS:
  * 0 on success.
  */
-int sti_gdp_field_cb(struct notifier_block *nb,
-               unsigned long event, void *data)
+static int sti_gdp_field_cb(struct notifier_block *nb,
+                           unsigned long event, void *data)
 {
        struct sti_gdp *gdp = container_of(nb, struct sti_gdp, vtg_field_nb);
 
@@ -733,7 +719,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
        u32 dma_updated_top;
        u32 dma_updated_btm;
        int format;
-       unsigned int depth, bpp;
+       unsigned int bpp;
        u32 ydo, xdo, yds, xds;
 
        if (!crtc || !fb)
@@ -772,9 +758,9 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
                         (unsigned long)cma_obj->paddr);
 
        /* pixel memory location */
-       drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
+       bpp = drm_format_plane_cpp(fb->pixel_format, 0);
        top_field->gam_gdp_pml = (u32)cma_obj->paddr + fb->offsets[0];
-       top_field->gam_gdp_pml += src_x * (bpp >> 3);
+       top_field->gam_gdp_pml += src_x * bpp;
        top_field->gam_gdp_pml += src_y * fb->pitches[0];
 
        /* output parameters (clamped / cropped) */
@@ -880,6 +866,33 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = {
        .atomic_disable = sti_gdp_atomic_disable,
 };
 
+static void sti_gdp_destroy(struct drm_plane *drm_plane)
+{
+       DRM_DEBUG_DRIVER("\n");
+
+       drm_plane_helper_disable(drm_plane);
+       drm_plane_cleanup(drm_plane);
+}
+
+static int sti_gdp_late_register(struct drm_plane *drm_plane)
+{
+       struct sti_plane *plane = to_sti_plane(drm_plane);
+       struct sti_gdp *gdp = to_sti_gdp(plane);
+
+       return gdp_debugfs_init(gdp, drm_plane->dev->primary);
+}
+
+static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
+       .update_plane = drm_atomic_helper_update_plane,
+       .disable_plane = drm_atomic_helper_disable_plane,
+       .destroy = sti_gdp_destroy,
+       .set_property = drm_atomic_helper_plane_set_property,
+       .reset = sti_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+       .late_register = sti_gdp_late_register,
+};
+
 struct drm_plane *sti_gdp_create(struct drm_device *drm_dev,
                                 struct device *dev, int desc,
                                 void __iomem *baseaddr,
@@ -906,7 +919,7 @@ struct drm_plane *sti_gdp_create(struct drm_device *drm_dev,
 
        res = drm_universal_plane_init(drm_dev, &gdp->plane.drm_plane,
                                       possible_crtcs,
-                                      &sti_plane_helpers_funcs,
+                                      &sti_gdp_plane_helpers_funcs,
                                       gdp_supported_formats,
                                       ARRAY_SIZE(gdp_supported_formats),
                                       type, NULL);
@@ -919,9 +932,6 @@ struct drm_plane *sti_gdp_create(struct drm_device *drm_dev,
 
        sti_plane_init_property(&gdp->plane, type);
 
-       if (gdp_debugfs_init(gdp, drm_dev->primary))
-               DRM_ERROR("GDP debugfs setup failed\n");
-
        return &gdp->plane.drm_plane;
 
 err: