drm/atomic: Avoid connector to writeback_connector casts
authorBoris Brezillon <boris.brezillon@bootlin.com>
Tue, 3 Jul 2018 07:50:15 +0000 (09:50 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Sat, 7 Jul 2018 05:51:19 +0000 (07:51 +0200)
Use container_of() instead of type casting so that it keeps working
even if base is moved inside the drm_writeback_connector struct.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20180703075022.15138-2-boris.brezillon@bootlin.com
drivers/gpu/drm/drm_atomic.c
include/drm/drm_writeback.h

index e6062c779aaf85d6b58842b921fb4a2677e8e95c..3eb061e11e2efb2caa36738b6425d2f789c19f6d 100644 (file)
@@ -2428,6 +2428,7 @@ static int prepare_signaling(struct drm_device *dev,
        }
 
        for_each_new_connector_in_state(state, conn, conn_state, i) {
+               struct drm_writeback_connector *wb_conn;
                struct drm_writeback_job *job;
                struct drm_out_fence_state *f;
                struct dma_fence *fence;
@@ -2451,7 +2452,8 @@ static int prepare_signaling(struct drm_device *dev,
                f[*num_fences].out_fence_ptr = fence_ptr;
                *fence_state = f;
 
-               fence = drm_writeback_get_out_fence((struct drm_writeback_connector *)conn);
+               wb_conn = drm_connector_to_writeback(conn);
+               fence = drm_writeback_get_out_fence(wb_conn);
                if (!fence)
                        return -ENOMEM;
 
index a10fe556dfd459b6f63bc446728f4af33c82972f..23df9d46300328452bca14212be467d93ead539a 100644 (file)
@@ -110,6 +110,12 @@ struct drm_writeback_job {
        struct dma_fence *out_fence;
 };
 
+static inline struct drm_writeback_connector *
+drm_connector_to_writeback(struct drm_connector *connector)
+{
+       return container_of(connector, struct drm_writeback_connector, base);
+}
+
 int drm_writeback_connector_init(struct drm_device *dev,
                                 struct drm_writeback_connector *wb_connector,
                                 const struct drm_connector_funcs *con_funcs,