leds: bcm6328: fix signal source assignment for leds 4 to 7
authorJonas Gorski <jonas.gorski@gmail.com>
Fri, 2 Jun 2017 12:17:05 +0000 (14:17 +0200)
committerJacek Anaszewski <jacek.anaszewski@gmail.com>
Tue, 13 Jun 2017 18:36:56 +0000 (20:36 +0200)
Each nibble represents 4 LEDs, and in case of the higher register, bit 0
represents LED 4, so we need to use modulus for the LED number as well.

Fixes: fd7b025a238d0a5440bfa26c585eb78097bf48dc ("leds: add BCM6328 LED driver")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
drivers/leds/leds-bcm6328.c

index 1548259297c185e8cfefb4f6df7127b97755da2b..2cfd9389ee96f8cc69a40681374a19a31aa174ed 100644 (file)
@@ -242,7 +242,7 @@ static int bcm6328_hwled(struct device *dev, struct device_node *nc, u32 reg,
 
                spin_lock_irqsave(lock, flags);
                val = bcm6328_led_read(addr);
-               val |= (BIT(reg) << (((sel % 4) * 4) + 16));
+               val |= (BIT(reg % 4) << (((sel % 4) * 4) + 16));
                bcm6328_led_write(addr, val);
                spin_unlock_irqrestore(lock, flags);
        }
@@ -269,7 +269,7 @@ static int bcm6328_hwled(struct device *dev, struct device_node *nc, u32 reg,
 
                spin_lock_irqsave(lock, flags);
                val = bcm6328_led_read(addr);
-               val |= (BIT(reg) << ((sel % 4) * 4));
+               val |= (BIT(reg % 4) << ((sel % 4) * 4));
                bcm6328_led_write(addr, val);
                spin_unlock_irqrestore(lock, flags);
        }