aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/backlight.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/backlight.h')
-rw-r--r--include/linux/backlight.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 287c62d956f2..d1426b852bdf 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -9,8 +9,24 @@
9#define _LINUX_BACKLIGHT_H 9#define _LINUX_BACKLIGHT_H
10 10
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/mutex.h>
12#include <linux/notifier.h> 13#include <linux/notifier.h>
13 14
15/* Notes on locking:
16 *
17 * backlight_device->sem is an internal backlight lock protecting the props
18 * field and no code outside the core should need to touch it.
19 *
20 * Access to update_status() is serialised by the update_lock mutex since
21 * most drivers seem to need this and historically get it wrong.
22 *
23 * Most drivers don't need locking on their get_brightness() method.
24 * If yours does, you need to implement it in the driver. You can use the
25 * update_lock mutex if appropriate.
26 *
27 * Any other use of the locks below is probably wrong.
28 */
29
14struct backlight_device; 30struct backlight_device;
15struct fb_info; 31struct fb_info;
16 32
@@ -44,12 +60,22 @@ struct backlight_device {
44 struct semaphore sem; 60 struct semaphore sem;
45 /* If this is NULL, the backing module is unloaded */ 61 /* If this is NULL, the backing module is unloaded */
46 struct backlight_properties *props; 62 struct backlight_properties *props;
63 /* Serialise access to update_status method */
64 struct mutex update_lock;
47 /* The framebuffer notifier block */ 65 /* The framebuffer notifier block */
48 struct notifier_block fb_notif; 66 struct notifier_block fb_notif;
49 /* The class device structure */ 67 /* The class device structure */
50 struct class_device class_dev; 68 struct class_device class_dev;
51}; 69};
52 70
71static inline void backlight_update_status(struct backlight_device *bd)
72{
73 mutex_lock(&bd->update_lock);
74 if (bd->props && bd->props->update_status)
75 bd->props->update_status(bd);
76 mutex_unlock(&bd->update_lock);
77}
78
53extern struct backlight_device *backlight_device_register(const char *name, 79extern struct backlight_device *backlight_device_register(const char *name,
54 struct device *dev,void *devdata,struct backlight_properties *bp); 80 struct device *dev,void *devdata,struct backlight_properties *bp);
55extern void backlight_device_unregister(struct backlight_device *bd); 81extern void backlight_device_unregister(struct backlight_device *bd);