aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/dss
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-03-02 14:11:06 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-09-03 09:13:27 -0400
commiteaaedaf6a1de3be2f62feefc40fa6a711382f1ca (patch)
tree525f0e7462e3a856507650319cd66369262609b8 /drivers/gpu/drm/omapdrm/dss
parent4e20bda68e01f723d7fcc4e7d55a4afc78223fb7 (diff)
drm/omap: dss: Extend omapdss_of_find_source_for_first_ep() to sinks
The omapdss_of_find_source_for_first_ep() function locates the source corresponding to the first endpoint of the first port of a device node. We can easily extend it to locate sinks as well by passing the port number as a parameter. This will be useful to find sinks in encoders drivers. Extend the function and rename it to omapdss_of_find_connected_device() to reflect its new extended purpose. Additionally, it is useful to differentiate between failures to return the connected device because no link exists in the device tree for the requested port, or because the connected device as described in the device tree is invalid or not probed yet. Return NULL in the first case and an error code in the second case, and update the callers accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/dss')
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dss-of.c14
-rw-r--r--drivers/gpu/drm/omapdrm/dss/omapdss.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index 771b20db2d98..0422597ac6b0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -47,7 +47,7 @@ dss_of_port_get_parent_device(struct device_node *port)
47} 47}
48 48
49struct omap_dss_device * 49struct omap_dss_device *
50omapdss_of_find_source_for_first_ep(struct device_node *node) 50omapdss_of_find_connected_device(struct device_node *node, unsigned int port)
51{ 51{
52 struct device_node *src_node; 52 struct device_node *src_node;
53 struct device_node *src_port; 53 struct device_node *src_port;
@@ -56,27 +56,27 @@ omapdss_of_find_source_for_first_ep(struct device_node *node)
56 u32 port_number = 0; 56 u32 port_number = 0;
57 57
58 /* Get the endpoint... */ 58 /* Get the endpoint... */
59 ep = of_graph_get_endpoint_by_regs(node, 0, 0); 59 ep = of_graph_get_endpoint_by_regs(node, port, 0);
60 if (!ep) 60 if (!ep)
61 return ERR_PTR(-EINVAL); 61 return NULL;
62 62
63 /* ... and its remote port... */ 63 /* ... and its remote port... */
64 src_port = of_graph_get_remote_port(ep); 64 src_port = of_graph_get_remote_port(ep);
65 of_node_put(ep); 65 of_node_put(ep);
66 if (!src_port) 66 if (!src_port)
67 return ERR_PTR(-EINVAL); 67 return NULL;
68 68
69 /* ... and the remote port's number and parent... */ 69 /* ... and the remote port's number and parent... */
70 of_property_read_u32(src_port, "reg", &port_number); 70 of_property_read_u32(src_port, "reg", &port_number);
71 src_node = dss_of_port_get_parent_device(src_port); 71 src_node = dss_of_port_get_parent_device(src_port);
72 of_node_put(src_port); 72 of_node_put(src_port);
73 if (!src_node) 73 if (!src_node)
74 return NULL; 74 return ERR_PTR(-EINVAL);
75 75
76 /* ... and finally the source. */ 76 /* ... and finally the connected device. */
77 src = omapdss_find_device_by_port(src_node, port_number); 77 src = omapdss_find_device_by_port(src_node, port_number);
78 of_node_put(src_node); 78 of_node_put(src_node);
79 79
80 return src ? src : ERR_PTR(-EPROBE_DEFER); 80 return src ? src : ERR_PTR(-EPROBE_DEFER);
81} 81}
82EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep); 82EXPORT_SYMBOL_GPL(omapdss_of_find_connected_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c2d9ebdec3d1..dc2f8167f61b 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -532,7 +532,7 @@ static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
532} 532}
533 533
534struct omap_dss_device * 534struct omap_dss_device *
535omapdss_of_find_source_for_first_ep(struct device_node *node); 535omapdss_of_find_connected_device(struct device_node *node, unsigned int port);
536 536
537enum dss_writeback_channel { 537enum dss_writeback_channel {
538 DSS_WB_LCD1_MGR = 0, 538 DSS_WB_LCD1_MGR = 0,