[PATCH v6 23/26] drm/bridge: samsung-dsim: use refcounting for the out_bridge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case the samsung-dsim is fixed and the following bridge is
hot-unplugged, we need to handle the dynamic lifetime of the following
bridge by putting the reference when disposing of it.

The devm functions used to get the next bridge reference will put it only
when this device is removed. Do it explicitly on detach and in the error
paths.

Signed-off-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>

---

Changed in v6:
 - use new devm_drm_put[_and_clear]_bridge()

This patch was added in v5.
---
 drivers/gpu/drm/bridge/samsung-dsim.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
index bbd0a4f5a3f52b61bf48f10d6e8ca741bffa5e46..8e94f099d67bee93655129625b40d4c1af023fcc 100644
--- a/drivers/gpu/drm/bridge/samsung-dsim.c
+++ b/drivers/gpu/drm/bridge/samsung-dsim.c
@@ -1732,13 +1732,13 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host,
 	if (!(device->mode_flags & MIPI_DSI_MODE_VIDEO)) {
 		ret = samsung_dsim_register_te_irq(dsi, &device->dev);
 		if (ret)
-			return ret;
+			goto err_devm_put_bridge;
 	}
 
 	if (pdata->host_ops && pdata->host_ops->attach) {
 		ret = pdata->host_ops->attach(dsi, device);
 		if (ret)
-			return ret;
+			goto err_devm_put_bridge;
 	}
 
 	dsi->lanes = device->lanes;
@@ -1748,6 +1748,10 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host,
 	dsi->out_bridge = out_bridge;
 
 	return 0;
+
+err_devm_put_bridge:
+	devm_drm_put_bridge(dev, out_bridge);
+	return ret;
 }
 
 static void samsung_dsim_unregister_te_irq(struct samsung_dsim *dsi)
@@ -1764,7 +1768,7 @@ static int samsung_dsim_host_detach(struct mipi_dsi_host *host,
 	struct samsung_dsim *dsi = host_to_dsi(host);
 	const struct samsung_dsim_plat_data *pdata = dsi->plat_data;
 
-	dsi->out_bridge = NULL;
+	devm_drm_put_and_clear_bridge(dsi->dev, &dsi->out_bridge);
 
 	if (pdata->host_ops && pdata->host_ops->detach)
 		pdata->host_ops->detach(dsi, device);

-- 
2.34.1





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux