The I2C probe path creates a synthetic MIPI DSI device so the bridge can
attach to the upstream DSI host. That device is registered with
mipi_dsi_device_register_full(), but after a successful attach the I2C
driver has no remove callback or devres action that unregisters it.
devm_mipi_dsi_attach() only detaches the device; it does not unregister
the child device that was created by the driver.
Use devm_mipi_dsi_device_register_full() so the DSI device is
unregistered when the I2C device is unwound. The managed DSI attach is
registered after the managed DSI device, so devres releases them in the
right order: detach first, then unregister.
Fixes: 8dde6f7452a1 ("drm: bridge: icn6211: Add I2C configuration support")
Signed-off-by: Zhiqi Zhang <[email protected]>
---
AI assistance disclosure: I found the bug. Codex modified the code.
I reviewed the change.
Build-tested with ARCH=arm64 allmodconfig object builds.
I did not test on hardware.
drivers/gpu/drm/bridge/chipone-icn6211.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/bridge/chipone-icn6211.c
b/drivers/gpu/drm/bridge/chipone-icn6211.c
index 14eaae0745..0b3fa2c370 100644
--- a/drivers/gpu/drm/bridge/chipone-icn6211.c
+++ b/drivers/gpu/drm/bridge/chipone-icn6211.c
@@ -545,7 +545,6 @@ static int chipone_dsi_host_attach(struct chipone *icn)
struct device_node *endpoint;
struct mipi_dsi_device *dsi;
struct mipi_dsi_host *host;
- int ret = 0;
const struct mipi_dsi_device_info info = {
.type = "chipone",
@@ -565,7 +564,7 @@ static int chipone_dsi_host_attach(struct chipone *icn)
if (!host)
return dev_err_probe(dev, -EPROBE_DEFER, "failed to find dsi
host\n");
- dsi = mipi_dsi_device_register_full(host, &info);
+ dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
if (IS_ERR(dsi)) {
return dev_err_probe(dev, PTR_ERR(dsi),
"failed to create dsi device\n");
@@ -573,11 +572,7 @@ static int chipone_dsi_host_attach(struct chipone *icn)
icn->dsi = dsi;
- ret = chipone_dsi_attach(icn);
- if (ret < 0)
- mipi_dsi_device_unregister(dsi);
-
- return ret;
+ return chipone_dsi_attach(icn);
}
static int chipone_attach(struct drm_bridge *bridge,
--
2.54.0 (Apple Git-157)