aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-da903x.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-11 20:40:48 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-11 20:40:48 -0800
commit2c487121e3c4f87e82cff493872675bde52e47fc (patch)
treec32f72d674c3503cff63063804de6b4e990d9545 /drivers/leds/leds-da903x.c
parentMerge tag 'edac_for_4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp (diff)
parentleds: add HAS_IOMEM dependency to LEDS_BCM6328/LEDS_BCM6358 (diff)
downloadlinux-dev-2c487121e3c4f87e82cff493872675bde52e47fc.tar.xz
linux-dev-2c487121e3c4f87e82cff493872675bde52e47fc.zip
Merge tag 'leds-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
Pull LED subsystem updates from Jacek Anaszewski: "Besides regular driver updates, we introduce a portion of LED core improvements, that allow to avoid the need for using work queues in the LED class drivers, that set brightness in a blocking way. Affected LED class drivers are being optimized accordingly. - LED core improvements: - use EXPORT_SYMBOL_GPL consistently, - add two new LED_BLINK_ flags, - rename brightness_set_sync op to brightness_set_blocking, - add led_set_brightness_nosleep{nopm} functions, - use set_brightness_work for the blocking op, - drivers shouldn't enforce SYNC/ASYNC brightness setting, - turn off the LED and wait for completion on unregistering LED class device, - add managed version of led_trigger_register, - add description of brightness setting API to the LED class doc. - Remove work queues from drivers: leds-tlc591xx, leds-88pm860x, leds-adp5520, leds-bd2802, leds-blinkm, leds-lm3533, leds-lm3642, leds-pca9532, leds-lp3944, leds-lp55xx, leds-lp8788, leds-lp8860, leds-pca955x, leds-pca963x, leds-wm831x, leds-da903x, leds-da9052, leds-dac124d085, leds-lt3593, leds-max8997, leds-mc13783, leds-regulator, leds-wm8350, leds-max77693, leds-aat1290, leds-ktd2692, leds-gpio, leds-pwm, leds-lm355x, leds-ns2. - Replace brightness_set op with a new brightness_set_blocking op to make the drivers compatible with led triggers: leds-ipaq-micro, leds-powernv. - Add missing of_node_put: leds-ktd2692, leds-aat1290, leds-max77693. - Make the driver explicitly non-modular: ledtrig-cpu, ledtrig-ide-disk, leds-syscon. - Improvements to leds-bcm6328: - reuse bcm6328_led_set() instead of copying its functionality, - swap LED ON and OFF definitions, - improve blink support, - simplify duplicated unlock in bcm6328_blink_set, - add little endian support, - remove unneded lock when checking initial LED status, - add HAS_IOMEM dependency, - code cleaning. - Improvements to leds-bcm6358: - use bcm6358_led_set() in order to get rid of the lock, - merge bcm6358_led_mode and bcm6358_led_set, - add little endian support, - remove unneded lock when checking initial LED status, - add HAS_IOMEM dependency, - remove unneeded busy status check. - Call led_pwm_set() in leds-pwm to enforce default LED_OFF. - Fix duration to be msec instead of jiffies: ledtrig-transient. - Removing NULL check: leds-powernv. - Use platform_register/unregister_drivers(): leds-sunfire. - Fix module license specification: ledtrig-oneshot. - Fix driver description and make license match the header: leds-pwm. - Remove checking for state < 1 in flash_strobe_store(): led-class-flash. - Use led_set_brightness_sync for torch brightness: v4l2-flash-led-class" * tag 'leds-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: (68 commits) leds: add HAS_IOMEM dependency to LEDS_BCM6328/LEDS_BCM6358 leds: core: add managed version of led_trigger_register leds: bcm6358: remove unneeded busy status check leds: bcm6328: improve blink support leds: bcm6358: merge bcm6358_led_mode and bcm6358_led_set leds: bcm6328: simplify duplicated unlock in bcm6328_blink_set leds: bcm6358: add little endian support leds: bcm6328: add little endian support leds: bcm6358: remove unneded lock when checking initial LED status leds: bcm6358: Use bcm6358_led_set() in order to get rid of the lock leds: bcm6328: remove unneded lock when checking initial LED leds: bcm6328: code cleaning leds: syscon: Make the driver explicitly non-modular leds: ledtrig-ide-disk: Make the driver explicitly non-modular leds: ledtrig-cpu: Make the driver explicitly non-modular leds: sunfire: Use platform_register/unregister_drivers() leds: max77693: Add missing of_node_put leds: aat1290: Add missing of_node_put leds: powernv: Implement brightness_set_blocking op leds: ipaq-micro: Implement brightness_set_blocking op ...
Diffstat (limited to 'drivers/leds/leds-da903x.c')
-rw-r--r--drivers/leds/leds-da903x.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c
index 952ba96e5b38..4752a2b6ba2b 100644
--- a/drivers/leds/leds-da903x.c
+++ b/drivers/leds/leds-da903x.c
@@ -16,7 +16,6 @@
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
-#include <linux/workqueue.h>
#include <linux/mfd/da903x.h>
#include <linux/slab.h>
@@ -33,9 +32,7 @@
struct da903x_led {
struct led_classdev cdev;
- struct work_struct work;
struct device *master;
- enum led_brightness new_brightness;
int id;
int flags;
};
@@ -43,11 +40,13 @@ struct da903x_led {
#define DA9030_LED_OFFSET(id) ((id) - DA9030_ID_LED_1)
#define DA9034_LED_OFFSET(id) ((id) - DA9034_ID_LED_1)
-static void da903x_led_work(struct work_struct *work)
+static int da903x_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
{
- struct da903x_led *led = container_of(work, struct da903x_led, work);
+ struct da903x_led *led =
+ container_of(led_cdev, struct da903x_led, cdev);
uint8_t val;
- int offset;
+ int offset, ret = -EINVAL;
switch (led->id) {
case DA9030_ID_LED_1:
@@ -57,37 +56,31 @@ static void da903x_led_work(struct work_struct *work)
case DA9030_ID_LED_PC:
offset = DA9030_LED_OFFSET(led->id);
val = led->flags & ~0x87;
- val |= (led->new_brightness) ? 0x80 : 0; /* EN bit */
- val |= (0x7 - (led->new_brightness >> 5)) & 0x7; /* PWM<2:0> */
- da903x_write(led->master, DA9030_LED1_CONTROL + offset, val);
+ val |= value ? 0x80 : 0; /* EN bit */
+ val |= (0x7 - (value >> 5)) & 0x7; /* PWM<2:0> */
+ ret = da903x_write(led->master, DA9030_LED1_CONTROL + offset,
+ val);
break;
case DA9030_ID_VIBRA:
val = led->flags & ~0x80;
- val |= (led->new_brightness) ? 0x80 : 0; /* EN bit */
- da903x_write(led->master, DA9030_MISC_CONTROL_A, val);
+ val |= value ? 0x80 : 0; /* EN bit */
+ ret = da903x_write(led->master, DA9030_MISC_CONTROL_A, val);
break;
case DA9034_ID_LED_1:
case DA9034_ID_LED_2:
offset = DA9034_LED_OFFSET(led->id);
- val = (led->new_brightness * 0x5f / LED_FULL) & 0x7f;
+ val = (value * 0x5f / LED_FULL) & 0x7f;
val |= (led->flags & DA9034_LED_RAMP) ? 0x80 : 0;
- da903x_write(led->master, DA9034_LED1_CONTROL + offset, val);
+ ret = da903x_write(led->master, DA9034_LED1_CONTROL + offset,
+ val);
break;
case DA9034_ID_VIBRA:
- val = led->new_brightness & 0xfe;
- da903x_write(led->master, DA9034_VIBRA, val);
+ val = value & 0xfe;
+ ret = da903x_write(led->master, DA9034_VIBRA, val);
break;
}
-}
-static void da903x_led_set(struct led_classdev *led_cdev,
- enum led_brightness value)
-{
- struct da903x_led *led;
-
- led = container_of(led_cdev, struct da903x_led, cdev);
- led->new_brightness = value;
- schedule_work(&led->work);
+ return ret;
}
static int da903x_led_probe(struct platform_device *pdev)
@@ -113,15 +106,12 @@ static int da903x_led_probe(struct platform_device *pdev)
led->cdev.name = pdata->name;
led->cdev.default_trigger = pdata->default_trigger;
- led->cdev.brightness_set = da903x_led_set;
+ led->cdev.brightness_set_blocking = da903x_led_set;
led->cdev.brightness = LED_OFF;
led->id = id;
led->flags = pdata->flags;
led->master = pdev->dev.parent;
- led->new_brightness = LED_OFF;
-
- INIT_WORK(&led->work, da903x_led_work);
ret = led_classdev_register(led->master, &led->cdev);
if (ret) {