Skip to contentSkip to conversation

drm/bridge: ti-sn65dsi83: Implement .detach callback

PATCH Applied Marek Vasut 2 participants 4 messages Sep 7, 2021 – Oct 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bridge: ti-sn65dsi83: Implement .detach callback

Move detach implementation from sn65dsi83_remove() to dedicated .detach callback. There is no functional change to the code, but that detach is now in the correct location.

Cc Jagan Teki <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Robert Foss <[email protected]>
Cc Sam Ravnborg <[email protected]>
---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +14 -3
index 4ea71d7f0bfbc..13ee313daba96 100644
@@ -288,6 +288,19 @@ static int sn65dsi83_attach(struct drm_bridge *bridge,
 	return ret;
 }
 
+static void sn65dsi83_detach(struct drm_bridge *bridge)
+{
+	struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+
+	if (!ctx->dsi)
+		return;
+
+	mipi_dsi_detach(ctx->dsi);
+	mipi_dsi_device_unregister(ctx->dsi);
+	drm_bridge_remove(&ctx->bridge);
+	ctx->dsi = NULL;
+}
+
 static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,
 					struct drm_bridge_state *old_bridge_state)
 {
@@ -588,6 +601,7 @@ sn65dsi83_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 
 static const struct drm_bridge_funcs sn65dsi83_funcs = {
 	.attach			= sn65dsi83_attach,
+	.detach			= sn65dsi83_detach,
 	.atomic_pre_enable	= sn65dsi83_atomic_pre_enable,
 	.atomic_enable		= sn65dsi83_atomic_enable,
 	.atomic_disable		= sn65dsi83_atomic_disable,
@@ -702,9 +716,6 @@ static int sn65dsi83_remove(struct i2c_client *client)
 {
 	struct sn65dsi83 *ctx = i2c_get_clientdata(client);
 
-	mipi_dsi_detach(ctx->dsi);
-	mipi_dsi_device_unregister(ctx->dsi);
-	drm_bridge_remove(&ctx->bridge);
 	of_node_put(ctx->host_node);
 
 	return 0;
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line
Quoted 2 lines · Marek Vasut

Move detach implementation from sn65dsi83_remove() to dedicated

.detach callback. There is no functional change to the code, but

Quoted 22 lines

that detach is now in the correct location.

Cc Jagan Teki <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Robert Foss <[email protected]>
Cc Sam Ravnborg <[email protected]>
---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +1 -0
index 4ea71d7f0bfbc..13ee313daba96 100644
@@ -288,6 +288,19 @@ static int sn65dsi83_attach(struct drm_bridge *bridge,
        return ret;
 }
 
+static void sn65dsi83_detach(struct drm_bridge *bridge)

drivers/gpu/drm/bridge/ti-sn65dsi83.c static int sn65dsi83_attach(struct drm_bridge *bridge, · line 301

Quoted 10 lines
drivers/gpu/drm/bridge/ti-sn65dsi83.c +10 -0
+{
+       struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+
+       if (!ctx->dsi)
+               return;
+
+       mipi_dsi_detach(ctx->dsi);
+       mipi_dsi_device_unregister(ctx->dsi);
+       drm_bridge_remove(&ctx->bridge);
+       ctx->dsi = NULL;

Is this assignment necessary? I'm not seeing it in the other drivers.

WIth this cleared up feel free to add my r-b.

#2 lore raw
Quoted 40 lines · Robert Foss
Quoted 1 line
Quoted 2 lines · Marek Vasut

Move detach implementation from sn65dsi83_remove() to dedicated

.detach callback. There is no functional change to the code, but

Quoted 22 lines

that detach is now in the correct location.

Cc Jagan Teki <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Robert Foss <[email protected]>
Cc Sam Ravnborg <[email protected]>
---
  drivers/gpu/drm/bridge/ti-sn65dsi83.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +1 -0
index 4ea71d7f0bfbc..13ee313daba96 100644
@@ -288,6 +288,19 @@ static int sn65dsi83_attach(struct drm_bridge *bridge,
         return ret;
  }
 
+static void sn65dsi83_detach(struct drm_bridge *bridge)

drivers/gpu/drm/bridge/ti-sn65dsi83.c static int sn65dsi83_attach(struct drm_bridge *bridge, · line 301

Quoted 10 lines
drivers/gpu/drm/bridge/ti-sn65dsi83.c +10 -0
+{
+       struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+
+       if (!ctx->dsi)
+               return;
+
+       mipi_dsi_detach(ctx->dsi);
+       mipi_dsi_device_unregister(ctx->dsi);
+       drm_bridge_remove(&ctx->bridge);
+       ctx->dsi = NULL;

Is this assignment necessary? I'm not seeing it in the other drivers.

Quoted 2 lines

WIth this cleared up feel free to add my r-b.

It works in tandem with the if (!ctx->dsi) return; at the beginning to prevent crash in case the detach callback was called multiple times for whatever reason.

Applied
#3 lore raw

Applied to drm-misc-next

Quoted 48 lines · Marek Vasut
Quoted 40 lines · Robert Foss
Quoted 1 line
Quoted 2 lines · Marek Vasut

Move detach implementation from sn65dsi83_remove() to dedicated

.detach callback. There is no functional change to the code, but

Quoted 22 lines

that detach is now in the correct location.

Cc Jagan Teki <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Robert Foss <[email protected]>
Cc Sam Ravnborg <[email protected]>
---
  drivers/gpu/drm/bridge/ti-sn65dsi83.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +1 -0
index 4ea71d7f0bfbc..13ee313daba96 100644
@@ -288,6 +288,19 @@ static int sn65dsi83_attach(struct drm_bridge *bridge,
         return ret;
  }
 
+static void sn65dsi83_detach(struct drm_bridge *bridge)

drivers/gpu/drm/bridge/ti-sn65dsi83.c static int sn65dsi83_attach(struct drm_bridge *bridge, · line 301

Quoted 10 lines
drivers/gpu/drm/bridge/ti-sn65dsi83.c +10 -0
+{
+       struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
+
+       if (!ctx->dsi)
+               return;
+
+       mipi_dsi_detach(ctx->dsi);
+       mipi_dsi_device_unregister(ctx->dsi);
+       drm_bridge_remove(&ctx->bridge);
+       ctx->dsi = NULL;

Is this assignment necessary? I'm not seeing it in the other drivers.

Quoted 2 lines

WIth this cleared up feel free to add my r-b.

It works in tandem with the if (!ctx->dsi) return; at the beginning to prevent crash in case the detach callback was called multiple times for whatever reason.