Commit 719093a6 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Rob Clark

drm/msm/hdmi: switch to devm_drm_bridge_add()

Make MSM HDMI 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/561635/Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 5f403fd7
...@@ -160,24 +160,16 @@ static int msm_hdmi_init(struct hdmi *hdmi) ...@@ -160,24 +160,16 @@ static int msm_hdmi_init(struct hdmi *hdmi)
int msm_hdmi_modeset_init(struct hdmi *hdmi, int msm_hdmi_modeset_init(struct hdmi *hdmi,
struct drm_device *dev, struct drm_encoder *encoder) struct drm_device *dev, 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;
}
hdmi->dev = dev; hdmi->dev = dev;
hdmi->encoder = encoder; hdmi->encoder = encoder;
hdmi_audio_infoframe_init(&hdmi->audio.infoframe); hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
hdmi->bridge = msm_hdmi_bridge_init(hdmi); ret = msm_hdmi_bridge_init(hdmi);
if (IS_ERR(hdmi->bridge)) { if (ret) {
ret = PTR_ERR(hdmi->bridge);
DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret); DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret);
hdmi->bridge = NULL;
goto fail; goto fail;
} }
...@@ -215,16 +207,9 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, ...@@ -215,16 +207,9 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
goto fail; goto fail;
} }
priv->bridges[priv->num_bridges++] = hdmi->bridge;
return 0; return 0;
fail: fail:
/* bridge is normally destroyed by drm: */
if (hdmi->bridge) {
msm_hdmi_bridge_destroy(hdmi->bridge);
hdmi->bridge = NULL;
}
if (hdmi->connector) { if (hdmi->connector) {
hdmi->connector->funcs->destroy(hdmi->connector); hdmi->connector->funcs->destroy(hdmi->connector);
hdmi->connector = NULL; hdmi->connector = NULL;
...@@ -395,6 +380,9 @@ static void msm_hdmi_unbind(struct device *dev, struct device *master, ...@@ -395,6 +380,9 @@ static void msm_hdmi_unbind(struct device *dev, struct device *master,
if (priv->hdmi->audio_pdev) if (priv->hdmi->audio_pdev)
platform_device_unregister(priv->hdmi->audio_pdev); platform_device_unregister(priv->hdmi->audio_pdev);
if (priv->hdmi->bridge)
msm_hdmi_hpd_disable(priv->hdmi);
msm_hdmi_destroy(priv->hdmi); msm_hdmi_destroy(priv->hdmi);
priv->hdmi = NULL; priv->hdmi = NULL;
} }
......
...@@ -224,14 +224,13 @@ void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate); ...@@ -224,14 +224,13 @@ void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
* hdmi bridge: * hdmi bridge:
*/ */
struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi); int msm_hdmi_bridge_init(struct hdmi *hdmi);
void msm_hdmi_bridge_destroy(struct drm_bridge *bridge);
void msm_hdmi_hpd_irq(struct drm_bridge *bridge); void msm_hdmi_hpd_irq(struct drm_bridge *bridge);
enum drm_connector_status msm_hdmi_bridge_detect( enum drm_connector_status msm_hdmi_bridge_detect(
struct drm_bridge *bridge); struct drm_bridge *bridge);
int msm_hdmi_hpd_enable(struct drm_bridge *bridge); int msm_hdmi_hpd_enable(struct drm_bridge *bridge);
void msm_hdmi_hpd_disable(struct hdmi_bridge *hdmi_bridge); void msm_hdmi_hpd_disable(struct hdmi *hdmi);
/* /*
* i2c adapter for ddc: * i2c adapter for ddc:
......
...@@ -11,14 +11,6 @@ ...@@ -11,14 +11,6 @@
#include "msm_kms.h" #include "msm_kms.h"
#include "hdmi.h" #include "hdmi.h"
void msm_hdmi_bridge_destroy(struct drm_bridge *bridge)
{
struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge);
msm_hdmi_hpd_disable(hdmi_bridge);
drm_bridge_remove(bridge);
}
static void msm_hdmi_power_on(struct drm_bridge *bridge) static void msm_hdmi_power_on(struct drm_bridge *bridge)
{ {
struct drm_device *dev = bridge->dev; struct drm_device *dev = bridge->dev;
...@@ -317,7 +309,7 @@ msm_hdmi_hotplug_work(struct work_struct *work) ...@@ -317,7 +309,7 @@ msm_hdmi_hotplug_work(struct work_struct *work)
} }
/* initialize bridge */ /* initialize bridge */
struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) int msm_hdmi_bridge_init(struct hdmi *hdmi)
{ {
struct drm_bridge *bridge = NULL; struct drm_bridge *bridge = NULL;
struct hdmi_bridge *hdmi_bridge; struct hdmi_bridge *hdmi_bridge;
...@@ -325,10 +317,8 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) ...@@ -325,10 +317,8 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi)
hdmi_bridge = devm_kzalloc(hdmi->dev->dev, hdmi_bridge = devm_kzalloc(hdmi->dev->dev,
sizeof(*hdmi_bridge), GFP_KERNEL); sizeof(*hdmi_bridge), GFP_KERNEL);
if (!hdmi_bridge) { if (!hdmi_bridge)
ret = -ENOMEM; return -ENOMEM;
goto fail;
}
hdmi_bridge->hdmi = hdmi; hdmi_bridge->hdmi = hdmi;
INIT_WORK(&hdmi_bridge->hpd_work, msm_hdmi_hotplug_work); INIT_WORK(&hdmi_bridge->hpd_work, msm_hdmi_hotplug_work);
...@@ -341,17 +331,15 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) ...@@ -341,17 +331,15 @@ struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi)
DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_DETECT |
DRM_BRIDGE_OP_EDID; DRM_BRIDGE_OP_EDID;
drm_bridge_add(bridge); ret = devm_drm_bridge_add(&hdmi->pdev->dev, bridge);
if (ret)
return ret;
ret = drm_bridge_attach(hdmi->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR); ret = drm_bridge_attach(hdmi->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret) if (ret)
goto fail; return ret;
return bridge; hdmi->bridge = bridge;
fail: return 0;
if (bridge)
msm_hdmi_bridge_destroy(bridge);
return ERR_PTR(ret);
} }
...@@ -147,9 +147,8 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge) ...@@ -147,9 +147,8 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)
return ret; return ret;
} }
void msm_hdmi_hpd_disable(struct hdmi_bridge *hdmi_bridge) void msm_hdmi_hpd_disable(struct hdmi *hdmi)
{ {
struct hdmi *hdmi = hdmi_bridge->hdmi;
const struct hdmi_platform_config *config = hdmi->config; const struct hdmi_platform_config *config = hdmi->config;
struct device *dev = &hdmi->pdev->dev; struct device *dev = &hdmi->pdev->dev;
int ret; int ret;
......
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