aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lm3642.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-lm3642.c')
-rw-r--r--drivers/leds/leds-lm3642.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c
index ceb6b3cde6fe..d3dec0132769 100644
--- a/drivers/leds/leds-lm3642.c
+++ b/drivers/leds/leds-lm3642.c
@@ -313,6 +313,18 @@ static const struct regmap_config lm3642_regmap = {
313 .max_register = REG_MAX, 313 .max_register = REG_MAX,
314}; 314};
315 315
316static struct attribute *lm3642_flash_attrs[] = {
317 &dev_attr_strobe_pin.attr,
318 NULL
319};
320ATTRIBUTE_GROUPS(lm3642_flash);
321
322static struct attribute *lm3642_torch_attrs[] = {
323 &dev_attr_torch_pin.attr,
324 NULL
325};
326ATTRIBUTE_GROUPS(lm3642_torch);
327
316static int lm3642_probe(struct i2c_client *client, 328static int lm3642_probe(struct i2c_client *client,
317 const struct i2c_device_id *id) 329 const struct i2c_device_id *id)
318{ 330{
@@ -364,17 +376,13 @@ static int lm3642_probe(struct i2c_client *client,
364 chip->cdev_flash.max_brightness = 16; 376 chip->cdev_flash.max_brightness = 16;
365 chip->cdev_flash.brightness_set = lm3642_strobe_brightness_set; 377 chip->cdev_flash.brightness_set = lm3642_strobe_brightness_set;
366 chip->cdev_flash.default_trigger = "flash"; 378 chip->cdev_flash.default_trigger = "flash";
379 chip->cdev_flash.groups = lm3642_flash_groups,
367 err = led_classdev_register((struct device *) 380 err = led_classdev_register((struct device *)
368 &client->dev, &chip->cdev_flash); 381 &client->dev, &chip->cdev_flash);
369 if (err < 0) { 382 if (err < 0) {
370 dev_err(chip->dev, "failed to register flash\n"); 383 dev_err(chip->dev, "failed to register flash\n");
371 goto err_out; 384 goto err_out;
372 } 385 }
373 err = device_create_file(chip->cdev_flash.dev, &dev_attr_strobe_pin);
374 if (err < 0) {
375 dev_err(chip->dev, "failed to create strobe-pin file\n");
376 goto err_create_flash_pin_file;
377 }
378 386
379 /* torch */ 387 /* torch */
380 INIT_WORK(&chip->work_torch, lm3642_deferred_torch_brightness_set); 388 INIT_WORK(&chip->work_torch, lm3642_deferred_torch_brightness_set);
@@ -382,17 +390,13 @@ static int lm3642_probe(struct i2c_client *client,
382 chip->cdev_torch.max_brightness = 8; 390 chip->cdev_torch.max_brightness = 8;
383 chip->cdev_torch.brightness_set = lm3642_torch_brightness_set; 391 chip->cdev_torch.brightness_set = lm3642_torch_brightness_set;
384 chip->cdev_torch.default_trigger = "torch"; 392 chip->cdev_torch.default_trigger = "torch";
393 chip->cdev_torch.groups = lm3642_torch_groups,
385 err = led_classdev_register((struct device *) 394 err = led_classdev_register((struct device *)
386 &client->dev, &chip->cdev_torch); 395 &client->dev, &chip->cdev_torch);
387 if (err < 0) { 396 if (err < 0) {
388 dev_err(chip->dev, "failed to register torch\n"); 397 dev_err(chip->dev, "failed to register torch\n");
389 goto err_create_torch_file; 398 goto err_create_torch_file;
390 } 399 }
391 err = device_create_file(chip->cdev_torch.dev, &dev_attr_torch_pin);
392 if (err < 0) {
393 dev_err(chip->dev, "failed to create torch-pin file\n");
394 goto err_create_torch_pin_file;
395 }
396 400
397 /* indicator */ 401 /* indicator */
398 INIT_WORK(&chip->work_indicator, 402 INIT_WORK(&chip->work_indicator,
@@ -411,12 +415,8 @@ static int lm3642_probe(struct i2c_client *client,
411 return 0; 415 return 0;
412 416
413err_create_indicator_file: 417err_create_indicator_file:
414 device_remove_file(chip->cdev_torch.dev, &dev_attr_torch_pin);
415err_create_torch_pin_file:
416 led_classdev_unregister(&chip->cdev_torch); 418 led_classdev_unregister(&chip->cdev_torch);
417err_create_torch_file: 419err_create_torch_file:
418 device_remove_file(chip->cdev_flash.dev, &dev_attr_strobe_pin);
419err_create_flash_pin_file:
420 led_classdev_unregister(&chip->cdev_flash); 420 led_classdev_unregister(&chip->cdev_flash);
421err_out: 421err_out:
422 return err; 422 return err;
@@ -428,10 +428,8 @@ static int lm3642_remove(struct i2c_client *client)
428 428
429 led_classdev_unregister(&chip->cdev_indicator); 429 led_classdev_unregister(&chip->cdev_indicator);
430 flush_work(&chip->work_indicator); 430 flush_work(&chip->work_indicator);
431 device_remove_file(chip->cdev_torch.dev, &dev_attr_torch_pin);
432 led_classdev_unregister(&chip->cdev_torch); 431 led_classdev_unregister(&chip->cdev_torch);
433 flush_work(&chip->work_torch); 432 flush_work(&chip->work_torch);
434 device_remove_file(chip->cdev_flash.dev, &dev_attr_strobe_pin);
435 led_classdev_unregister(&chip->cdev_flash); 433 led_classdev_unregister(&chip->cdev_flash);
436 flush_work(&chip->work_flash); 434 flush_work(&chip->work_flash);
437 regmap_write(chip->regmap, REG_ENABLE, 0); 435 regmap_write(chip->regmap, REG_ENABLE, 0);