Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: Convert semaphore -> mutex

Convert internal semaphore to a mutex

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>

+37 -37
+17 -17
drivers/video/backlight/backlight.c
··· 32 32 return 0; 33 33 34 34 bd = container_of(self, struct backlight_device, fb_notif); 35 - down(&bd->sem); 35 + mutex_lock(&bd->props_lock); 36 36 if (bd->props) 37 37 if (!bd->props->check_fb || 38 38 bd->props->check_fb(evdata->info)) { 39 39 bd->props->fb_blank = *(int *)evdata->data; 40 40 backlight_update_status(bd); 41 41 } 42 - up(&bd->sem); 42 + mutex_unlock(&bd->props_lock); 43 43 return 0; 44 44 } 45 45 ··· 71 71 int rc = -ENXIO; 72 72 struct backlight_device *bd = to_backlight_device(cdev); 73 73 74 - down(&bd->sem); 74 + mutex_lock(&bd->props_lock); 75 75 if (bd->props) 76 76 rc = sprintf(buf, "%d\n", bd->props->power); 77 - up(&bd->sem); 77 + mutex_unlock(&bd->props_lock); 78 78 79 79 return rc; 80 80 } ··· 92 92 if (size != count) 93 93 return -EINVAL; 94 94 95 - down(&bd->sem); 95 + mutex_lock(&bd->props_lock); 96 96 if (bd->props) { 97 97 pr_debug("backlight: set power to %d\n", power); 98 98 bd->props->power = power; 99 99 backlight_update_status(bd); 100 100 rc = count; 101 101 } 102 - up(&bd->sem); 102 + mutex_unlock(&bd->props_lock); 103 103 104 104 return rc; 105 105 } ··· 109 109 int rc = -ENXIO; 110 110 struct backlight_device *bd = to_backlight_device(cdev); 111 111 112 - down(&bd->sem); 112 + mutex_lock(&bd->props_lock); 113 113 if (bd->props) 114 114 rc = sprintf(buf, "%d\n", bd->props->brightness); 115 - up(&bd->sem); 115 + mutex_unlock(&bd->props_lock); 116 116 117 117 return rc; 118 118 } ··· 130 130 if (size != count) 131 131 return -EINVAL; 132 132 133 - down(&bd->sem); 133 + mutex_lock(&bd->props_lock); 134 134 if (bd->props) { 135 135 if (brightness > bd->props->max_brightness) 136 136 rc = -EINVAL; ··· 142 142 rc = count; 143 143 } 144 144 } 145 - up(&bd->sem); 145 + mutex_unlock(&bd->props_lock); 146 146 147 147 return rc; 148 148 } ··· 152 152 int rc = -ENXIO; 153 153 struct backlight_device *bd = to_backlight_device(cdev); 154 154 155 - down(&bd->sem); 155 + mutex_lock(&bd->props_lock); 156 156 if (bd->props) 157 157 rc = sprintf(buf, "%d\n", bd->props->max_brightness); 158 - up(&bd->sem); 158 + mutex_unlock(&bd->props_lock); 159 159 160 160 return rc; 161 161 } ··· 166 166 int rc = -ENXIO; 167 167 struct backlight_device *bd = to_backlight_device(cdev); 168 168 169 - down(&bd->sem); 169 + mutex_lock(&bd->props_lock); 170 170 if (bd->props && bd->props->get_brightness) 171 171 rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd)); 172 - up(&bd->sem); 172 + mutex_unlock(&bd->props_lock); 173 173 174 174 return rc; 175 175 } ··· 228 228 return ERR_PTR(-ENOMEM); 229 229 230 230 mutex_init(&new_bd->update_lock); 231 - init_MUTEX(&new_bd->sem); 231 + mutex_init(&new_bd->props_lock); 232 232 new_bd->props = bp; 233 233 memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev)); 234 234 new_bd->class_dev.class = &backlight_class; ··· 285 285 class_device_remove_file(&bd->class_dev, 286 286 &bl_class_device_attributes[i]); 287 287 288 - down(&bd->sem); 288 + mutex_lock(&bd->props_lock); 289 289 bd->props = NULL; 290 - up(&bd->sem); 290 + mutex_unlock(&bd->props_lock); 291 291 292 292 backlight_unregister_fb(bd); 293 293
+15 -15
drivers/video/backlight/lcd.c
··· 31 31 return 0; 32 32 33 33 ld = container_of(self, struct lcd_device, fb_notif); 34 - down(&ld->sem); 34 + mutex_lock(&ld->props_lock); 35 35 if (ld->props) 36 36 if (!ld->props->check_fb || ld->props->check_fb(evdata->info)) 37 37 ld->props->set_power(ld, *(int *)evdata->data); 38 - up(&ld->sem); 38 + mutex_unlock(&ld->props_lock); 39 39 return 0; 40 40 } 41 41 ··· 66 66 int rc; 67 67 struct lcd_device *ld = to_lcd_device(cdev); 68 68 69 - down(&ld->sem); 69 + mutex_lock(&ld->props_lock); 70 70 if (ld->props && ld->props->get_power) 71 71 rc = sprintf(buf, "%d\n", ld->props->get_power(ld)); 72 72 else 73 73 rc = -ENXIO; 74 - up(&ld->sem); 74 + mutex_unlock(&ld->props_lock); 75 75 76 76 return rc; 77 77 } ··· 89 89 if (size != count) 90 90 return -EINVAL; 91 91 92 - down(&ld->sem); 92 + mutex_lock(&ld->props_lock); 93 93 if (ld->props && ld->props->set_power) { 94 94 pr_debug("lcd: set power to %d\n", power); 95 95 ld->props->set_power(ld, power); 96 96 rc = count; 97 97 } 98 - up(&ld->sem); 98 + mutex_unlock(&ld->props_lock); 99 99 100 100 return rc; 101 101 } ··· 105 105 int rc = -ENXIO; 106 106 struct lcd_device *ld = to_lcd_device(cdev); 107 107 108 - down(&ld->sem); 108 + mutex_lock(&ld->props_lock); 109 109 if (ld->props && ld->props->get_contrast) 110 110 rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld)); 111 - up(&ld->sem); 111 + mutex_unlock(&ld->props_lock); 112 112 113 113 return rc; 114 114 } ··· 126 126 if (size != count) 127 127 return -EINVAL; 128 128 129 - down(&ld->sem); 129 + mutex_lock(&ld->props_lock); 130 130 if (ld->props && ld->props->set_contrast) { 131 131 pr_debug("lcd: set contrast to %d\n", contrast); 132 132 ld->props->set_contrast(ld, contrast); 133 133 rc = count; 134 134 } 135 - up(&ld->sem); 135 + mutex_unlock(&ld->props_lock); 136 136 137 137 return rc; 138 138 } ··· 142 142 int rc = -ENXIO; 143 143 struct lcd_device *ld = to_lcd_device(cdev); 144 144 145 - down(&ld->sem); 145 + mutex_lock(&ld->props_lock); 146 146 if (ld->props) 147 147 rc = sprintf(buf, "%d\n", ld->props->max_contrast); 148 - up(&ld->sem); 148 + mutex_unlock(&ld->props_lock); 149 149 150 150 return rc; 151 151 } ··· 197 197 if (!new_ld) 198 198 return ERR_PTR(-ENOMEM); 199 199 200 - init_MUTEX(&new_ld->sem); 200 + mutex_init(&new_ld->props_lock); 201 201 mutex_init(&new_ld->update_lock); 202 202 new_ld->props = lp; 203 203 memset(&new_ld->class_dev, 0, sizeof(new_ld->class_dev)); ··· 253 253 class_device_remove_file(&ld->class_dev, 254 254 &lcd_class_device_attributes[i]); 255 255 256 - down(&ld->sem); 256 + mutex_lock(&ld->props_lock); 257 257 ld->props = NULL; 258 - up(&ld->sem); 258 + mutex_unlock(&ld->props_lock); 259 259 lcd_unregister_fb(ld); 260 260 class_device_unregister(&ld->class_dev); 261 261 }
+3 -3
include/linux/backlight.h
··· 14 14 15 15 /* Notes on locking: 16 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. 17 + * backlight_device->props_lock is an internal backlight lock protecting the 18 + * props field and no code outside the core should need to touch it. 19 19 * 20 20 * Access to update_status() is serialised by the update_lock mutex since 21 21 * most drivers seem to need this and historically get it wrong. ··· 57 57 /* This protects the 'props' field. If 'props' is NULL, the driver that 58 58 registered this device has been unloaded, and if class_get_devdata() 59 59 points to something in the body of that driver, it is also invalid. */ 60 - struct semaphore sem; 60 + struct mutex props_lock; 61 61 /* If this is NULL, the backing module is unloaded */ 62 62 struct backlight_properties *props; 63 63 /* Serialise access to update_status method */
+2 -2
include/linux/lcd.h
··· 14 14 15 15 /* Notes on locking: 16 16 * 17 - * lcd_device->sem is an internal backlight lock protecting the props 17 + * lcd_device->props_lock is an internal backlight lock protecting the props 18 18 * field and no code outside the core should need to touch it. 19 19 * 20 20 * Access to set_power() is serialised by the update_lock mutex since ··· 52 52 /* This protects the 'props' field. If 'props' is NULL, the driver that 53 53 registered this device has been unloaded, and if class_get_devdata() 54 54 points to something in the body of that driver, it is also invalid. */ 55 - struct semaphore sem; 55 + struct mutex props_lock; 56 56 /* If this is NULL, the backing module is unloaded */ 57 57 struct lcd_properties *props; 58 58 /* Serialise access to set_power method */