Commit 762a936f authored by Thierry Reding's avatar Thierry Reding Committed by Linus Torvalds
Browse files

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.

Signed-off-by: default avatarThierry Reding <>
Acked-by: default avatarJingoo Han <>
Reviewed-by: default avatarGrant Likely <>
Cc: Thierry Reding <>
Reviewed-by: default avatarGrant Likely <>
Acked-by: default avatarJingoo Han <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent fb08cd9b
......@@ -370,6 +370,35 @@ void backlight_device_unregister(struct backlight_device *bd)
#ifdef CONFIG_OF
static int of_parent_match(struct device *dev, void *data)
return dev->parent && dev->parent->of_node == data;
* of_find_backlight_by_node() - find backlight device by device-tree node
* @node: device-tree node of the backlight device
* Returns a pointer to the backlight device corresponding to the given DT
* node or NULL if no such backlight device exists or if the device hasn't
* been probed yet.
* This function obtains a reference on the backlight device and it is the
* caller's responsibility to drop the reference by calling put_device() on
* the backlight device's .dev field.
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;
static void __exit backlight_class_exit(void)
......@@ -134,4 +134,14 @@ struct generic_bl_info {
void (*kick_battery)(void);
#ifdef CONFIG_OF
struct backlight_device *of_find_backlight_by_node(struct device_node *node);
static inline struct backlight_device *
of_find_backlight_by_node(struct device_node *node)
return NULL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment