Re: [PATCH 11/29] drm/omap: Factor out common init/cleanup code for output devices

2018-12-10 Thread Sebastian Reichel
Hi,

On Wed, Dec 05, 2018 at 05:00:04PM +0200, Laurent Pinchart wrote:
> All the internal encoders share common init and cleanup code. Factor it
> out to separate functions.
> 
> Signed-off-by: Laurent Pinchart 
> ---

Reviewed-by: Sebastian Reichel 

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c | 17 +++--
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 17 +++--
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 17 +++--
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 17 +++--
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++-
>  drivers/gpu/drm/omapdrm/dss/output.c  | 18 --
>  drivers/gpu/drm/omapdrm/dss/sdi.c | 17 +++--
>  drivers/gpu/drm/omapdrm/dss/venc.c| 17 +++--
>  8 files changed, 36 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
> b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 74e841a2b4eb..0db01cadf09f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, 
> struct device_node *port)
>   out->ops = _ops;
>   out->owner = THIS_MODULE;
>  
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
>   return r;
> - }
>  
>   omapdss_device_register(out);
>  
> @@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node 
> *port)
>   struct dpi_data *dpi = port->data;
>   struct omap_dss_device *out = >output;
>  
> - if (out->next)
> - omapdss_device_put(out->next);
>   omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
>  }
>  
>  static const struct soc_device_attribute dpi_soc_devices[] = {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
> b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 99b34e409159..0ba4670fd6cf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5122,19 +5122,9 @@ static int dsi_init_output(struct dsi_data *dsi)
>  | DRM_BUS_FLAG_DE_HIGH
>  | DRM_BUS_FLAG_SYNC_NEGEDGE;
>  
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
>   return r;
> - }
>  
>   omapdss_device_register(out);
>  
> @@ -5145,9 +5135,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
>  {
>   struct omap_dss_device *out = >output;
>  
> - if (out->next)
> - omapdss_device_put(out->next);
>   omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
>  }
>  
>  static int dsi_probe_of(struct dsi_data *dsi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index 6f88fb4d6344..60792981a33f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
>   out->of_ports = BIT(0);
>   out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
>  
> - out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
> - if (IS_ERR(out->next)) {
> - if (PTR_ERR(out->next) != -EPROBE_DEFER)
> - dev_err(out->dev, "failed to find video sink\n");
> - return PTR_ERR(out->next);
> - }
> -
> - r = omapdss_output_validate(out);
> - if (r) {
> - omapdss_device_put(out->next);
> - out->next = NULL;
> + r = omapdss_device_init_output(out);
> + if (r < 0)
>   return r;
> - }
>  
>   omapdss_device_register(out);
>  
> @@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
>  {
>   struct omap_dss_device *out = >output;
>  
> - if (out->next)
> - omapdss_device_put(out->next);
>   omapdss_device_unregister(out);
> + omapdss_device_cleanup_output(out);
>  }
>  
>  static int hdmi4_probe_of(struct omap_hdmi *hdmi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 28cf1c32b158..d7d33b4d2bed 100644
> --- 

[PATCH 11/29] drm/omap: Factor out common init/cleanup code for output devices

2018-12-05 Thread Laurent Pinchart
All the internal encoders share common init and cleanup code. Factor it
out to separate functions.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 17 +++--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 17 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 17 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 17 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++-
 drivers/gpu/drm/omapdrm/dss/output.c  | 18 --
 drivers/gpu/drm/omapdrm/dss/sdi.c | 17 +++--
 drivers/gpu/drm/omapdrm/dss/venc.c| 17 +++--
 8 files changed, 36 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 74e841a2b4eb..0db01cadf09f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, 
struct device_node *port)
out->ops = _ops;
out->owner = THIS_MODULE;
 
-   out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
-   if (IS_ERR(out->next)) {
-   if (PTR_ERR(out->next) != -EPROBE_DEFER)
-   dev_err(out->dev, "failed to find video sink\n");
-   return PTR_ERR(out->next);
-   }
-
-   r = omapdss_output_validate(out);
-   if (r) {
-   omapdss_device_put(out->next);
-   out->next = NULL;
+   r = omapdss_device_init_output(out);
+   if (r < 0)
return r;
-   }
 
omapdss_device_register(out);
 
@@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node *port)
struct dpi_data *dpi = port->data;
struct omap_dss_device *out = >output;
 
-   if (out->next)
-   omapdss_device_put(out->next);
omapdss_device_unregister(out);
+   omapdss_device_cleanup_output(out);
 }
 
 static const struct soc_device_attribute dpi_soc_devices[] = {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 99b34e409159..0ba4670fd6cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5122,19 +5122,9 @@ static int dsi_init_output(struct dsi_data *dsi)
   | DRM_BUS_FLAG_DE_HIGH
   | DRM_BUS_FLAG_SYNC_NEGEDGE;
 
-   out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
-   if (IS_ERR(out->next)) {
-   if (PTR_ERR(out->next) != -EPROBE_DEFER)
-   dev_err(out->dev, "failed to find video sink\n");
-   return PTR_ERR(out->next);
-   }
-
-   r = omapdss_output_validate(out);
-   if (r) {
-   omapdss_device_put(out->next);
-   out->next = NULL;
+   r = omapdss_device_init_output(out);
+   if (r < 0)
return r;
-   }
 
omapdss_device_register(out);
 
@@ -5145,9 +5135,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
 {
struct omap_dss_device *out = >output;
 
-   if (out->next)
-   omapdss_device_put(out->next);
omapdss_device_unregister(out);
+   omapdss_device_cleanup_output(out);
 }
 
 static int dsi_probe_of(struct dsi_data *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 6f88fb4d6344..60792981a33f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
out->of_ports = BIT(0);
out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
 
-   out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
-   if (IS_ERR(out->next)) {
-   if (PTR_ERR(out->next) != -EPROBE_DEFER)
-   dev_err(out->dev, "failed to find video sink\n");
-   return PTR_ERR(out->next);
-   }
-
-   r = omapdss_output_validate(out);
-   if (r) {
-   omapdss_device_put(out->next);
-   out->next = NULL;
+   r = omapdss_device_init_output(out);
+   if (r < 0)
return r;
-   }
 
omapdss_device_register(out);
 
@@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
 {
struct omap_dss_device *out = >output;
 
-   if (out->next)
-   omapdss_device_put(out->next);
omapdss_device_unregister(out);
+   omapdss_device_cleanup_output(out);
 }
 
 static int hdmi4_probe_of(struct omap_hdmi *hdmi)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 28cf1c32b158..d7d33b4d2bed 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -671,19 +671,9 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
out->of_ports = BIT(0);
out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
 
-   out->next =