MLK-17275-3: drm/bridge: nwl-dsi: Fix remove/detach
authorRobert Chiras <robert.chiras@nxp.com>
Thu, 21 Dec 2017 09:06:44 +0000 (11:06 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:52:42 +0000 (14:52 -0500)
Add a check in detach function, so that the mipi_dsi_host_unregister
will occur only if the host was registered.
Also, remove the unnecessary calls to host_unregister from probe and
remove functions.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
drivers/gpu/drm/bridge/nwl-dsi.c

index fc05165..9b40b38 100644 (file)
@@ -1000,11 +1000,14 @@ static void nwl_dsi_bridge_detach(struct drm_bridge *bridge)
        if (dsi->panel) {
                drm_panel_detach(dsi->panel);
                drm_connector_cleanup(&dsi->connector);
+               dsi->panel = NULL;
        } else if (dsi->next_bridge) {
                drm_bridge_detach(dsi->next_bridge);
                nwl_dsi_del_bridge(dsi->next_bridge->encoder, dsi->next_bridge);
+               dsi->next_bridge = NULL;
        }
-       mipi_dsi_host_unregister(&dsi->host);
+       if (dsi->host.dev)
+               mipi_dsi_host_unregister(&dsi->host);
 }
 
 static void nwl_dsi_bridge_enable(struct drm_bridge *bridge)
@@ -1171,24 +1174,17 @@ static int nwl_dsi_probe(struct platform_device *pdev)
        dsi->bridge.of_node = dev->of_node;
 
        ret = drm_bridge_add(&dsi->bridge);
-       if (ret < 0) {
+       if (ret < 0)
                dev_err(dev, "Failed to add nwl-dsi bridge (%d)\n", ret);
-               goto err_host;
-       }
 
-       return 0;
-
-err_host:
-       mipi_dsi_host_unregister(&dsi->host);
        return ret;
-
 }
 
 static int nwl_dsi_remove(struct platform_device *pdev)
 {
        struct nwl_mipi_dsi *dsi = platform_get_drvdata(pdev);
 
-       mipi_dsi_host_unregister(&dsi->host);
+       drm_bridge_remove(&dsi->bridge);
 
        return 0;
 }