summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/dss/base.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-03-02 02:07:34 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-09-03 16:13:26 +0300
commitb9f4d2ebf641d157be89a68227a5feb00c961d10 (patch)
tree18972475d565660c07c8e78ec51f3f1ea31b5555 /drivers/gpu/drm/omapdrm/dss/base.c
parent92ce521a4841131acf9af41e5bc772990ada06dc (diff)
downloadlinux-b9f4d2ebf641d157be89a68227a5feb00c961d10.tar.bz2
drm/omap: dss: Make omap_dss_get_next_device() more generic
Despite its name, the omap_dss_get_next_device() function operates on display devices only. Make it more generic by allowing operation on all devices, with a parameter to specify the device type. While at it rename the function to omapdss_device_get_next() to match the naming of the other functions operating on struct omap_dss_device. 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/base.c')
-rw-r--r--drivers/gpu/drm/omapdrm/dss/base.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 8fac816ca481..9f01a4f28145 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -104,6 +104,58 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
return NULL;
}
+/*
+ * Search for the next device starting at @from. If display_only is true, skip
+ * non-display devices. Release the reference to the @from device, and acquire
+ * a reference to the returned device if found.
+ */
+struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from,
+ bool display_only)
+{
+ struct omap_dss_device *dssdev;
+ struct list_head *list;
+
+ mutex_lock(&omapdss_devices_lock);
+
+ if (list_empty(&omapdss_devices_list)) {
+ dssdev = NULL;
+ goto done;
+ }
+
+ /*
+ * Start from the from entry if given or from omapdss_devices_list
+ * otherwise.
+ */
+ list = from ? &from->list : &omapdss_devices_list;
+
+ list_for_each_entry(dssdev, list, list) {
+ /*
+ * Stop if we reach the omapdss_devices_list, that's the end of
+ * the list.
+ */
+ if (&dssdev->list == &omapdss_devices_list) {
+ dssdev = NULL;
+ goto done;
+ }
+
+ /* Filter out non-display entries if display_only is set. */
+ if (!display_only || dssdev->driver)
+ goto done;
+ }
+
+ dssdev = NULL;
+
+done:
+ if (from)
+ omap_dss_put_device(from);
+ if (dssdev)
+ omap_dss_get_device(dssdev);
+
+ mutex_unlock(&omapdss_devices_lock);
+ return dssdev;
+}
+EXPORT_SYMBOL(omapdss_device_get_next);
+
int omapdss_device_connect(struct omap_dss_device *src,
struct omap_dss_device *dst)
{