diff options
author | Thierry Reding <thierry.reding@avionic-design.de> | 2012-12-17 19:01:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:16 -0500 |
commit | 762a936fba7bd9225ca9a96e4860f6969b6b5670 (patch) | |
tree | afb3f60c95eb8d21573e80683c61bb43ebb58ffe /drivers/video | |
parent | fb08cd9b111c6a922f468ef5e33acc67eb91d40b (diff) |
backlight: add of_find_backlight_by_node()
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.
[akpm@linux-foundation.org: Don't use IS_ENABLED(CONFIG_OF)]
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>
Cc: Thierry Reding <thierry.reding@avionic-design.de>
Reviewed-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/backlight.c | 29 |
1 files changed, 29 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); |