Commit 479da1f5 authored by Noralf Trønnes's avatar Noralf Trønnes Committed by Lee Jones
Browse files

backlight: Add backlight_device_get_by_name()



Add a way to lookup a backlight device based on its name.
Will be used by a USB display gadget getting the name from configfs.

Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Acked-by: default avatarJingoo Han <jingoohan1@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 62a1d3f6
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -432,6 +432,27 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
}
EXPORT_SYMBOL(backlight_device_get_by_type);

/**
 * backlight_device_get_by_name - Get backlight device by name
 * @name: Device name
 *
 * This function looks up a backlight device by its name. It obtains a reference
 * on the backlight device and it is the caller's responsibility to drop the
 * reference by calling backlight_put().
 *
 * Returns:
 * A pointer to the backlight device if found, otherwise NULL.
 */
struct backlight_device *backlight_device_get_by_name(const char *name)
{
	struct device *dev;

	dev = class_find_device_by_name(backlight_class, name);

	return dev ? to_backlight_device(dev) : NULL;
}
EXPORT_SYMBOL(backlight_device_get_by_name);

/**
 * backlight_device_unregister - unregisters a backlight device object.
 * @bd: the backlight device object to be unregistered and freed.
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ extern void backlight_force_update(struct backlight_device *bd,
extern int backlight_register_notifier(struct notifier_block *nb);
extern int backlight_unregister_notifier(struct notifier_block *nb);
extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
struct backlight_device *backlight_device_get_by_name(const char *name);
extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);

#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)