Commit d8fe1606 authored by Álvaro Fernández Rojas's avatar Álvaro Fernández Rojas Committed by Jacek Anaszewski

leds-bcm6328: simplify and improve default-state handling

This patch simplifies and improves the code related to
default-state handling.
It also changes the code to power off the LEDs by default.
Signed-off-by: default avatarÁlvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
parent 79653fbb
...@@ -281,11 +281,10 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -281,11 +281,10 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
"linux,default-trigger", "linux,default-trigger",
NULL); NULL);
spin_lock_irqsave(lock, flags);
if (!of_property_read_string(nc, "default-state", &state)) { if (!of_property_read_string(nc, "default-state", &state)) {
spin_lock_irqsave(lock, flags);
if (!strcmp(state, "on")) { if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
bcm6328_led_mode(led, BCM6328_LED_MODE_ON);
} else if (!strcmp(state, "keep")) { } else if (!strcmp(state, "keep")) {
void __iomem *mode; void __iomem *mode;
unsigned long val, shift; unsigned long val, shift;
...@@ -296,21 +295,28 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -296,21 +295,28 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
else else
mode = mem + BCM6328_REG_MODE_LO; mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >> (shift % 16); val = bcm6328_led_read(mode) >>
BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK; val &= BCM6328_LED_MODE_MASK;
if (val == BCM6328_LED_MODE_ON) if ((led->active_low && val == BCM6328_LED_MODE_ON) ||
(!led->active_low && val == BCM6328_LED_MODE_OFF))
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
else { else
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
}
} else { } else {
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
} }
spin_unlock_irqrestore(lock, flags); } else {
led->cdev.brightness = LED_OFF;
} }
if ((led->active_low && led->cdev.brightness == LED_FULL) ||
(!led->active_low && led->cdev.brightness == LED_OFF))
bcm6328_led_mode(led, BCM6328_LED_MODE_ON);
else
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
spin_unlock_irqrestore(lock, flags);
led->cdev.brightness_set = bcm6328_led_set; led->cdev.brightness_set = bcm6328_led_set;
led->cdev.blink_set = bcm6328_blink_set; led->cdev.blink_set = bcm6328_blink_set;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment