Re: [PATCH v2 38/60] drm/omap: dss: Cleanup error paths in output init functions

2018-06-10 Thread Sebastian Reichel
Hi,

On Sat, May 26, 2018 at 08:24:56PM +0300, Laurent Pinchart wrote:
> Rename the jump labels according to the cleanup they perform, not the
> location they're accessed from, and move functions from error checks to
> cleanup paths, and move reference handling to simplify cleanup.
> 
> Signed-off-by: Laurent Pinchart 
> ---

Reviewed-by: Sebastian Reichel 

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c   | 10 ++
>  drivers/gpu/drm/omapdrm/dss/dsi.c   |  9 -
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c |  7 ---
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c |  7 ---
>  drivers/gpu/drm/omapdrm/dss/sdi.c   |  7 ++-
>  drivers/gpu/drm/omapdrm/dss/venc.c  |  7 +++
>  6 files changed, 19 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
> b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 8a7c951a413c..e97f54d5f3e1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -745,15 +745,14 @@ int dpi_init_port(struct dss_device *dss, struct 
> platform_device *pdev,
>   return 0;
>  
>   r = of_property_read_u32(ep, "data-lines", );
> + of_node_put(ep);
>   if (r) {
>   DSSERR("failed to parse datalines\n");
> - goto err_datalines;
> + return r;
>   }
>  
>   dpi->data_lines = datalines;
>  
> - of_node_put(ep);
> -
>   dpi->pdev = pdev;
>   dpi->dss_model = dss_model;
>   dpi->dss = dss;
> @@ -764,11 +763,6 @@ int dpi_init_port(struct dss_device *dss, struct 
> platform_device *pdev,
>   dpi_init_output_port(dpi, port);
>  
>   return 0;
> -
> -err_datalines:
> - of_node_put(ep);
> -
> - return r;
>  }
>  
>  void dpi_uninit_port(struct device_node *port)
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
> b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index b3e50d8a7477..278094f29255 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5360,7 +5360,7 @@ static int dsi_bind(struct device *dev, struct device 
> *master, void *data)
>  
>   r = dsi_runtime_get(dsi);
>   if (r)
> - goto err_runtime_get;
> + goto err_pm_disable;
>  
>   rev = dsi_read_reg(dsi, DSI_REVISION);
>   dev_dbg(dev, "OMAP DSI rev %d.%d\n",
> @@ -5381,7 +5381,7 @@ static int dsi_bind(struct device *dev, struct device 
> *master, void *data)
>   r = dsi_probe_of(dsi);
>   if (r) {
>   DSSERR("Invalid DSI DT data\n");
> - goto err_probe_of;
> + goto err_uninit_output;
>   }
>  
>   r = of_platform_populate(dev->of_node, NULL, NULL, dev);
> @@ -5404,11 +5404,10 @@ static int dsi_bind(struct device *dev, struct device 
> *master, void *data)
>  
>   return 0;
>  
> -err_probe_of:
> +err_uninit_output:
>   dsi_uninit_output(dsi);
>   dsi_runtime_put(dsi);
> -
> -err_runtime_get:
> +err_pm_disable:
>   pm_runtime_disable(dev);
>   return r;
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index bf800cede2ad..1d1f2e0b2b2a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -780,9 +780,7 @@ static int hdmi4_bind(struct device *dev, struct device 
> *master, void *data)
>   r = hdmi_audio_register(hdmi);
>   if (r) {
>   DSSERR("Registering HDMI audio failed\n");
> - hdmi_uninit_output(hdmi);
> - pm_runtime_disable(>dev);
> - return r;
> + goto err_uninit_output;
>   }
>  
>   hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
> @@ -790,6 +788,9 @@ static int hdmi4_bind(struct device *dev, struct device 
> *master, void *data)
>  
>   return 0;
>  
> +err_uninit_output:
> + hdmi_uninit_output(hdmi);
> + pm_runtime_disable(>dev);
>  err_pll:
>   hdmi_pll_uninit(>pll);
>  err_free:
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index e5d23dd19f99..92ae561bf974 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -773,9 +773,7 @@ static int hdmi5_bind(struct device *dev, struct device 
> *master, void *data)
>   r = hdmi_audio_register(hdmi);
>   if (r) {
>   DSSERR("Registering HDMI audio failed %d\n", r);
> - hdmi_uninit_output(hdmi);
> - pm_runtime_disable(>dev);
> - return r;
> + goto err_uninit_output;
>   }
>  
>   hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
> @@ -783,6 +781,9 @@ static int hdmi5_bind(struct device *dev, struct device 
> *master, void *data)
>  
>   return 0;
>  
> +err_uninit_output:
> + hdmi_uninit_output(hdmi);
> + pm_runtime_disable(>dev);
>  err_pll:
>   hdmi_pll_uninit(>pll);
>  err_free:
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
> b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 

[PATCH v2 38/60] drm/omap: dss: Cleanup error paths in output init functions

2018-05-26 Thread Laurent Pinchart
Rename the jump labels according to the cleanup they perform, not the
location they're accessed from, and move functions from error checks to
cleanup paths, and move reference handling to simplify cleanup.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 10 ++
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  9 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  7 ---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  7 ---
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  7 ++-
 drivers/gpu/drm/omapdrm/dss/venc.c  |  7 +++
 6 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 8a7c951a413c..e97f54d5f3e1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -745,15 +745,14 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
return 0;
 
r = of_property_read_u32(ep, "data-lines", );
+   of_node_put(ep);
if (r) {
DSSERR("failed to parse datalines\n");
-   goto err_datalines;
+   return r;
}
 
dpi->data_lines = datalines;
 
-   of_node_put(ep);
-
dpi->pdev = pdev;
dpi->dss_model = dss_model;
dpi->dss = dss;
@@ -764,11 +763,6 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
dpi_init_output_port(dpi, port);
 
return 0;
-
-err_datalines:
-   of_node_put(ep);
-
-   return r;
 }
 
 void dpi_uninit_port(struct device_node *port)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b3e50d8a7477..278094f29255 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5360,7 +5360,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
r = dsi_runtime_get(dsi);
if (r)
-   goto err_runtime_get;
+   goto err_pm_disable;
 
rev = dsi_read_reg(dsi, DSI_REVISION);
dev_dbg(dev, "OMAP DSI rev %d.%d\n",
@@ -5381,7 +5381,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
r = dsi_probe_of(dsi);
if (r) {
DSSERR("Invalid DSI DT data\n");
-   goto err_probe_of;
+   goto err_uninit_output;
}
 
r = of_platform_populate(dev->of_node, NULL, NULL, dev);
@@ -5404,11 +5404,10 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
-err_probe_of:
+err_uninit_output:
dsi_uninit_output(dsi);
dsi_runtime_put(dsi);
-
-err_runtime_get:
+err_pm_disable:
pm_runtime_disable(dev);
return r;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index bf800cede2ad..1d1f2e0b2b2a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -780,9 +780,7 @@ static int hdmi4_bind(struct device *dev, struct device 
*master, void *data)
r = hdmi_audio_register(hdmi);
if (r) {
DSSERR("Registering HDMI audio failed\n");
-   hdmi_uninit_output(hdmi);
-   pm_runtime_disable(>dev);
-   return r;
+   goto err_uninit_output;
}
 
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
@@ -790,6 +788,9 @@ static int hdmi4_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
+err_uninit_output:
+   hdmi_uninit_output(hdmi);
+   pm_runtime_disable(>dev);
 err_pll:
hdmi_pll_uninit(>pll);
 err_free:
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index e5d23dd19f99..92ae561bf974 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -773,9 +773,7 @@ static int hdmi5_bind(struct device *dev, struct device 
*master, void *data)
r = hdmi_audio_register(hdmi);
if (r) {
DSSERR("Registering HDMI audio failed %d\n", r);
-   hdmi_uninit_output(hdmi);
-   pm_runtime_disable(>dev);
-   return r;
+   goto err_uninit_output;
}
 
hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
@@ -783,6 +781,9 @@ static int hdmi5_bind(struct device *dev, struct device 
*master, void *data)
 
return 0;
 
+err_uninit_output:
+   hdmi_uninit_output(hdmi);
+   pm_runtime_disable(>dev);
 err_pll:
hdmi_pll_uninit(>pll);
 err_free:
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index fd5320041911..0ace553a21c5 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -355,16 +355,15 @@ int sdi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
}
 
r = of_property_read_u32(ep,