diff mbox

[RFC,3/3] drm/tilcdc: Adapt to bridge object refcounting

Message ID 9e7ececc0e0954e9608cfcd5e173adda0de6594b.1480603126.git.jsarha@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jyri Sarha Dec. 1, 2016, 3:52 p.m. UTC
Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 80184f0..31c6092 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -154,8 +154,10 @@  void tilcdc_remove_external_device(struct drm_device *dev)
 		drm_connector_helper_add(priv->external_connector,
 					 priv->connector_funcs);
 
-	if (priv->external_encoder && priv->external_encoder->bridge)
+	if (priv->external_encoder && priv->external_encoder->bridge) {
 		drm_bridge_detach(priv->external_encoder->bridge);
+		drm_bridge_put(priv->external_encoder->bridge);
+	}
 }
 
 static const struct drm_encoder_funcs tilcdc_external_encoder_funcs = {
@@ -234,7 +236,7 @@  int tilcdc_attach_external_device(struct drm_device *ddev)
 	if (!remote_node)
 		return 0;
 
-	bridge = of_drm_find_bridge(remote_node);
+	bridge = of_drm_get_bridge(remote_node);
 	of_node_put(remote_node);
 	if (!bridge)
 		return -EPROBE_DEFER;
@@ -242,20 +244,25 @@  int tilcdc_attach_external_device(struct drm_device *ddev)
 	priv->external_encoder = devm_kzalloc(ddev->dev,
 					      sizeof(*priv->external_encoder),
 					      GFP_KERNEL);
-	if (!priv->external_encoder)
+	if (!priv->external_encoder) {
+		drm_bridge_put(bridge);
 		return -ENOMEM;
+	}
 
 	ret = drm_encoder_init(ddev, priv->external_encoder,
 			       &tilcdc_external_encoder_funcs,
 			       DRM_MODE_ENCODER_NONE, NULL);
 	if (ret) {
 		dev_err(ddev->dev, "drm_encoder_init() failed %d\n", ret);
+		drm_bridge_put(bridge);
 		return ret;
 	}
 
 	ret = tilcdc_attach_bridge(ddev, bridge);
-	if (ret)
+	if (ret) {
 		drm_encoder_cleanup(priv->external_encoder);
+		drm_bridge_put(bridge);
+	}
 
 	return ret;
 }