From 249040dc7fd391186f420fe23a9b59d357103cac Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 8 Feb 2007 22:53:55 +0000 Subject: [PATCH] backlight: Convert semaphore -> mutex Convert internal semaphore to a mutex Signed-off-by: Richard Purdie --- drivers/video/backlight/backlight.c | 34 +++++++++++++++++----------------- drivers/video/backlight/lcd.c | 30 +++++++++++++++--------------- include/linux/backlight.h | 6 +++--- include/linux/lcd.h | 4 ++-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 347081d..4f987c4 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -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); diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 1e1e61a..430ba01 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -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); } diff --git a/include/linux/backlight.h b/include/linux/backlight.h index d1426b8..43c6d55 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -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 */ diff --git a/include/linux/lcd.h b/include/linux/lcd.h index bfbf655..46970af 100644 --- a/include/linux/lcd.h +++ b/include/linux/lcd.h @@ -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 */ -- 2.7.4