Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds

Pull LED updates from Bryan Wu:
"This cycle we got:
- new driver for leds-mc13783
- bug fixes
- code cleanup"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
leds: make sure we unregister a trigger only once
leds: leds-pwm: properly clean up after probe failure
leds: clevo-mail: Make probe function __init
leds-ot200: Fix dependencies
leds-gpio: of: introduce MODULE_DEVICE_TABLE for module autoloading
leds: clevo-mail: remove __initdata marker
leds: leds-ss4200: remove __initdata marker
leds: blinkm: remove unnecessary spaces
leds: lp5562: remove unnecessary parentheses
leds: leds-ss4200: remove DEFINE_PCI_DEVICE_TABLE macro
leds: leds-s3c24xx: Trivial cleanup in header file
drivers/leds: delete non-required instances of include <linux/init.h>
leds: leds-gpio: add retain-state-suspended property
leds: leds-mc13783: Add devicetree support
leds: leds-mc13783: Remove unnecessary cleaning of registers on exit
leds: leds-mc13783: Use proper "max_brightness" value fo LEDs
leds: leds-mc13783: Use LED core PM functions
leds: leds-mc13783: Add MC34708 LED support
leds: Turn off led if blinking is disabled
ledtrig-cpu: Handle CPU hot(un)plugging

