summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/backlight.h26
-rw-r--r--include/linux/lcd.h26
2 files changed, 52 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 @@
#define _LINUX_BACKLIGHT_H
#include <linux/device.h>
+#include <linux/mutex.h>
#include <linux/notifier.h>
+/* Notes on locking:
+ *
+ * backlight_device->sem is an internal backlight lock protecting the props
+ * field and no code outside the core should need to touch it.
+ *
+ * Access to update_status() is serialised by the update_lock mutex since
+ * most drivers seem to need this and historically get it wrong.
+ *
+ * Most drivers don't need locking on their get_brightness() method.
+ * If yours does, you need to implement it in the driver. You can use the
+ * update_lock mutex if appropriate.
+ *
+ * Any other use of the locks below is probably wrong.
+ */
+
struct backlight_device;
struct fb_info;
@@ -44,12 +60,22 @@ struct backlight_device {
struct semaphore sem;
/* If this is NULL, the backing module is unloaded */
struct backlight_properties *props;
+ /* Serialise access to update_status method */
+ struct mutex update_lock;
/* The framebuffer notifier block */
struct notifier_block fb_notif;
/* The class device structure */
struct class_device class_dev;
};
+static inline void backlight_update_status(struct backlight_device *bd)
+{
+ mutex_lock(&bd->update_lock);
+ if (bd->props && bd->props->update_status)
+ bd->props->update_status(bd);
+ mutex_unlock(&bd->update_lock);
+}
+
extern struct backlight_device *backlight_device_register(const char *name,
struct device *dev,void *devdata,struct backlight_properties *bp);
extern void backlight_device_unregister(struct backlight_device *bd);
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 8a468f168c45..bfbf6552eb51 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -9,8 +9,24 @@
#define _LINUX_LCD_H
#include <linux/device.h>
+#include <linux/mutex.h>
#include <linux/notifier.h>
+/* Notes on locking:
+ *
+ * lcd_device->sem is an internal backlight lock protecting the props
+ * field and no code outside the core should need to touch it.
+ *
+ * Access to set_power() is serialised by the update_lock mutex since
+ * most drivers seem to need this and historically get it wrong.
+ *
+ * Most drivers don't need locking on their get_power() method.
+ * If yours does, you need to implement it in the driver. You can use the
+ * update_lock mutex if appropriate.
+ *
+ * Any other use of the locks below is probably wrong.
+ */
+
struct lcd_device;
struct fb_info;
@@ -39,12 +55,22 @@ struct lcd_device {
struct semaphore sem;
/* If this is NULL, the backing module is unloaded */
struct lcd_properties *props;
+ /* Serialise access to set_power method */
+ struct mutex update_lock;
/* The framebuffer notifier block */
struct notifier_block fb_notif;
/* The class device structure */
struct class_device class_dev;
};
+static inline void lcd_set_power(struct lcd_device *ld, int power)
+{
+ mutex_lock(&ld->update_lock);
+ if (ld->props && ld->props->set_power)
+ ld->props->set_power(ld, power);
+ mutex_unlock(&ld->update_lock);
+}
+
extern struct lcd_device *lcd_device_register(const char *name,
void *devdata, struct lcd_properties *lp);
extern void lcd_device_unregister(struct lcd_device *ld);