drm/omap: Factor out common init/cleanup code for output devices
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 12 Sep 2018 16:41:31 +0000 (19:41 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 18 Mar 2019 09:42:12 +0000 (11:42 +0200)
All the internal encoders share common init and cleanup code. Factor it
out to separate functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/dss/dpi.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/omapdrm/dss/hdmi4.c
drivers/gpu/drm/omapdrm/dss/hdmi5.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/dss/output.c
drivers/gpu/drm/omapdrm/dss/sdi.c
drivers/gpu/drm/omapdrm/dss/venc.c

index 74e841a2b4eb41814e00773cbcf1029016747ba4..0db01cadf09f67fc70b36f0eedbb1efaa2d783e3 100644 (file)
@@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
        out->ops = &dpi_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 = &dpi->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[] = {
index 4dad2bf6b551a2f94a176065eda42a334f9402de..4ac325e664b5fb17d776d16ab4c20427447a57b3 100644 (file)
@@ -5131,19 +5131,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);
 
@@ -5154,9 +5144,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
 {
        struct omap_dss_device *out = &dsi->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)
index 6f88fb4d6344a37dff57c870a63a7e96c5b80410..60792981a33f3b59a4c74884d34fb8cb786521e5 100644 (file)
@@ -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 = &hdmi->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)
index 28cf1c32b1587768e11d73c94de5bfe24cfc1363..d7d33b4d2bedfa7cab8c232b5a634309b99419cb 100644 (file)
@@ -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 = 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);
 
@@ -694,9 +684,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
 {
        struct omap_dss_device *out = &hdmi->output;
 
-       if (out->next)
-               omapdss_device_put(out->next);
        omapdss_device_unregister(out);
+       omapdss_device_cleanup_output(out);
 }
 
 static int hdmi5_probe_of(struct omap_hdmi *hdmi)
index fc82b8f545ae866b8e8063bbecefa27a2bbe1961..fbdeeaa521d6c8e473d5fb1e46d603e1faa08e81 100644 (file)
@@ -493,7 +493,8 @@ int omap_dss_get_num_overlays(void);
 #define for_each_dss_output(d) \
        while ((d = omapdss_device_next_output(d)) != NULL)
 struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
-int omapdss_output_validate(struct omap_dss_device *out);
+int omapdss_device_init_output(struct omap_dss_device *out);
+void omapdss_device_cleanup_output(struct omap_dss_device *out);
 
 typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
index 18505bc70f7e5037e8c03f56274a842bb53d7dc4..0ac400a521f33be1cda6eaec16e92ec5cdc3bfae 100644 (file)
 #include "dss.h"
 #include "omapdss.h"
 
-int omapdss_output_validate(struct omap_dss_device *out)
+int omapdss_device_init_output(struct omap_dss_device *out)
 {
+       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);
+       }
+
        if (out->next && out->output_type != out->next->type) {
                dev_err(out->dev, "output type and display type don't match\n");
                return -EINVAL;
@@ -33,7 +40,14 @@ int omapdss_output_validate(struct omap_dss_device *out)
 
        return 0;
 }
-EXPORT_SYMBOL(omapdss_output_validate);
+EXPORT_SYMBOL(omapdss_device_init_output);
+
+void omapdss_device_cleanup_output(struct omap_dss_device *out)
+{
+       if (out->next)
+               omapdss_device_put(out->next);
+}
+EXPORT_SYMBOL(omapdss_device_cleanup_output);
 
 int dss_install_mgr_ops(struct dss_device *dss,
                        const struct dss_mgr_ops *mgr_ops,
index 20e88c6e3d9859d07567286b23fed284c8a6d097..58c17566a4cb2b3c80dac8e9c66d4f6ec1c174bb 100644 (file)
@@ -281,19 +281,9 @@ static int sdi_init_output(struct sdi_device *sdi)
        out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE   /* 15.5.9.1.2 */
                       | DRM_BUS_FLAG_SYNC_POSEDGE;
 
-       out->next = omapdss_of_find_connected_device(out->dev->of_node, 1);
-       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);
 
@@ -302,9 +292,8 @@ static int sdi_init_output(struct sdi_device *sdi)
 
 static void sdi_uninit_output(struct sdi_device *sdi)
 {
-       if (sdi->output.next)
-               omapdss_device_put(sdi->output.next);
        omapdss_device_unregister(&sdi->output);
+       omapdss_device_cleanup_output(&sdi->output);
 }
 
 int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
index dc4133718875e6dd7a5f6bffc0ae647d08d93fd9..3fc776c45c4fb1dc35634062969b719860e9adcb 100644 (file)
@@ -752,19 +752,9 @@ static int venc_init_output(struct venc_device *venc)
        out->owner = THIS_MODULE;
        out->of_ports = BIT(0);
 
-       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);
 
@@ -773,9 +763,8 @@ static int venc_init_output(struct venc_device *venc)
 
 static void venc_uninit_output(struct venc_device *venc)
 {
-       if (venc->output.next)
-               omapdss_device_put(venc->output.next);
        omapdss_device_unregister(&venc->output);
+       omapdss_device_cleanup_output(&venc->output);
 }
 
 static int venc_probe_of(struct venc_device *venc)