+276 -130
+12
Documentation/devicetree/bindings/leds/leds-gpio.txt
··· 21 21 on). The "keep" setting will keep the LED at whatever its current 22 22 state is, without producing a glitch. The default is off if this 23 23 property is not present. 24 + - retain-state-suspended: (optional) The suspend state can be retained.Such 25 + as charge-led gpio. 24 26 25 27 Examples: 26 28 ··· 50 48 green { 51 49 gpios = <&mpc8572 7 0>; 52 50 default-state = "on"; 51 + }; 52 + }; 53 + 54 + leds { 55 + compatible = "gpio-leds"; 56 + 57 + charger-led { 58 + gpios = <&gpio1 2 0>; 59 + linux,default-trigger = "max8903-charger-charging"; 60 + retain-state-suspended; 53 61 }; 54 62 };
+47
Documentation/devicetree/bindings/mfd/mc13xxx.txt
··· 10 10 - fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used 11 11 12 12 Sub-nodes: 13 + - leds : Contain the led nodes and initial register values in property 14 + "led-control". Number of register depends of used IC, for MC13783 is 6, 15 + for MC13892 is 4, for MC34708 is 1. See datasheet for bits definitions of 16 + these registers. 17 + - #address-cells: Must be 1. 18 + - #size-cells: Must be 0. 19 + Each led node should contain "reg", which used as LED ID (described below). 20 + Optional properties "label" and "linux,default-trigger" is described in 21 + Documentation/devicetree/bindings/leds/common.txt. 13 22 - regulators : Contain the regulator nodes. The regulators are bound using 14 23 their names as listed below with their registers and bits for enabling. 24 + 25 + MC13783 LED IDs: 26 + 0 : Main display 27 + 1 : AUX display 28 + 2 : Keypad 29 + 3 : Red 1 30 + 4 : Green 1 31 + 5 : Blue 1 32 + 6 : Red 2 33 + 7 : Green 2 34 + 8 : Blue 2 35 + 9 : Red 3 36 + 10 : Green 3 37 + 11 : Blue 3 38 + 39 + MC13892 LED IDs: 40 + 0 : Main display 41 + 1 : AUX display 42 + 2 : Keypad 43 + 3 : Red 44 + 4 : Green 45 + 5 : Blue 46 + 47 + MC34708 LED IDs: 48 + 0 : Charger Red 49 + 1 : Charger Green 15 50 16 51 MC13783 regulators: 17 52 sw1a : regulator SW1A (register 24, bit 0) ··· 123 88 reg = <0>; 124 89 interrupt-parent = <&gpio0>; 125 90 interrupts = <8>; 91 + 92 + leds { 93 + #address-cells = <1>; 94 + #size-cells = <0>; 95 + led-control = <0x000 0x000 0x0e0 0x000>; 96 + 97 + sysled { 98 + reg = <3>; 99 + label = "system:red:live"; 100 + linux,default-trigger = "heartbeat"; 101 + }; 102 + }; 126 103 127 104 regulators { 128 105 sw1_reg: mc13892__sw1 {
+2 -2
drivers/leds/Kconfig
··· 416 416 depends on MFD_MC13XXX 417 417 help 418 418 This option enable support for on-chip LED drivers found 419 - on Freescale Semiconductor MC13783/MC13892 PMIC. 419 + on Freescale Semiconductor MC13783/MC13892/MC34708 PMIC. 420 420 421 421 config LEDS_NS2 422 422 tristate "LED support for Network Space v2 GPIO LEDs" ··· 474 474 475 475 config LEDS_OT200 476 476 tristate "LED support for the Bachmann OT200" 477 - depends on LEDS_CLASS && HAS_IOMEM 477 + depends on LEDS_CLASS && HAS_IOMEM && (X86_32 || COMPILE_TEST) 478 478 help 479 479 This option enables support for the LEDs on the Bachmann OT200. 480 480 Say Y to enable LEDs on the Bachmann OT200.
+4 -2
drivers/leds/led-core.c
··· 39 39 led_cdev->blink_delay_on = delay_on; 40 40 led_cdev->blink_delay_off = delay_off; 41 41 42 - /* never on - don't blink */ 43 - if (!delay_on) 42 + /* never on - just set to off */ 43 + if (!delay_on) { 44 + __led_set_brightness(led_cdev, LED_OFF); 44 45 return; 46 + } 45 47 46 48 /* never off - just set to brightness */ 47 49 if (!delay_off) {
+4 -2
drivers/leds/led-triggers.c
··· 13 13 14 14 #include <linux/module.h> 15 15 #include <linux/kernel.h> 16 - #include <linux/init.h> 17 16 #include <linux/list.h> 18 17 #include <linux/spinlock.h> 19 18 #include <linux/device.h> ··· 219 220 { 220 221 struct led_classdev *led_cdev; 221 222 223 + if (list_empty_careful(&trig->next_trig)) 224 + return; 225 + 222 226 /* Remove from the list of led triggers */ 223 227 down_write(&triggers_list_lock); 224 - list_del(&trig->next_trig); 228 + list_del_init(&trig->next_trig); 225 229 up_write(&triggers_list_lock); 226 230 227 231 /* Remove anyone actively using this trigger */
-1
drivers/leds/leds-88pm860x.c
··· 11 11 */ 12 12 13 13 #include <linux/kernel.h> 14 - #include <linux/init.h> 15 14 #include <linux/of.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/i2c.h>
-1
drivers/leds/leds-adp5520.c
··· 15 15 16 16 #include <linux/module.h> 17 17 #include <linux/kernel.h> 18 - #include <linux/init.h> 19 18 #include <linux/platform_device.h> 20 19 #include <linux/leds.h> 21 20 #include <linux/workqueue.h>
-1
drivers/leds/leds-asic3.c
··· 7 7 */ 8 8 9 9 #include <linux/kernel.h> 10 - #include <linux/init.h> 11 10 #include <linux/platform_device.h> 12 11 #include <linux/leds.h> 13 12 #include <linux/slab.h>
+1 -2
drivers/leds/leds-blinkm.c
··· 18 18 */ 19 19 20 20 #include <linux/module.h> 21 - #include <linux/init.h> 22 21 #include <linux/slab.h> 23 22 #include <linux/jiffies.h> 24 23 #include <linux/i2c.h> ··· 443 444 { 444 445 int ret; 445 446 struct blinkm_led *led; 446 - struct blinkm_data *data ; 447 + struct blinkm_data *data; 447 448 struct blinkm_work *blm_work = work_to_blmwork(work); 448 449 449 450 led = blm_work->blinkm_led;
+2 -3
drivers/leds/leds-clevo-mail.c
··· 19 19 MODULE_DESCRIPTION("Clevo mail LED driver"); 20 20 MODULE_LICENSE("GPL"); 21 21 22 - static bool __initdata nodetect; 22 + static bool nodetect; 23 23 module_param_named(nodetect, nodetect, bool, 0); 24 24 MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection"); 25 25 ··· 153 153 .flags = LED_CORE_SUSPENDRESUME, 154 154 }; 155 155 156 - static int clevo_mail_led_probe(struct platform_device *pdev) 156 + static int __init clevo_mail_led_probe(struct platform_device *pdev) 157 157 { 158 158 return led_classdev_register(&pdev->dev, &clevo_mail_led); 159 159 } ··· 165 165 } 166 166 167 167 static struct platform_driver clevo_mail_led_driver = { 168 - .probe = clevo_mail_led_probe, 169 168 .remove = clevo_mail_led_remove, 170 169 .driver = { 171 170 .name = KBUILD_MODNAME,
-1
drivers/leds/leds-cobalt-qube.c
··· 3 3 * 4 4 * Control the Cobalt Qube/RaQ front LED 5 5 */ 6 - #include <linux/init.h> 7 6 #include <linux/io.h> 8 7 #include <linux/ioport.h> 9 8 #include <linux/leds.h>
-1
drivers/leds/leds-da903x.c
··· 14 14 15 15 #include <linux/module.h> 16 16 #include <linux/kernel.h> 17 - #include <linux/init.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/leds.h> 20 19 #include <linux/workqueue.h>
-1
drivers/leds/leds-da9052.c
··· 14 14 15 15 #include <linux/module.h> 16 16 #include <linux/kernel.h> 17 - #include <linux/init.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/leds.h> 20 19 #include <linux/workqueue.h>
-1
drivers/leds/leds-fsg.c
··· 16 16 */ 17 17 18 18 #include <linux/kernel.h> 19 - #include <linux/init.h> 20 19 #include <linux/platform_device.h> 21 20 #include <linux/leds.h> 22 21 #include <linux/module.h>
+5 -1
drivers/leds/leds-gpio.c
··· 11 11 * 12 12 */ 13 13 #include <linux/kernel.h> 14 - #include <linux/init.h> 15 14 #include <linux/platform_device.h> 16 15 #include <linux/gpio.h> 17 16 #include <linux/leds.h> ··· 203 204 led.default_state = LEDS_GPIO_DEFSTATE_OFF; 204 205 } 205 206 207 + if (of_get_property(child, "retain-state-suspended", NULL)) 208 + led.retain_state_suspended = 1; 209 + 206 210 ret = create_gpio_led(&led, &priv->leds[priv->num_leds++], 207 211 &pdev->dev, NULL); 208 212 if (ret < 0) { ··· 226 224 { .compatible = "gpio-leds", }, 227 225 {}, 228 226 }; 227 + 228 + MODULE_DEVICE_TABLE(of, of_gpio_leds_match); 229 229 #else /* CONFIG_OF_GPIO */ 230 230 static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) 231 231 {
-1
drivers/leds/leds-hp6xx.c
··· 12 12 13 13 #include <linux/module.h> 14 14 #include <linux/kernel.h> 15 - #include <linux/init.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/leds.h> 18 17 #include <asm/hd64461.h>
-1
drivers/leds/leds-lm3533.c
··· 12 12 */ 13 13 14 14 #include <linux/module.h> 15 - #include <linux/init.h> 16 15 #include <linux/leds.h> 17 16 #include <linux/mfd/core.h> 18 17 #include <linux/mutex.h>
-1
drivers/leds/leds-lp5521.c
··· 25 25 #include <linux/delay.h> 26 26 #include <linux/firmware.h> 27 27 #include <linux/i2c.h> 28 - #include <linux/init.h> 29 28 #include <linux/leds.h> 30 29 #include <linux/module.h> 31 30 #include <linux/mutex.h>
-1
drivers/leds/leds-lp5523.c
··· 25 25 #include <linux/delay.h> 26 26 #include <linux/firmware.h> 27 27 #include <linux/i2c.h> 28 - #include <linux/init.h> 29 28 #include <linux/leds.h> 30 29 #include <linux/module.h> 31 30 #include <linux/mutex.h>
+3 -4
drivers/leds/leds-lp5562.c
··· 13 13 #include <linux/delay.h> 14 14 #include <linux/firmware.h> 15 15 #include <linux/i2c.h> 16 - #include <linux/init.h> 17 16 #include <linux/leds.h> 18 17 #include <linux/module.h> 19 18 #include <linux/mutex.h> ··· 346 347 /* check the size of program count */ 347 348 static inline bool _is_pc_overflow(struct lp55xx_predef_pattern *ptn) 348 349 { 349 - return (ptn->size_r >= LP5562_PROGRAM_LENGTH || 350 - ptn->size_g >= LP5562_PROGRAM_LENGTH || 351 - ptn->size_b >= LP5562_PROGRAM_LENGTH); 350 + return ptn->size_r >= LP5562_PROGRAM_LENGTH || 351 + ptn->size_g >= LP5562_PROGRAM_LENGTH || 352 + ptn->size_b >= LP5562_PROGRAM_LENGTH; 352 353 } 353 354 354 355 static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode)
-1
drivers/leds/leds-lt3593.c
··· 17 17 */ 18 18 19 19 #include <linux/kernel.h> 20 - #include <linux/init.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/leds.h> 23 22 #include <linux/workqueue.h>
+147 -78
drivers/leds/leds-mc13783.c
··· 1 1 /* 2 - * LEDs driver for Freescale MC13783/MC13892 2 + * LEDs driver for Freescale MC13783/MC13892/MC34708 3 3 * 4 4 * Copyright (C) 2010 Philippe Rétornaz 5 5 * ··· 17 17 18 18 #include <linux/module.h> 19 19 #include <linux/kernel.h> 20 - #include <linux/init.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/leds.h> 22 + #include <linux/of.h> 23 23 #include <linux/workqueue.h> 24 24 #include <linux/mfd/mc13xxx.h> 25 - 26 - #define MC13XXX_REG_LED_CONTROL(x) (51 + (x)) 27 25 28 26 struct mc13xxx_led_devtype { 29 27 int led_min; 30 28 int led_max; 31 29 int num_regs; 30 + u32 ledctrl_base; 32 31 }; 33 32 34 33 struct mc13xxx_led { 35 34 struct led_classdev cdev; 36 35 struct work_struct work; 37 - struct mc13xxx *master; 38 36 enum led_brightness new_brightness; 39 37 int id; 38 + struct mc13xxx_leds *leds; 40 39 }; 41 40 42 41 struct mc13xxx_leds { 42 + struct mc13xxx *master; 43 43 struct mc13xxx_led_devtype *devtype; 44 44 int num_leds; 45 - struct mc13xxx_led led[0]; 45 + struct mc13xxx_led *led; 46 46 }; 47 + 48 + static unsigned int mc13xxx_max_brightness(int id) 49 + { 50 + if (id >= MC13783_LED_MD && id <= MC13783_LED_KP) 51 + return 0x0f; 52 + else if (id >= MC13783_LED_R1 && id <= MC13783_LED_B3) 53 + return 0x1f; 54 + 55 + return 0x3f; 56 + } 47 57 48 58 static void mc13xxx_led_work(struct work_struct *work) 49 59 { 50 60 struct mc13xxx_led *led = container_of(work, struct mc13xxx_led, work); 51 - int reg, mask, value, bank, off, shift; 61 + struct mc13xxx_leds *leds = led->leds; 62 + unsigned int reg, bank, off, shift; 52 63 53 64 switch (led->id) { 54 65 case MC13783_LED_MD: 55 - reg = MC13XXX_REG_LED_CONTROL(2); 56 - shift = 9; 57 - mask = 0x0f; 58 - value = led->new_brightness >> 4; 59 - break; 60 66 case MC13783_LED_AD: 61 - reg = MC13XXX_REG_LED_CONTROL(2); 62 - shift = 13; 63 - mask = 0x0f; 64 - value = led->new_brightness >> 4; 65 - break; 66 67 case MC13783_LED_KP: 67 - reg = MC13XXX_REG_LED_CONTROL(2); 68 - shift = 17; 69 - mask = 0x0f; 70 - value = led->new_brightness >> 4; 68 + reg = 2; 69 + shift = 9 + (led->id - MC13783_LED_MD) * 4; 71 70 break; 72 71 case MC13783_LED_R1: 73 72 case MC13783_LED_G1: ··· 79 80 case MC13783_LED_B3: 80 81 off = led->id - MC13783_LED_R1; 81 82 bank = off / 3; 82 - reg = MC13XXX_REG_LED_CONTROL(3) + bank; 83 + reg = 3 + bank; 83 84 shift = (off - bank * 3) * 5 + 6; 84 - value = led->new_brightness >> 3; 85 - mask = 0x1f; 86 85 break; 87 86 case MC13892_LED_MD: 88 - reg = MC13XXX_REG_LED_CONTROL(0); 89 - shift = 3; 90 - mask = 0x3f; 91 - value = led->new_brightness >> 2; 92 - break; 93 87 case MC13892_LED_AD: 94 - reg = MC13XXX_REG_LED_CONTROL(0); 95 - shift = 15; 96 - mask = 0x3f; 97 - value = led->new_brightness >> 2; 98 - break; 99 88 case MC13892_LED_KP: 100 - reg = MC13XXX_REG_LED_CONTROL(1); 101 - shift = 3; 102 - mask = 0x3f; 103 - value = led->new_brightness >> 2; 89 + reg = (led->id - MC13892_LED_MD) / 2; 90 + shift = 3 + (led->id - MC13892_LED_MD) * 12; 104 91 break; 105 92 case MC13892_LED_R: 106 93 case MC13892_LED_G: 107 94 case MC13892_LED_B: 108 95 off = led->id - MC13892_LED_R; 109 96 bank = off / 2; 110 - reg = MC13XXX_REG_LED_CONTROL(2) + bank; 97 + reg = 2 + bank; 111 98 shift = (off - bank * 2) * 12 + 3; 112 - value = led->new_brightness >> 2; 113 - mask = 0x3f; 99 + break; 100 + case MC34708_LED_R: 101 + case MC34708_LED_G: 102 + reg = 0; 103 + shift = 3 + (led->id - MC34708_LED_R) * 12; 114 104 break; 115 105 default: 116 106 BUG(); 117 107 } 118 108 119 - mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift); 109 + mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg, 110 + mc13xxx_max_brightness(led->id) << shift, 111 + led->new_brightness << shift); 120 112 } 121 113 122 114 static void mc13xxx_led_set(struct led_classdev *led_cdev, ··· 120 130 schedule_work(&led->work); 121 131 } 122 132 133 + #ifdef CONFIG_OF 134 + static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( 135 + struct platform_device *pdev) 136 + { 137 + struct mc13xxx_leds *leds = platform_get_drvdata(pdev); 138 + struct mc13xxx_leds_platform_data *pdata; 139 + struct device_node *parent, *child; 140 + struct device *dev = &pdev->dev; 141 + int i = 0, ret = -ENODATA; 142 + 143 + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 144 + if (!pdata) 145 + return ERR_PTR(-ENOMEM); 146 + 147 + of_node_get(dev->parent->of_node); 148 + 149 + parent = of_find_node_by_name(dev->parent->of_node, "leds"); 150 + if (!parent) 151 + goto out_node_put; 152 + 153 + ret = of_property_read_u32_array(parent, "led-control", 154 + pdata->led_control, 155 + leds->devtype->num_regs); 156 + if (ret) 157 + goto out_node_put; 158 + 159 + pdata->num_leds = of_get_child_count(parent); 160 + 161 + pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led), 162 + GFP_KERNEL); 163 + if (!pdata->led) { 164 + ret = -ENOMEM; 165 + goto out_node_put; 166 + } 167 + 168 + for_each_child_of_node(parent, child) { 169 + const char *str; 170 + u32 tmp; 171 + 172 + if (of_property_read_u32(child, "reg", &tmp)) 173 + continue; 174 + pdata->led[i].id = leds->devtype->led_min + tmp; 175 + 176 + if (!of_property_read_string(child, "label", &str)) 177 + pdata->led[i].name = str; 178 + if (!of_property_read_string(child, "linux,default-trigger", 179 + &str)) 180 + pdata->led[i].default_trigger = str; 181 + 182 + i++; 183 + } 184 + 185 + pdata->num_leds = i; 186 + ret = i > 0 ? 0 : -ENODATA; 187 + 188 + out_node_put: 189 + of_node_put(parent); 190 + 191 + return ret ? ERR_PTR(ret) : pdata; 192 + } 193 + #else 194 + static inline struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( 195 + struct platform_device *pdev) 196 + { 197 + return ERR_PTR(-ENOSYS); 198 + } 199 + #endif 200 + 123 201 static int __init mc13xxx_led_probe(struct platform_device *pdev) 124 202 { 125 - struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); 126 - struct mc13xxx *mcdev = dev_get_drvdata(pdev->dev.parent); 203 + struct device *dev = &pdev->dev; 204 + struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(dev); 205 + struct mc13xxx *mcdev = dev_get_drvdata(dev->parent); 127 206 struct mc13xxx_led_devtype *devtype = 128 207 (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; 129 208 struct mc13xxx_leds *leds; 130 - int i, id, num_leds, ret = -ENODATA; 131 - u32 reg, init_led = 0; 209 + int i, id, ret = -ENODATA; 210 + u32 init_led = 0; 132 211 133 - if (!pdata) { 134 - dev_err(&pdev->dev, "Missing platform data\n"); 135 - return -ENODEV; 136 - } 137 - 138 - num_leds = pdata->num_leds; 139 - 140 - if ((num_leds < 1) || 141 - (num_leds > (devtype->led_max - devtype->led_min + 1))) { 142 - dev_err(&pdev->dev, "Invalid LED count %d\n", num_leds); 143 - return -EINVAL; 144 - } 145 - 146 - leds = devm_kzalloc(&pdev->dev, num_leds * sizeof(struct mc13xxx_led) + 147 - sizeof(struct mc13xxx_leds), GFP_KERNEL); 212 + leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL); 148 213 if (!leds) 149 214 return -ENOMEM; 150 215 151 216 leds->devtype = devtype; 152 - leds->num_leds = num_leds; 217 + leds->master = mcdev; 153 218 platform_set_drvdata(pdev, leds); 154 219 220 + if (dev->parent->of_node) { 221 + pdata = mc13xxx_led_probe_dt(pdev); 222 + if (IS_ERR(pdata)) 223 + return PTR_ERR(pdata); 224 + } else if (!pdata) 225 + return -ENODATA; 226 + 227 + leds->num_leds = pdata->num_leds; 228 + 229 + if ((leds->num_leds < 1) || 230 + (leds->num_leds > (devtype->led_max - devtype->led_min + 1))) { 231 + dev_err(dev, "Invalid LED count %d\n", leds->num_leds); 232 + return -EINVAL; 233 + } 234 + 235 + leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led), 236 + GFP_KERNEL); 237 + if (!leds->led) 238 + return -ENOMEM; 239 + 155 240 for (i = 0; i < devtype->num_regs; i++) { 156 - reg = pdata->led_control[i]; 157 - WARN_ON(reg >= (1 << 24)); 158 - ret = mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), reg); 241 + ret = mc13xxx_reg_write(mcdev, leds->devtype->ledctrl_base + i, 242 + pdata->led_control[i]); 159 243 if (ret) 160 244 return ret; 161 245 } 162 246 163 - for (i = 0; i < num_leds; i++) { 247 + for (i = 0; i < leds->num_leds; i++) { 164 248 const char *name, *trig; 165 249 166 250 ret = -EINVAL; ··· 244 180 trig = pdata->led[i].default_trigger; 245 181 246 182 if ((id > devtype->led_max) || (id < devtype->led_min)) { 247 - dev_err(&pdev->dev, "Invalid ID %i\n", id); 183 + dev_err(dev, "Invalid ID %i\n", id); 248 184 break; 249 185 } 250 186 251 187 if (init_led & (1 << id)) { 252 - dev_warn(&pdev->dev, 253 - "LED %i already initialized\n", id); 188 + dev_warn(dev, "LED %i already initialized\n", id); 254 189 break; 255 190 } 256 191 257 192 init_led |= 1 << id; 258 193 leds->led[i].id = id; 259 - leds->led[i].master = mcdev; 194 + leds->led[i].leds = leds; 260 195 leds->led[i].cdev.name = name; 261 196 leds->led[i].cdev.default_trigger = trig; 197 + leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME; 262 198 leds->led[i].cdev.brightness_set = mc13xxx_led_set; 263 - leds->led[i].cdev.brightness = LED_OFF; 199 + leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id); 264 200 265 201 INIT_WORK(&leds->led[i].work, mc13xxx_led_work); 266 202 267 - ret = led_classdev_register(pdev->dev.parent, 268 - &leds->led[i].cdev); 203 + ret = led_classdev_register(dev->parent, &leds->led[i].cdev); 269 204 if (ret) { 270 - dev_err(&pdev->dev, "Failed to register LED %i\n", id); 205 + dev_err(dev, "Failed to register LED %i\n", id); 271 206 break; 272 207 } 273 208 } ··· 282 219 283 220 static int mc13xxx_led_remove(struct platform_device *pdev) 284 221 { 285 - struct mc13xxx *mcdev = dev_get_drvdata(pdev->dev.parent); 286 222 struct mc13xxx_leds *leds = platform_get_drvdata(pdev); 287 223 int i; 288 224 ··· 290 228 cancel_work_sync(&leds->led[i].work); 291 229 } 292 230 293 - for (i = 0; i < leds->devtype->num_regs; i++) 294 - mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), 0); 295 - 296 231 return 0; 297 232 } 298 233 ··· 297 238 .led_min = MC13783_LED_MD, 298 239 .led_max = MC13783_LED_B3, 299 240 .num_regs = 6, 241 + .ledctrl_base = 51, 300 242 }; 301 243 302 244 static const struct mc13xxx_led_devtype mc13892_led_devtype = { 303 245 .led_min = MC13892_LED_MD, 304 246 .led_max = MC13892_LED_B, 305 247 .num_regs = 4, 248 + .ledctrl_base = 51, 249 + }; 250 + 251 + static const struct mc13xxx_led_devtype mc34708_led_devtype = { 252 + .led_min = MC34708_LED_R, 253 + .led_max = MC34708_LED_G, 254 + .num_regs = 1, 255 + .ledctrl_base = 54, 306 256 }; 307 257 308 258 static const struct platform_device_id mc13xxx_led_id_table[] = { 309 259 { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, }, 310 260 { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, }, 261 + { "mc34708-led", (kernel_ulong_t)&mc34708_led_devtype, }, 311 262 { } 312 263 }; 313 264 MODULE_DEVICE_TABLE(platform, mc13xxx_led_id_table);
-1
drivers/leds/leds-netxbig.c
··· 21 21 */ 22 22 23 23 #include <linux/module.h> 24 - #include <linux/init.h> 25 24 #include <linux/irq.h> 26 25 #include <linux/slab.h> 27 26 #include <linux/spinlock.h>
-1
drivers/leds/leds-ns2.c
··· 23 23 */ 24 24 25 25 #include <linux/kernel.h> 26 - #include <linux/init.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/slab.h> 29 28 #include <linux/gpio.h>
-1
drivers/leds/leds-ot200.c
··· 8 8 */ 9 9 10 10 #include <linux/kernel.h> 11 - #include <linux/init.h> 12 11 #include <linux/platform_device.h> 13 12 #include <linux/slab.h> 14 13 #include <linux/leds.h>
+13 -11
drivers/leds/leds-pwm.c
··· 14 14 15 15 #include <linux/module.h> 16 16 #include <linux/kernel.h> 17 - #include <linux/init.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/of_platform.h> 20 19 #include <linux/fb.h> ··· 83 84 (sizeof(struct led_pwm_data) * num_leds); 84 85 } 85 86 87 + static void led_pwm_cleanup(struct led_pwm_priv *priv) 88 + { 89 + while (priv->num_leds--) { 90 + led_classdev_unregister(&priv->leds[priv->num_leds].cdev); 91 + if (priv->leds[priv->num_leds].can_sleep) 92 + cancel_work_sync(&priv->leds[priv->num_leds].work); 93 + } 94 + } 95 + 86 96 static int led_pwm_create_of(struct platform_device *pdev, 87 97 struct led_pwm_priv *priv) 88 98 { ··· 139 131 140 132 return 0; 141 133 err: 142 - while (priv->num_leds--) 143 - led_classdev_unregister(&priv->leds[priv->num_leds].cdev); 134 + led_pwm_cleanup(priv); 144 135 145 136 return ret; 146 137 } ··· 207 200 return 0; 208 201 209 202 err: 210 - while (i--) 211 - led_classdev_unregister(&priv->leds[i].cdev); 203 + priv->num_leds = i; 204 + led_pwm_cleanup(priv); 212 205 213 206 return ret; 214 207 } ··· 216 209 static int led_pwm_remove(struct platform_device *pdev) 217 210 { 218 211 struct led_pwm_priv *priv = platform_get_drvdata(pdev); 219 - int i; 220 212 221 - for (i = 0; i < priv->num_leds; i++) { 222 - led_classdev_unregister(&priv->leds[i].cdev); 223 - if (priv->leds[i].can_sleep) 224 - cancel_work_sync(&priv->leds[i].work); 225 - } 213 + led_pwm_cleanup(priv); 226 214 227 215 return 0; 228 216 }
-1
drivers/leds/leds-s3c24xx.c
··· 12 12 */ 13 13 14 14 #include <linux/kernel.h> 15 - #include <linux/init.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/leds.h> 18 17 #include <linux/gpio.h>
+2 -2
drivers/leds/leds-ss4200.c
··· 63 63 /* 64 64 * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives. 65 65 */ 66 - static DEFINE_PCI_DEVICE_TABLE(ich7_lpc_pci_id) = { 66 + static const struct pci_device_id ich7_lpc_pci_id[] = { 67 67 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) }, 68 68 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) }, 69 69 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30) }, ··· 78 78 return 1; 79 79 } 80 80 81 - static bool __initdata nodetect; 81 + static bool nodetect; 82 82 module_param_named(nodetect, nodetect, bool, 0); 83 83 MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection"); 84 84
-1
drivers/leds/leds-wm831x-status.c
··· 10 10 */ 11 11 12 12 #include <linux/kernel.h> 13 - #include <linux/init.h> 14 13 #include <linux/platform_device.h> 15 14 #include <linux/slab.h> 16 15 #include <linux/leds.h>
-1
drivers/leds/leds-wm8350.c
··· 10 10 */ 11 11 12 12 #include <linux/kernel.h> 13 - #include <linux/init.h> 14 13 #include <linux/platform_device.h> 15 14 #include <linux/leds.h> 16 15 #include <linux/err.h>
+24
drivers/leds/trigger/ledtrig-cpu.c
··· 26 26 #include <linux/percpu.h> 27 27 #include <linux/syscore_ops.h> 28 28 #include <linux/rwsem.h> 29 + #include <linux/cpu.h> 29 30 #include "../leds.h" 30 31 31 32 #define MAX_NAME_LEN 8 ··· 93 92 .resume = ledtrig_cpu_syscore_resume, 94 93 }; 95 94 95 + static int ledtrig_cpu_notify(struct notifier_block *self, 96 + unsigned long action, void *hcpu) 97 + { 98 + switch (action & ~CPU_TASKS_FROZEN) { 99 + case CPU_STARTING: 100 + ledtrig_cpu(CPU_LED_START); 101 + break; 102 + case CPU_DYING: 103 + ledtrig_cpu(CPU_LED_STOP); 104 + break; 105 + } 106 + 107 + return NOTIFY_OK; 108 + } 109 + 110 + 111 + static struct notifier_block ledtrig_cpu_nb = { 112 + .notifier_call = ledtrig_cpu_notify, 113 + }; 114 + 96 115 static int __init ledtrig_cpu_init(void) 97 116 { 98 117 int cpu; ··· 134 113 } 135 114 136 115 register_syscore_ops(&ledtrig_cpu_syscore_ops); 116 + register_cpu_notifier(&ledtrig_cpu_nb); 137 117 138 118 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); 139 119 ··· 145 123 static void __exit ledtrig_cpu_exit(void) 146 124 { 147 125 int cpu; 126 + 127 + unregister_cpu_notifier(&ledtrig_cpu_nb); 148 128 149 129 for_each_possible_cpu(cpu) { 150 130 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
+6
include/linux/mfd/mc13xxx.h
··· 104 104 MC13892_LED_R, 105 105 MC13892_LED_G, 106 106 MC13892_LED_B, 107 + /* MC34708 LED IDs */ 108 + MC34708_LED_R, 109 + MC34708_LED_G, 107 110 }; 108 111 109 112 struct mc13xxx_led_platform_data { ··· 166 163 #define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21) 167 164 /* MC13892 LED Control 3 */ 168 165 #define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9) 166 + /* MC34708 LED Control 0 */ 167 + #define MC34708_LED_C0_CURRENT_R(x) (((x) & 0x3) << 9) 168 + #define MC34708_LED_C0_CURRENT_G(x) (((x) & 0x3) << 21) 169 169 u32 led_control[MAX_LED_CONTROL_REGS]; 170 170 }; 171 171
+4 -5
include/linux/platform_data/leds-s3c24xx.h
··· 1 - /* arch/arm/mach-s3c2410/include/mach/leds-gpio.h 2 - * 1 + /* 3 2 * Copyright (c) 2006 Simtec Electronics 4 3 * http://armlinux.simtec.co.uk/ 5 4 * Ben Dooks <ben@simtec.co.uk> ··· 10 11 * published by the Free Software Foundation. 11 12 */ 12 13 13 - #ifndef __ASM_ARCH_LEDSGPIO_H 14 - #define __ASM_ARCH_LEDSGPIO_H "leds-gpio.h" 14 + #ifndef __LEDS_S3C24XX_H 15 + #define __LEDS_S3C24XX_H 15 16 16 17 #define S3C24XX_LEDF_ACTLOW (1<<0) /* LED is on when GPIO low */ 17 18 #define S3C24XX_LEDF_TRISTATE (1<<1) /* tristate to turn off */ ··· 24 25 char *def_trigger; 25 26 }; 26 27 27 - #endif /* __ASM_ARCH_LEDSGPIO_H */ 28 + #endif /* __LEDS_S3C24XX_H */