Instead, embed the drm_bridge structure into analogix_dp_core and use a container_of wrapper to access the latter. Signed-off-by: Mihail Atanassov <mihail.atanassov@xxxxxxx> --- .../drm/bridge/analogix/analogix_dp_core.c | 40 +++++++------------ .../drm/bridge/analogix/analogix_dp_core.h | 8 +++- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 6effe532f820..56ea3be27f2b 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1218,7 +1218,7 @@ static const struct drm_connector_funcs analogix_dp_connector_funcs = { static int analogix_dp_bridge_attach(struct drm_bridge *bridge) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_encoder *encoder = dp->encoder; struct drm_connector *connector = NULL; int ret = 0; @@ -1292,7 +1292,7 @@ struct drm_crtc *analogix_dp_get_new_crtc(struct analogix_dp_device *dp, static void analogix_dp_bridge_atomic_pre_enable(struct drm_bridge *bridge, struct drm_atomic_state *state) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state; int ret; @@ -1369,7 +1369,7 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) static void analogix_dp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_atomic_state *state) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state; int timeout_loop = 0; @@ -1406,7 +1406,7 @@ static void analogix_dp_bridge_atomic_enable(struct drm_bridge *bridge, static void analogix_dp_bridge_disable(struct drm_bridge *bridge) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); int ret; if (dp->dpms_mode != DRM_MODE_DPMS_ON) @@ -1443,7 +1443,7 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge) static void analogix_dp_bridge_atomic_disable(struct drm_bridge *bridge, struct drm_atomic_state *state) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_crtc *crtc; struct drm_crtc_state *new_crtc_state = NULL; @@ -1467,7 +1467,7 @@ static void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge, struct drm_atomic_state *state) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_crtc *crtc; struct drm_crtc_state *new_crtc_state; int ret; @@ -1489,7 +1489,7 @@ static void analogix_dp_bridge_mode_set(struct drm_bridge *bridge, const struct drm_display_mode *orig_mode, const struct drm_display_mode *mode) { - struct analogix_dp_device *dp = bridge->driver_private; + struct analogix_dp_device *dp = bridge_to_analogix_dp_device(bridge); struct drm_display_info *display_info = &dp->connector.display_info; struct video_info *video = &dp->video_info; struct device_node *dp_node = dp->dev->of_node; @@ -1571,28 +1571,16 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { .attach = analogix_dp_bridge_attach, }; -static int analogix_dp_create_bridge(struct drm_device *drm_dev, +static int analogix_dp_attach_bridge(struct drm_device *drm_dev, struct analogix_dp_device *dp) { - struct drm_bridge *bridge; int ret; - bridge = devm_kzalloc(drm_dev->dev, sizeof(*bridge), GFP_KERNEL); - if (!bridge) { - DRM_ERROR("failed to allocate for drm bridge\n"); - return -ENOMEM; - } - - dp->bridge = bridge; - - bridge->driver_private = dp; - bridge->funcs = &analogix_dp_bridge_funcs; + dp->bridge.funcs = &analogix_dp_bridge_funcs; - ret = drm_bridge_attach(dp->encoder, bridge, NULL); - if (ret) { - DRM_ERROR("failed to attach drm bridge\n"); + ret = drm_bridge_attach(dp->encoder, &dp->bridge, NULL); + if (ret) return -EINVAL; - } return 0; } @@ -1757,9 +1745,9 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, pm_runtime_enable(dev); - ret = analogix_dp_create_bridge(drm_dev, dp); + ret = analogix_dp_attach_bridge(drm_dev, dp); if (ret) { - DRM_ERROR("failed to create bridge (%d)\n", ret); + DRM_ERROR("failed to attach bridge (%d)\n", ret); goto err_disable_pm_runtime; } @@ -1775,7 +1763,7 @@ EXPORT_SYMBOL_GPL(analogix_dp_bind); void analogix_dp_unbind(struct analogix_dp_device *dp) { - analogix_dp_bridge_disable(dp->bridge); + analogix_dp_bridge_disable(&dp->bridge); dp->connector.funcs->destroy(&dp->connector); if (dp->plat_data->panel) { diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h index c051502d7fbf..aae4110c7bf9 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h @@ -9,6 +9,9 @@ #ifndef _ANALOGIX_DP_CORE_H #define _ANALOGIX_DP_CORE_H +#include <linux/kernel.h> + +#include <drm/drm_bridge.h> #include <drm/drm_crtc.h> #include <drm/drm_dp_helper.h> @@ -159,7 +162,7 @@ struct analogix_dp_device { struct device *dev; struct drm_device *drm_dev; struct drm_connector connector; - struct drm_bridge *bridge; + struct drm_bridge bridge; struct drm_dp_aux aux; struct clk *clock; unsigned int irq; @@ -180,6 +183,9 @@ struct analogix_dp_device { struct analogix_dp_plat_data *plat_data; }; +#define bridge_to_analogix_dp_device(b) \ + container_of((b), struct analogix_dp_device, bridge) + /* analogix_dp_reg.c */ void analogix_dp_enable_video_mute(struct analogix_dp_device *dp, bool enable); void analogix_dp_stop_video(struct analogix_dp_device *dp); -- 2.24.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel