diff options
-rw-r--r-- | drivers/video/backlight/backlight.c | 29 | ||||
-rw-r--r-- | include/linux/backlight.h | 10 |
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 297db2fa91f5..345f6660d4b3 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -370,6 +370,35 @@ void backlight_device_unregister(struct backlight_device *bd) | |||
370 | } | 370 | } |
371 | EXPORT_SYMBOL(backlight_device_unregister); | 371 | EXPORT_SYMBOL(backlight_device_unregister); |
372 | 372 | ||
373 | #ifdef CONFIG_OF | ||
374 | static int of_parent_match(struct device *dev, void *data) | ||
375 | { | ||
376 | return dev->parent && dev->parent->of_node == data; | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * of_find_backlight_by_node() - find backlight device by device-tree node | ||
381 | * @node: device-tree node of the backlight device | ||
382 | * | ||
383 | * Returns a pointer to the backlight device corresponding to the given DT | ||
384 | * node or NULL if no such backlight device exists or if the device hasn't | ||
385 | * been probed yet. | ||
386 | * | ||
387 | * This function obtains a reference on the backlight device and it is the | ||
388 | * caller's responsibility to drop the reference by calling put_device() on | ||
389 | * the backlight device's .dev field. | ||
390 | */ | ||
391 | struct backlight_device *of_find_backlight_by_node(struct device_node *node) | ||
392 | { | ||
393 | struct device *dev; | ||
394 | |||
395 | dev = class_find_device(backlight_class, NULL, node, of_parent_match); | ||
396 | |||
397 | return dev ? to_backlight_device(dev) : NULL; | ||
398 | } | ||
399 | EXPORT_SYMBOL(of_find_backlight_by_node); | ||
400 | #endif | ||
401 | |||
373 | static void __exit backlight_class_exit(void) | 402 | static void __exit backlight_class_exit(void) |
374 | { | 403 | { |
375 | class_destroy(backlight_class); | 404 | class_destroy(backlight_class); |
diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 5ffc6dda4675..da9a0825e007 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h | |||
@@ -134,4 +134,14 @@ struct generic_bl_info { | |||
134 | void (*kick_battery)(void); | 134 | void (*kick_battery)(void); |
135 | }; | 135 | }; |
136 | 136 | ||
137 | #ifdef CONFIG_OF | ||
138 | struct backlight_device *of_find_backlight_by_node(struct device_node *node); | ||
139 | #else | ||
140 | static inline struct backlight_device * | ||
141 | of_find_backlight_by_node(struct device_node *node) | ||
142 | { | ||
143 | return NULL; | ||
144 | } | ||
145 | #endif | ||
146 | |||
137 | #endif | 147 | #endif |