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

leds: pca955x: Remove work queue

Now the core implements the work queue, remove it from the drivers,
and switch to using brightness_set_blocking op.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Cc: Nate Case <ncase@xes-inc.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>

authored by

Andrew Lunn and committed by
Jacek Anaszewski
c3482b82 7c4b10a2

+9 -30
+9 -30
drivers/leds/leds-pca955x.c
··· 47 47 #include <linux/leds.h> 48 48 #include <linux/err.h> 49 49 #include <linux/i2c.h> 50 - #include <linux/workqueue.h> 51 50 #include <linux/slab.h> 52 51 53 52 /* LED select registers determine the source that drives LED outputs */ ··· 109 110 110 111 struct pca955x_led { 111 112 struct pca955x *pca955x; 112 - struct work_struct work; 113 - enum led_brightness brightness; 114 113 struct led_classdev led_cdev; 115 114 int led_num; /* 0 .. 15 potentially */ 116 115 char name[32]; ··· 190 193 pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); 191 194 } 192 195 193 - static void pca955x_led_work(struct work_struct *work) 196 + static int pca955x_led_set(struct led_classdev *led_cdev, 197 + enum led_brightness value) 194 198 { 195 199 struct pca955x_led *pca955x_led; 196 200 struct pca955x *pca955x; ··· 199 201 int chip_ls; /* which LSx to use (0-3 potentially) */ 200 202 int ls_led; /* which set of bits within LSx to use (0-3) */ 201 203 202 - pca955x_led = container_of(work, struct pca955x_led, work); 204 + pca955x_led = container_of(led_cdev, struct pca955x_led, led_cdev); 203 205 pca955x = pca955x_led->pca955x; 204 206 205 207 chip_ls = pca955x_led->led_num / 4; ··· 209 211 210 212 ls = pca955x_read_ls(pca955x->client, chip_ls); 211 213 212 - switch (pca955x_led->brightness) { 214 + switch (value) { 213 215 case LED_FULL: 214 216 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON); 215 217 break; ··· 228 230 * just turning off for all other values. 229 231 */ 230 232 pca955x_write_pwm(pca955x->client, 1, 231 - 255 - pca955x_led->brightness); 233 + 255 - value); 232 234 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK1); 233 235 break; 234 236 } ··· 236 238 pca955x_write_ls(pca955x->client, chip_ls, ls); 237 239 238 240 mutex_unlock(&pca955x->lock); 239 - } 240 241 241 - static void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness value) 242 - { 243 - struct pca955x_led *pca955x; 244 - 245 - pca955x = container_of(led_cdev, struct pca955x_led, led_cdev); 246 - 247 - pca955x->brightness = value; 248 - 249 - /* 250 - * Must use workqueue for the actual I/O since I2C operations 251 - * can sleep. 252 - */ 253 - schedule_work(&pca955x->work); 242 + return 0; 254 243 } 255 244 256 245 static int pca955x_probe(struct i2c_client *client, ··· 313 328 } 314 329 315 330 pca955x_led->led_cdev.name = pca955x_led->name; 316 - pca955x_led->led_cdev.brightness_set = pca955x_led_set; 317 - 318 - INIT_WORK(&pca955x_led->work, pca955x_led_work); 331 + pca955x_led->led_cdev.brightness_set_blocking = pca955x_led_set; 319 332 320 333 err = led_classdev_register(&client->dev, 321 334 &pca955x_led->led_cdev); ··· 338 355 return 0; 339 356 340 357 exit: 341 - while (i--) { 358 + while (i--) 342 359 led_classdev_unregister(&pca955x->leds[i].led_cdev); 343 - cancel_work_sync(&pca955x->leds[i].work); 344 - } 345 360 346 361 return err; 347 362 } ··· 349 368 struct pca955x *pca955x = i2c_get_clientdata(client); 350 369 int i; 351 370 352 - for (i = 0; i < pca955x->chipdef->bits; i++) { 371 + for (i = 0; i < pca955x->chipdef->bits; i++) 353 372 led_classdev_unregister(&pca955x->leds[i].led_cdev); 354 - cancel_work_sync(&pca955x->leds[i].work); 355 - } 356 373 357 374 return 0; 358 375 }