aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/backlight.c29
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}
371EXPORT_SYMBOL(backlight_device_unregister); 371EXPORT_SYMBOL(backlight_device_unregister);
372 372
373#ifdef CONFIG_OF
374static 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 */
391struct 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}
399EXPORT_SYMBOL(of_find_backlight_by_node);
400#endif
401
373static void __exit backlight_class_exit(void) 402static void __exit backlight_class_exit(void)
374{ 403{
375 class_destroy(backlight_class); 404 class_destroy(backlight_class);