]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/omap: dss: Make omap_dss_get_next_device() more generic
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 2 Mar 2018 00:07:34 +0000 (02:07 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:26 +0000 (16:13 +0300)
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>
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/display.c
drivers/gpu/drm/omapdrm/dss/omapdss.h

index 8fac816ca481c3ce3e2b2c21b37cb88e477da723..9f01a4f2814531c1871c6a1bba67d7a31dc13180 100644 (file)
@@ -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)
 {
index e7872e0c8dab1a041f5705281cb4342c1a4be70d..5df73cd761532dee2aaf61737279b8c689950e13 100644 (file)
@@ -92,52 +92,3 @@ void omap_dss_put_device(struct omap_dss_device *dssdev)
        module_put(dssdev->owner);
 }
 EXPORT_SYMBOL(omap_dss_put_device);
-
-/*
- * ref count of the found device is incremented.
- * ref count of from-device is decremented.
- */
-struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
-{
-       struct list_head *l;
-       struct omap_dss_device *dssdev;
-
-       mutex_lock(&panel_list_mutex);
-
-       if (list_empty(&panel_list)) {
-               dssdev = NULL;
-               goto out;
-       }
-
-       if (from == NULL) {
-               dssdev = list_first_entry(&panel_list, struct omap_dss_device,
-                               panel_list);
-               omap_dss_get_device(dssdev);
-               goto out;
-       }
-
-       omap_dss_put_device(from);
-
-       list_for_each(l, &panel_list) {
-               dssdev = list_entry(l, struct omap_dss_device, panel_list);
-               if (dssdev == from) {
-                       if (list_is_last(l, &panel_list)) {
-                               dssdev = NULL;
-                               goto out;
-                       }
-
-                       dssdev = list_entry(l->next, struct omap_dss_device,
-                                       panel_list);
-                       omap_dss_get_device(dssdev);
-                       goto out;
-               }
-       }
-
-       WARN(1, "'from' dssdev not found\n");
-
-       dssdev = NULL;
-out:
-       mutex_unlock(&panel_list_mutex);
-       return dssdev;
-}
-EXPORT_SYMBOL(omap_dss_get_next_device);
index a6ddc881ea727c83688adff9627525e73622e340..94a3f98bdd3d54ddd0a0b75ab8244290c2693c78 100644 (file)
@@ -489,11 +489,15 @@ static inline bool omapdss_is_initialized(void)
 
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
+#define for_each_dss_display(d) \
+       while ((d = omapdss_device_get_next(d, true)) != NULL)
 
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
 struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
                                                    unsigned int port);
+struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from,
+                                               bool display_only);
 int omapdss_device_connect(struct omap_dss_device *src,
                           struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
@@ -501,8 +505,6 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
-#define for_each_dss_display(d) while ((d = omap_dss_get_next_device(d)) != NULL)
-struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
 
 int omap_dss_get_num_overlay_managers(void);