Commit 5f403fd7 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Rob Clark

drm/msm/dsi: switch to devm_drm_bridge_add()

Make MSM DSI driver use devm_drm_bridge_add() instead of plain
drm_bridge_add(). As the driver doesn't require any additional cleanup,
stop adding created bridge to the priv->bridges array.
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/561636/Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 1f50db2f
...@@ -217,20 +217,14 @@ void __exit msm_dsi_unregister(void) ...@@ -217,20 +217,14 @@ void __exit msm_dsi_unregister(void)
int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
struct drm_encoder *encoder) struct drm_encoder *encoder)
{ {
struct msm_drm_private *priv = dev->dev_private;
int ret; int ret;
if (priv->num_bridges == ARRAY_SIZE(priv->bridges)) {
DRM_DEV_ERROR(dev->dev, "too many bridges\n");
return -ENOSPC;
}
msm_dsi->dev = dev; msm_dsi->dev = dev;
ret = msm_dsi_host_modeset_init(msm_dsi->host, dev); ret = msm_dsi_host_modeset_init(msm_dsi->host, dev);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev->dev, "failed to modeset init host: %d\n", ret); DRM_DEV_ERROR(dev->dev, "failed to modeset init host: %d\n", ret);
goto fail; return ret;
} }
if (msm_dsi_is_bonded_dsi(msm_dsi) && if (msm_dsi_is_bonded_dsi(msm_dsi) &&
...@@ -244,32 +238,20 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, ...@@ -244,32 +238,20 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
msm_dsi->encoder = encoder; msm_dsi->encoder = encoder;
msm_dsi->bridge = msm_dsi_manager_bridge_init(msm_dsi->id); ret = msm_dsi_manager_bridge_init(msm_dsi);
if (IS_ERR(msm_dsi->bridge)) { if (ret) {
ret = PTR_ERR(msm_dsi->bridge);
DRM_DEV_ERROR(dev->dev, "failed to create dsi bridge: %d\n", ret); DRM_DEV_ERROR(dev->dev, "failed to create dsi bridge: %d\n", ret);
msm_dsi->bridge = NULL; return ret;
goto fail;
} }
ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id); ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev->dev, DRM_DEV_ERROR(dev->dev,
"failed to create dsi connector: %d\n", ret); "failed to create dsi connector: %d\n", ret);
goto fail; return ret;
} }
priv->bridges[priv->num_bridges++] = msm_dsi->bridge;
return 0; return 0;
fail:
/* bridge/connector are normally destroyed by drm: */
if (msm_dsi->bridge) {
msm_dsi_manager_bridge_destroy(msm_dsi->bridge);
msm_dsi->bridge = NULL;
}
return ret;
} }
void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi) void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi)
......
...@@ -56,8 +56,7 @@ struct msm_dsi { ...@@ -56,8 +56,7 @@ struct msm_dsi {
}; };
/* dsi manager */ /* dsi manager */
struct drm_bridge *msm_dsi_manager_bridge_init(u8 id); int msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi);
void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
int msm_dsi_manager_ext_bridge_init(u8 id); int msm_dsi_manager_ext_bridge_init(u8 id);
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len); bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
......
...@@ -466,9 +466,8 @@ static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = { ...@@ -466,9 +466,8 @@ static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = {
}; };
/* initialize bridge */ /* initialize bridge */
struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) int msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi)
{ {
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
struct drm_bridge *bridge = NULL; struct drm_bridge *bridge = NULL;
struct dsi_bridge *dsi_bridge; struct dsi_bridge *dsi_bridge;
struct drm_encoder *encoder; struct drm_encoder *encoder;
...@@ -476,31 +475,27 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) ...@@ -476,31 +475,27 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id)
dsi_bridge = devm_kzalloc(msm_dsi->dev->dev, dsi_bridge = devm_kzalloc(msm_dsi->dev->dev,
sizeof(*dsi_bridge), GFP_KERNEL); sizeof(*dsi_bridge), GFP_KERNEL);
if (!dsi_bridge) { if (!dsi_bridge)
ret = -ENOMEM; return -ENOMEM;
goto fail;
}
dsi_bridge->id = id; dsi_bridge->id = msm_dsi->id;
encoder = msm_dsi->encoder; encoder = msm_dsi->encoder;
bridge = &dsi_bridge->base; bridge = &dsi_bridge->base;
bridge->funcs = &dsi_mgr_bridge_funcs; bridge->funcs = &dsi_mgr_bridge_funcs;
drm_bridge_add(bridge); ret = devm_drm_bridge_add(&msm_dsi->pdev->dev, bridge);
if (ret)
return ret;
ret = drm_bridge_attach(encoder, bridge, NULL, 0); ret = drm_bridge_attach(encoder, bridge, NULL, 0);
if (ret) if (ret)
goto fail; return ret;
return bridge; msm_dsi->bridge = bridge;
fail: return 0;
if (bridge)
msm_dsi_manager_bridge_destroy(bridge);
return ERR_PTR(ret);
} }
int msm_dsi_manager_ext_bridge_init(u8 id) int msm_dsi_manager_ext_bridge_init(u8 id)
...@@ -557,11 +552,6 @@ int msm_dsi_manager_ext_bridge_init(u8 id) ...@@ -557,11 +552,6 @@ int msm_dsi_manager_ext_bridge_init(u8 id)
return 0; return 0;
} }
void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge)
{
drm_bridge_remove(bridge);
}
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg) int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg)
{ {
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment