leds-lp8860.c (50aa46c4bd7b79a57766537dfa8e8c4d8b174a3a) leds-lp8860.c (a2169c9b762ac64899b2aefb170ea0e16178afd6)
1/*
2 * TI LP8860 4-Channel LED Driver
3 *
4 * Copyright (C) 2014 Texas Instruments
5 *
6 * Author: Dan Murphy <dmurphy@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or

--- 407 unchanged lines hidden (view full) ---

416 }
417
418 led->regulator = devm_regulator_get(&client->dev, "vled");
419 if (IS_ERR(led->regulator))
420 led->regulator = NULL;
421
422 led->client = client;
423 led->led_dev.name = led->label;
1/*
2 * TI LP8860 4-Channel LED Driver
3 *
4 * Copyright (C) 2014 Texas Instruments
5 *
6 * Author: Dan Murphy <dmurphy@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or

--- 407 unchanged lines hidden (view full) ---

416 }
417
418 led->regulator = devm_regulator_get(&client->dev, "vled");
419 if (IS_ERR(led->regulator))
420 led->regulator = NULL;
421
422 led->client = client;
423 led->led_dev.name = led->label;
424 led->led_dev.max_brightness = LED_FULL;
425 led->led_dev.brightness_set_blocking = lp8860_brightness_set;
426
427 mutex_init(&led->lock);
428
429 i2c_set_clientdata(client, led);
430
431 led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config);
432 if (IS_ERR(led->regmap)) {

--- 10 unchanged lines hidden (view full) ---

443 ret);
444 return ret;
445 }
446
447 ret = lp8860_init(led);
448 if (ret)
449 return ret;
450
424 led->led_dev.brightness_set_blocking = lp8860_brightness_set;
425
426 mutex_init(&led->lock);
427
428 i2c_set_clientdata(client, led);
429
430 led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config);
431 if (IS_ERR(led->regmap)) {

--- 10 unchanged lines hidden (view full) ---

442 ret);
443 return ret;
444 }
445
446 ret = lp8860_init(led);
447 if (ret)
448 return ret;
449
451 ret = led_classdev_register(&client->dev, &led->led_dev);
450 ret = devm_led_classdev_register(&client->dev, &led->led_dev);
452 if (ret) {
453 dev_err(&client->dev, "led register err: %d\n", ret);
454 return ret;
455 }
456
457 return 0;
458}
459
460static int lp8860_remove(struct i2c_client *client)
461{
462 struct lp8860_led *led = i2c_get_clientdata(client);
463 int ret;
464
451 if (ret) {
452 dev_err(&client->dev, "led register err: %d\n", ret);
453 return ret;
454 }
455
456 return 0;
457}
458
459static int lp8860_remove(struct i2c_client *client)
460{
461 struct lp8860_led *led = i2c_get_clientdata(client);
462 int ret;
463
465 led_classdev_unregister(&led->led_dev);
466
467 if (led->enable_gpio)
468 gpiod_direction_output(led->enable_gpio, 0);
469
470 if (led->regulator) {
471 ret = regulator_disable(led->regulator);
472 if (ret)
473 dev_err(&led->client->dev,
474 "Failed to disable regulator\n");
475 }
476
464 if (led->enable_gpio)
465 gpiod_direction_output(led->enable_gpio, 0);
466
467 if (led->regulator) {
468 ret = regulator_disable(led->regulator);
469 if (ret)
470 dev_err(&led->client->dev,
471 "Failed to disable regulator\n");
472 }
473
474 mutex_destroy(&led->lock);
475
477 return 0;
478}
479
480static const struct i2c_device_id lp8860_id[] = {
481 { "lp8860", 0 },
482 { }
483};
484MODULE_DEVICE_TABLE(i2c, lp8860_id);
485
476 return 0;
477}
478
479static const struct i2c_device_id lp8860_id[] = {
480 { "lp8860", 0 },
481 { }
482};
483MODULE_DEVICE_TABLE(i2c, lp8860_id);
484
486#ifdef CONFIG_OF
487static const struct of_device_id of_lp8860_leds_match[] = {
488 { .compatible = "ti,lp8860", },
489 {},
490};
491MODULE_DEVICE_TABLE(of, of_lp8860_leds_match);
485static const struct of_device_id of_lp8860_leds_match[] = {
486 { .compatible = "ti,lp8860", },
487 {},
488};
489MODULE_DEVICE_TABLE(of, of_lp8860_leds_match);
492#endif
493
494static struct i2c_driver lp8860_driver = {
495 .driver = {
496 .name = "lp8860",
490
491static struct i2c_driver lp8860_driver = {
492 .driver = {
493 .name = "lp8860",
497 .of_match_table = of_match_ptr(of_lp8860_leds_match),
494 .of_match_table = of_lp8860_leds_match,
498 },
499 .probe = lp8860_probe,
500 .remove = lp8860_remove,
501 .id_table = lp8860_id,
502};
503module_i2c_driver(lp8860_driver);
504
505MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver");
506MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
495 },
496 .probe = lp8860_probe,
497 .remove = lp8860_remove,
498 .id_table = lp8860_id,
499};
500module_i2c_driver(lp8860_driver);
501
502MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver");
503MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
507MODULE_LICENSE("GPL");
504MODULE_LICENSE("GPL v2");