]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
backlight: add of_find_backlight_by_node()
authorThierry Reding <thierry.reding@avionic-design.de>
Thu, 29 Nov 2012 03:18:29 +0000 (14:18 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2012 05:23:32 +0000 (16:23 +1100)
This function finds the struct backlight_device for a given device tree
node.  A dummy function is provided so that it safely compiles out if OF
support is disabled.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Reviewed-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/video/backlight/backlight.c
include/linux/backlight.h

index 297db2fa91f58e556873a114b812c214e650dca8..0d1ed4f008c82e74ca71c942b8c00ebc6c57e45f 100644 (file)
@@ -370,6 +370,23 @@ void backlight_device_unregister(struct backlight_device *bd)
 }
 EXPORT_SYMBOL(backlight_device_unregister);
 
+#if IS_ENABLED(CONFIG_OF)
+static int of_parent_match(struct device *dev, void *data)
+{
+       return dev->parent && dev->parent->of_node == data;
+}
+
+struct backlight_device *of_find_backlight_by_node(struct device_node *node)
+{
+       struct device *dev;
+
+       dev = class_find_device(backlight_class, NULL, node, of_parent_match);
+
+       return dev ? to_backlight_device(dev) : NULL;
+}
+EXPORT_SYMBOL(of_find_backlight_by_node);
+#endif
+
 static void __exit backlight_class_exit(void)
 {
        class_destroy(backlight_class);
index 5ffc6dda46751a44681ee3f94808ceeb50fd0d38..11840e9bde970b86dcb929d8f8f553453c3843ac 100644 (file)
@@ -134,4 +134,14 @@ struct generic_bl_info {
        void (*kick_battery)(void);
 };
 
+#if IS_ENABLED(CONFIG_OF)
+struct backlight_device *of_find_backlight_by_node(struct device_node *node);
+#else
+static inline struct backlight_device *
+of_find_backlight_by_node(struct device_node *node)
+{
+       return NULL;
+}
+#endif
+
 #endif