]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
backlight: Convert semaphore -> mutex
authorRichard Purdie <rpurdie@rpsys.net>
Thu, 8 Feb 2007 22:53:55 +0000 (22:53 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Tue, 20 Feb 2007 08:38:45 +0000 (08:38 +0000)
Convert internal semaphore to a mutex

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/video/backlight/backlight.c
drivers/video/backlight/lcd.c
include/linux/backlight.h
include/linux/lcd.h

index 347081daf7a469a5fe271308f6d079dde9232950..4f987c40b72de1674a32487157539b7ed1924497 100644 (file)
@@ -32,14 +32,14 @@ static int fb_notifier_callback(struct notifier_block *self,
                return 0;
 
        bd = container_of(self, struct backlight_device, fb_notif);
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props)
                if (!bd->props->check_fb ||
                    bd->props->check_fb(evdata->info)) {
                        bd->props->fb_blank = *(int *)evdata->data;
                        backlight_update_status(bd);
                }
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
        return 0;
 }
 
@@ -71,10 +71,10 @@ static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
        int rc = -ENXIO;
        struct backlight_device *bd = to_backlight_device(cdev);
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props)
                rc = sprintf(buf, "%d\n", bd->props->power);
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -92,14 +92,14 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf,
        if (size != count)
                return -EINVAL;
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props) {
                pr_debug("backlight: set power to %d\n", power);
                bd->props->power = power;
                backlight_update_status(bd);
                rc = count;
        }
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -109,10 +109,10 @@ static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
        int rc = -ENXIO;
        struct backlight_device *bd = to_backlight_device(cdev);
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props)
                rc = sprintf(buf, "%d\n", bd->props->brightness);
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -130,7 +130,7 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
        if (size != count)
                return -EINVAL;
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props) {
                if (brightness > bd->props->max_brightness)
                        rc = -EINVAL;
@@ -142,7 +142,7 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
                        rc = count;
                }
        }
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -152,10 +152,10 @@ static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *bu
        int rc = -ENXIO;
        struct backlight_device *bd = to_backlight_device(cdev);
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props)
                rc = sprintf(buf, "%d\n", bd->props->max_brightness);
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -166,10 +166,10 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
        int rc = -ENXIO;
        struct backlight_device *bd = to_backlight_device(cdev);
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        if (bd->props && bd->props->get_brightness)
                rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd));
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        return rc;
 }
@@ -228,7 +228,7 @@ struct backlight_device *backlight_device_register(const char *name,
                return ERR_PTR(-ENOMEM);
 
        mutex_init(&new_bd->update_lock);
-       init_MUTEX(&new_bd->sem);
+       mutex_init(&new_bd->props_lock);
        new_bd->props = bp;
        memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
        new_bd->class_dev.class = &backlight_class;
@@ -285,9 +285,9 @@ void backlight_device_unregister(struct backlight_device *bd)
                class_device_remove_file(&bd->class_dev,
                                         &bl_class_device_attributes[i]);
 
-       down(&bd->sem);
+       mutex_lock(&bd->props_lock);
        bd->props = NULL;
-       up(&bd->sem);
+       mutex_unlock(&bd->props_lock);
 
        backlight_unregister_fb(bd);
 
index 1e1e61a4b5da6cc6651f2e2a55fa7a76cd12dbe7..430ba018a896021806654a9eb04d00882628fd3a 100644 (file)
@@ -31,11 +31,11 @@ static int fb_notifier_callback(struct notifier_block *self,
                return 0;
 
        ld = container_of(self, struct lcd_device, fb_notif);
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props)
                if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
                        ld->props->set_power(ld, *(int *)evdata->data);
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
        return 0;
 }
 
@@ -66,12 +66,12 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
        int rc;
        struct lcd_device *ld = to_lcd_device(cdev);
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props && ld->props->get_power)
                rc = sprintf(buf, "%d\n", ld->props->get_power(ld));
        else
                rc = -ENXIO;
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
 
        return rc;
 }
@@ -89,13 +89,13 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
        if (size != count)
                return -EINVAL;
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props && ld->props->set_power) {
                pr_debug("lcd: set power to %d\n", power);
                ld->props->set_power(ld, power);
                rc = count;
        }
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
 
        return rc;
 }
@@ -105,10 +105,10 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
        int rc = -ENXIO;
        struct lcd_device *ld = to_lcd_device(cdev);
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props && ld->props->get_contrast)
                rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld));
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
 
        return rc;
 }
@@ -126,13 +126,13 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
        if (size != count)
                return -EINVAL;
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props && ld->props->set_contrast) {
                pr_debug("lcd: set contrast to %d\n", contrast);
                ld->props->set_contrast(ld, contrast);
                rc = count;
        }
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
 
        return rc;
 }
@@ -142,10 +142,10 @@ static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
        int rc = -ENXIO;
        struct lcd_device *ld = to_lcd_device(cdev);
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        if (ld->props)
                rc = sprintf(buf, "%d\n", ld->props->max_contrast);
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
 
        return rc;
 }
@@ -197,7 +197,7 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
        if (!new_ld)
                return ERR_PTR(-ENOMEM);
 
-       init_MUTEX(&new_ld->sem);
+       mutex_init(&new_ld->props_lock);
        mutex_init(&new_ld->update_lock);
        new_ld->props = lp;
        memset(&new_ld->class_dev, 0, sizeof(new_ld->class_dev));
@@ -253,9 +253,9 @@ void lcd_device_unregister(struct lcd_device *ld)
                class_device_remove_file(&ld->class_dev,
                                         &lcd_class_device_attributes[i]);
 
-       down(&ld->sem);
+       mutex_lock(&ld->props_lock);
        ld->props = NULL;
-       up(&ld->sem);
+       mutex_unlock(&ld->props_lock);
        lcd_unregister_fb(ld);
        class_device_unregister(&ld->class_dev);
 }
index d1426b852bdfe28001b86b95532cd0c1d62971d8..43c6d55644b5236d777e38c8bf6420873b9db84e 100644 (file)
@@ -14,8 +14,8 @@
 
 /* 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.
+ * backlight_device->props_lock 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.
@@ -57,7 +57,7 @@ struct backlight_device {
        /* This protects the 'props' field. If 'props' is NULL, the driver that
           registered this device has been unloaded, and if class_get_devdata()
           points to something in the body of that driver, it is also invalid. */
-       struct semaphore sem;
+       struct mutex props_lock;
        /* If this is NULL, the backing module is unloaded */
        struct backlight_properties *props;
        /* Serialise access to update_status method */
index bfbf6552eb5158e2427032eb2ab6cea4e98073ea..46970af2ca89fc8e9c8a000883a993b54e02b2dc 100644 (file)
@@ -14,7 +14,7 @@
 
 /* Notes on locking:
  *
- * lcd_device->sem is an internal backlight lock protecting the props
+ * lcd_device->props_lock 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
@@ -52,7 +52,7 @@ struct lcd_device {
        /* This protects the 'props' field. If 'props' is NULL, the driver that
           registered this device has been unloaded, and if class_get_devdata()
           points to something in the body of that driver, it is also invalid. */
-       struct semaphore sem;
+       struct mutex props_lock;
        /* If this is NULL, the backing module is unloaded */
        struct lcd_properties *props;
        /* Serialise access to set_power method */