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:
"I just found merge window is open and I'm quite busy and almost forget
to send out this pull request. Thanks Russell and Alexandre ping me
about this.

So basically we got some clean up and leds-pwm fixing patches from
Russell"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
leds: Remove duplicated OOM message for individual driver
drivers/leds: Replace __get_cpu_var use through this_cpu_ptr
leds: lp55xx: add DT bindings for LP55231
leds: 88pm860x: Fix missing refcount decrement for parent of_node
leds: 88pm860x: Use of_get_child_by_name
leds: leds-pwm: add DT support for LEDs wired to supply
leds: leds-pwm: implement PWM inversion
leds: leds-pwm: convert OF parsing code to use led_pwm_add()
leds: leds-pwm: provide a common function to setup a single led-pwm device
leds: pca9685: Remove leds-pca9685 driver
dell-led: add mic mute led interface

+273 -373
+7 -1
Documentation/devicetree/bindings/leds/leds-lp55xx.txt
··· 1 1 Binding for TI/National Semiconductor LP55xx Led Drivers 2 2 3 3 Required properties: 4 - - compatible: "national,lp5521" or "national,lp5523" or "ti,lp5562" or "ti,lp8501" 4 + - compatible: one of 5 + national,lp5521 6 + national,lp5523 7 + ti,lp55231 8 + ti,lp5562 9 + ti,lp8501 10 + 5 11 - reg: I2C slave address 6 12 - clock-mode: Input clock mode, (0: automode, 1: internal, 2: external) 7 13
+2
Documentation/devicetree/bindings/leds/leds-pwm.txt
··· 13 13 For the pwms and pwm-names property please refer to: 14 14 Documentation/devicetree/bindings/pwm/pwm.txt 15 15 - max-brightness : Maximum brightness possible for the LED 16 + - active-low : (optional) For PWMs where the LED is wired to supply 17 + rather than ground. 16 18 - label : (optional) 17 19 see Documentation/devicetree/bindings/leds/common.txt 18 20 - linux,default-trigger : (optional)
-10
drivers/leds/Kconfig
··· 300 300 LED driver chip accessed via the I2C bus. Supported 301 301 devices include PCA9633 and PCA9634 302 302 303 - config LEDS_PCA9685 304 - tristate "LED support for PCA9685 I2C chip" 305 - depends on LEDS_CLASS 306 - depends on I2C 307 - help 308 - This option enables support for LEDs connected to the PCA9685 309 - LED driver chip accessed via the I2C bus. 310 - The PCA9685 offers 12-bit PWM (4095 levels of brightness) on 311 - 16 individual channels. 312 - 313 303 config LEDS_WM831X_STATUS 314 304 tristate "LED support for status LEDs on WM831x PMICs" 315 305 depends on LEDS_CLASS
-1
drivers/leds/Makefile
··· 36 36 obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 37 37 obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 38 38 obj-$(CONFIG_LEDS_PCA963X) += leds-pca963x.o 39 - obj-$(CONFIG_LEDS_PCA9685) += leds-pca9685.o 40 39 obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 41 40 obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o 42 41 obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
+164 -7
drivers/leds/dell-led.c
··· 15 15 #include <linux/leds.h> 16 16 #include <linux/slab.h> 17 17 #include <linux/module.h> 18 + #include <linux/dmi.h> 19 + #include <linux/dell-led.h> 18 20 19 21 MODULE_AUTHOR("Louis Davis/Jim Dailey"); 20 22 MODULE_DESCRIPTION("Dell LED Control Driver"); 21 23 MODULE_LICENSE("GPL"); 22 24 23 25 #define DELL_LED_BIOS_GUID "F6E4FE6E-909D-47cb-8BAB-C9F6F2F8D396" 26 + #define DELL_APP_GUID "A80593CE-A997-11DA-B012-B622A1EF5492" 24 27 MODULE_ALIAS("wmi:" DELL_LED_BIOS_GUID); 25 28 26 29 /* Error Result Codes: */ ··· 41 38 #define CMD_LED_ON 16 42 39 #define CMD_LED_OFF 17 43 40 #define CMD_LED_BLINK 18 41 + 42 + struct app_wmi_args { 43 + u16 class; 44 + u16 selector; 45 + u32 arg1; 46 + u32 arg2; 47 + u32 arg3; 48 + u32 arg4; 49 + u32 res1; 50 + u32 res2; 51 + u32 res3; 52 + u32 res4; 53 + char dummy[92]; 54 + }; 55 + 56 + #define GLOBAL_MIC_MUTE_ENABLE 0x364 57 + #define GLOBAL_MIC_MUTE_DISABLE 0x365 58 + 59 + struct dell_bios_data_token { 60 + u16 tokenid; 61 + u16 location; 62 + u16 value; 63 + }; 64 + 65 + struct __attribute__ ((__packed__)) dell_bios_calling_interface { 66 + struct dmi_header header; 67 + u16 cmd_io_addr; 68 + u8 cmd_io_code; 69 + u32 supported_cmds; 70 + struct dell_bios_data_token damap[]; 71 + }; 72 + 73 + static struct dell_bios_data_token dell_mic_tokens[2]; 74 + 75 + static int dell_wmi_perform_query(struct app_wmi_args *args) 76 + { 77 + struct app_wmi_args *bios_return; 78 + union acpi_object *obj; 79 + struct acpi_buffer input; 80 + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 81 + acpi_status status; 82 + u32 rc = -EINVAL; 83 + 84 + input.length = 128; 85 + input.pointer = args; 86 + 87 + status = wmi_evaluate_method(DELL_APP_GUID, 0, 1, &input, &output); 88 + if (!ACPI_SUCCESS(status)) 89 + goto err_out0; 90 + 91 + obj = output.pointer; 92 + if (!obj) 93 + goto err_out0; 94 + 95 + if (obj->type != ACPI_TYPE_BUFFER) 96 + goto err_out1; 97 + 98 + bios_return = (struct app_wmi_args *)obj->buffer.pointer; 99 + rc = bios_return->res1; 100 + if (rc) 101 + goto err_out1; 102 + 103 + memcpy(args, bios_return, sizeof(struct app_wmi_args)); 104 + rc = 0; 105 + 106 + err_out1: 107 + kfree(obj); 108 + err_out0: 109 + return rc; 110 + } 111 + 112 + static void __init find_micmute_tokens(const struct dmi_header *dm, void *dummy) 113 + { 114 + struct dell_bios_calling_interface *calling_interface; 115 + struct dell_bios_data_token *token; 116 + int token_size = sizeof(struct dell_bios_data_token); 117 + int i = 0; 118 + 119 + if (dm->type == 0xda && dm->length > 17) { 120 + calling_interface = container_of(dm, 121 + struct dell_bios_calling_interface, header); 122 + 123 + token = &calling_interface->damap[i]; 124 + while (token->tokenid != 0xffff) { 125 + if (token->tokenid == GLOBAL_MIC_MUTE_DISABLE) 126 + memcpy(&dell_mic_tokens[0], token, token_size); 127 + else if (token->tokenid == GLOBAL_MIC_MUTE_ENABLE) 128 + memcpy(&dell_mic_tokens[1], token, token_size); 129 + 130 + i++; 131 + token = &calling_interface->damap[i]; 132 + } 133 + } 134 + } 135 + 136 + static int dell_micmute_led_set(int state) 137 + { 138 + struct app_wmi_args args; 139 + struct dell_bios_data_token *token; 140 + 141 + if (!wmi_has_guid(DELL_APP_GUID)) 142 + return -ENODEV; 143 + 144 + if (state == 0 || state == 1) 145 + token = &dell_mic_tokens[state]; 146 + else 147 + return -EINVAL; 148 + 149 + memset(&args, 0, sizeof(struct app_wmi_args)); 150 + 151 + args.class = 1; 152 + args.arg1 = token->location; 153 + args.arg2 = token->value; 154 + 155 + dell_wmi_perform_query(&args); 156 + 157 + return state; 158 + } 159 + 160 + int dell_app_wmi_led_set(int whichled, int on) 161 + { 162 + int state = 0; 163 + 164 + switch (whichled) { 165 + case DELL_LED_MICMUTE: 166 + state = dell_micmute_led_set(on); 167 + break; 168 + default: 169 + pr_warn("led type %x is not supported\n", whichled); 170 + break; 171 + } 172 + 173 + return state; 174 + } 175 + EXPORT_SYMBOL_GPL(dell_app_wmi_led_set); 176 + 177 + static int __init dell_micmute_led_init(void) 178 + { 179 + memset(dell_mic_tokens, 0, sizeof(struct dell_bios_data_token) * 2); 180 + dmi_walk(find_micmute_tokens, NULL); 181 + 182 + return 0; 183 + } 44 184 45 185 struct bios_args { 46 186 unsigned char length; ··· 327 181 { 328 182 int error = 0; 329 183 330 - if (!wmi_has_guid(DELL_LED_BIOS_GUID)) 184 + if (!wmi_has_guid(DELL_LED_BIOS_GUID) && !wmi_has_guid(DELL_APP_GUID)) 331 185 return -ENODEV; 332 186 333 - error = led_off(); 334 - if (error != 0) 335 - return -ENODEV; 187 + if (wmi_has_guid(DELL_APP_GUID)) 188 + error = dell_micmute_led_init(); 336 189 337 - return led_classdev_register(NULL, &dell_led); 190 + if (wmi_has_guid(DELL_LED_BIOS_GUID)) { 191 + error = led_off(); 192 + if (error != 0) 193 + return -ENODEV; 194 + 195 + error = led_classdev_register(NULL, &dell_led); 196 + } 197 + 198 + return error; 338 199 } 339 200 340 201 static void __exit dell_led_exit(void) 341 202 { 342 - led_classdev_unregister(&dell_led); 203 + int error = 0; 343 204 344 - led_off(); 205 + if (wmi_has_guid(DELL_LED_BIOS_GUID)) { 206 + error = led_off(); 207 + if (error == 0) 208 + led_classdev_unregister(&dell_led); 209 + } 345 210 } 346 211 347 212 module_init(dell_led_init);
+2 -3
drivers/leds/leds-88pm860x.c
··· 130 130 struct device_node *nproot, *np; 131 131 int iset = 0; 132 132 133 - nproot = of_node_get(pdev->dev.parent->of_node); 134 - if (!nproot) 133 + if (!pdev->dev.parent->of_node) 135 134 return -ENODEV; 136 - nproot = of_find_node_by_name(nproot, "leds"); 135 + nproot = of_get_child_by_name(pdev->dev.parent->of_node, "leds"); 137 136 if (!nproot) { 138 137 dev_err(&pdev->dev, "failed to find leds node\n"); 139 138 return -ENODEV;
+1 -4
drivers/leds/leds-adp5520.c
··· 120 120 121 121 led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds, 122 122 GFP_KERNEL); 123 - if (led == NULL) { 124 - dev_err(&pdev->dev, "failed to alloc memory\n"); 123 + if (!led) 125 124 return -ENOMEM; 126 - } 127 125 128 126 ret = adp5520_led_prepare(pdev); 129 - 130 127 if (ret) { 131 128 dev_err(&pdev->dev, "failed to write\n"); 132 129 return ret;
+1 -3
drivers/leds/leds-bd2802.c
··· 678 678 int ret, i; 679 679 680 680 led = devm_kzalloc(&client->dev, sizeof(struct bd2802_led), GFP_KERNEL); 681 - if (!led) { 682 - dev_err(&client->dev, "failed to allocate driver data\n"); 681 + if (!led) 683 682 return -ENOMEM; 684 - } 685 683 686 684 led->client = client; 687 685 pdata = led->pdata = dev_get_platdata(&client->dev);
+1 -3
drivers/leds/leds-da903x.c
··· 108 108 } 109 109 110 110 led = devm_kzalloc(&pdev->dev, sizeof(struct da903x_led), GFP_KERNEL); 111 - if (led == NULL) { 112 - dev_err(&pdev->dev, "failed to alloc memory for LED%d\n", id); 111 + if (!led) 113 112 return -ENOMEM; 114 - } 115 113 116 114 led->cdev.name = pdata->name; 117 115 led->cdev.default_trigger = pdata->default_trigger;
+1 -2
drivers/leds/leds-da9052.c
··· 126 126 led = devm_kzalloc(&pdev->dev, 127 127 sizeof(struct da9052_led) * pled->num_leds, 128 128 GFP_KERNEL); 129 - if (led == NULL) { 130 - dev_err(&pdev->dev, "Failed to alloc memory\n"); 129 + if (!led) { 131 130 error = -ENOMEM; 132 131 goto err; 133 132 }
+2 -1
drivers/leds/leds-lp5523.c
··· 1 1 /* 2 - * lp5523.c - LP5523 LED Driver 2 + * lp5523.c - LP5523, LP55231 LED Driver 3 3 * 4 4 * Copyright (C) 2010 Nokia Corporation 5 5 * Copyright (C) 2012 Texas Instruments ··· 814 814 #ifdef CONFIG_OF 815 815 static const struct of_device_id of_lp5523_leds_match[] = { 816 816 { .compatible = "national,lp5523", }, 817 + { .compatible = "ti,lp55231", }, 817 818 {}, 818 819 }; 819 820
-213
drivers/leds/leds-pca9685.c
··· 1 - /* 2 - * Copyright 2013 Maximilian Güntner <maximilian.guentner@gmail.com> 3 - * 4 - * This file is subject to the terms and conditions of version 2 of 5 - * the GNU General Public License. See the file COPYING in the main 6 - * directory of this archive for more details. 7 - * 8 - * Based on leds-pca963x.c driver by 9 - * Peter Meerwald <p.meerwald@bct-electronic.com> 10 - * 11 - * Driver for the NXP PCA9685 12-Bit PWM LED driver chip. 12 - * 13 - */ 14 - 15 - #include <linux/ctype.h> 16 - #include <linux/delay.h> 17 - #include <linux/err.h> 18 - #include <linux/i2c.h> 19 - #include <linux/leds.h> 20 - #include <linux/module.h> 21 - #include <linux/slab.h> 22 - #include <linux/string.h> 23 - #include <linux/workqueue.h> 24 - 25 - #include <linux/platform_data/leds-pca9685.h> 26 - 27 - /* Register Addresses */ 28 - #define PCA9685_MODE1 0x00 29 - #define PCA9685_MODE2 0x01 30 - #define PCA9685_LED0_ON_L 0x06 31 - #define PCA9685_ALL_LED_ON_L 0xFA 32 - 33 - /* MODE1 Register */ 34 - #define PCA9685_ALLCALL 0x00 35 - #define PCA9685_SLEEP 0x04 36 - #define PCA9685_AI 0x05 37 - 38 - /* MODE2 Register */ 39 - #define PCA9685_INVRT 0x04 40 - #define PCA9685_OUTDRV 0x02 41 - 42 - static const struct i2c_device_id pca9685_id[] = { 43 - { "pca9685", 0 }, 44 - { } 45 - }; 46 - MODULE_DEVICE_TABLE(i2c, pca9685_id); 47 - 48 - struct pca9685_led { 49 - struct i2c_client *client; 50 - struct work_struct work; 51 - u16 brightness; 52 - struct led_classdev led_cdev; 53 - int led_num; /* 0-15 */ 54 - char name[32]; 55 - }; 56 - 57 - static void pca9685_write_msg(struct i2c_client *client, u8 *buf, u8 len) 58 - { 59 - struct i2c_msg msg = { 60 - .addr = client->addr, 61 - .flags = 0x00, 62 - .len = len, 63 - .buf = buf 64 - }; 65 - i2c_transfer(client->adapter, &msg, 1); 66 - } 67 - 68 - static void pca9685_all_off(struct i2c_client *client) 69 - { 70 - u8 i2c_buffer[5] = {PCA9685_ALL_LED_ON_L, 0x00, 0x00, 0x00, 0x10}; 71 - pca9685_write_msg(client, i2c_buffer, 5); 72 - } 73 - 74 - static void pca9685_led_work(struct work_struct *work) 75 - { 76 - struct pca9685_led *pca9685; 77 - u8 i2c_buffer[5]; 78 - 79 - pca9685 = container_of(work, struct pca9685_led, work); 80 - i2c_buffer[0] = PCA9685_LED0_ON_L + 4 * pca9685->led_num; 81 - /* 82 - * 4095 is the maximum brightness, so we set the ON time to 0x1000 83 - * which disables the PWM generator for that LED 84 - */ 85 - if (pca9685->brightness == 4095) 86 - *((__le16 *)(i2c_buffer+1)) = cpu_to_le16(0x1000); 87 - else 88 - *((__le16 *)(i2c_buffer+1)) = 0x0000; 89 - 90 - if (pca9685->brightness == 0) 91 - *((__le16 *)(i2c_buffer+3)) = cpu_to_le16(0x1000); 92 - else if (pca9685->brightness == 4095) 93 - *((__le16 *)(i2c_buffer+3)) = 0x0000; 94 - else 95 - *((__le16 *)(i2c_buffer+3)) = cpu_to_le16(pca9685->brightness); 96 - 97 - pca9685_write_msg(pca9685->client, i2c_buffer, 5); 98 - } 99 - 100 - static void pca9685_led_set(struct led_classdev *led_cdev, 101 - enum led_brightness value) 102 - { 103 - struct pca9685_led *pca9685; 104 - pca9685 = container_of(led_cdev, struct pca9685_led, led_cdev); 105 - pca9685->brightness = value; 106 - 107 - schedule_work(&pca9685->work); 108 - } 109 - 110 - static int pca9685_probe(struct i2c_client *client, 111 - const struct i2c_device_id *id) 112 - { 113 - struct pca9685_led *pca9685; 114 - struct pca9685_platform_data *pdata; 115 - int err; 116 - u8 i; 117 - 118 - pdata = dev_get_platdata(&client->dev); 119 - if (pdata) { 120 - if (pdata->leds.num_leds < 1 || pdata->leds.num_leds > 15) { 121 - dev_err(&client->dev, "board info must claim 1-16 LEDs"); 122 - return -EINVAL; 123 - } 124 - } 125 - 126 - pca9685 = devm_kzalloc(&client->dev, 16 * sizeof(*pca9685), GFP_KERNEL); 127 - if (!pca9685) 128 - return -ENOMEM; 129 - 130 - i2c_set_clientdata(client, pca9685); 131 - pca9685_all_off(client); 132 - 133 - for (i = 0; i < 16; i++) { 134 - pca9685[i].client = client; 135 - pca9685[i].led_num = i; 136 - pca9685[i].name[0] = '\0'; 137 - if (pdata && i < pdata->leds.num_leds) { 138 - if (pdata->leds.leds[i].name) 139 - strncpy(pca9685[i].name, 140 - pdata->leds.leds[i].name, 141 - sizeof(pca9685[i].name)-1); 142 - if (pdata->leds.leds[i].default_trigger) 143 - pca9685[i].led_cdev.default_trigger = 144 - pdata->leds.leds[i].default_trigger; 145 - } 146 - if (strlen(pca9685[i].name) == 0) { 147 - /* 148 - * Write adapter and address to the name as well. 149 - * Otherwise multiple chips attached to one host would 150 - * not work. 151 - */ 152 - snprintf(pca9685[i].name, sizeof(pca9685[i].name), 153 - "pca9685:%d:x%.2x:%d", 154 - client->adapter->nr, client->addr, i); 155 - } 156 - pca9685[i].led_cdev.name = pca9685[i].name; 157 - pca9685[i].led_cdev.max_brightness = 0xfff; 158 - pca9685[i].led_cdev.brightness_set = pca9685_led_set; 159 - 160 - INIT_WORK(&pca9685[i].work, pca9685_led_work); 161 - err = led_classdev_register(&client->dev, &pca9685[i].led_cdev); 162 - if (err < 0) 163 - goto exit; 164 - } 165 - 166 - if (pdata) 167 - i2c_smbus_write_byte_data(client, PCA9685_MODE2, 168 - pdata->outdrv << PCA9685_OUTDRV | 169 - pdata->inverted << PCA9685_INVRT); 170 - else 171 - i2c_smbus_write_byte_data(client, PCA9685_MODE2, 172 - PCA9685_TOTEM_POLE << PCA9685_OUTDRV); 173 - /* Enable Auto-Increment, enable oscillator, ALLCALL/SUBADDR disabled */ 174 - i2c_smbus_write_byte_data(client, PCA9685_MODE1, BIT(PCA9685_AI)); 175 - 176 - return 0; 177 - 178 - exit: 179 - while (i--) { 180 - led_classdev_unregister(&pca9685[i].led_cdev); 181 - cancel_work_sync(&pca9685[i].work); 182 - } 183 - return err; 184 - } 185 - 186 - static int pca9685_remove(struct i2c_client *client) 187 - { 188 - struct pca9685_led *pca9685 = i2c_get_clientdata(client); 189 - u8 i; 190 - 191 - for (i = 0; i < 16; i++) { 192 - led_classdev_unregister(&pca9685[i].led_cdev); 193 - cancel_work_sync(&pca9685[i].work); 194 - } 195 - pca9685_all_off(client); 196 - return 0; 197 - } 198 - 199 - static struct i2c_driver pca9685_driver = { 200 - .driver = { 201 - .name = "leds-pca9685", 202 - .owner = THIS_MODULE, 203 - }, 204 - .probe = pca9685_probe, 205 - .remove = pca9685_remove, 206 - .id_table = pca9685_id, 207 - }; 208 - 209 - module_i2c_driver(pca9685_driver); 210 - 211 - MODULE_AUTHOR("Maximilian Güntner <maximilian.guentner@gmail.com>"); 212 - MODULE_DESCRIPTION("PCA9685 LED Driver"); 213 - MODULE_LICENSE("GPL v2");
+79 -83
drivers/leds/leds-pwm.c
··· 69 69 70 70 duty *= brightness; 71 71 do_div(duty, max); 72 + 73 + if (led_dat->active_low) 74 + duty = led_dat->period - duty; 75 + 72 76 led_dat->duty = duty; 73 77 74 78 if (led_dat->can_sleep) ··· 96 92 } 97 93 } 98 94 99 - static int led_pwm_create_of(struct platform_device *pdev, 100 - struct led_pwm_priv *priv) 95 + static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, 96 + struct led_pwm *led, struct device_node *child) 101 97 { 102 - struct device_node *child; 98 + struct led_pwm_data *led_data = &priv->leds[priv->num_leds]; 103 99 int ret; 104 100 105 - for_each_child_of_node(pdev->dev.of_node, child) { 106 - struct led_pwm_data *led_dat = &priv->leds[priv->num_leds]; 101 + led_data->active_low = led->active_low; 102 + led_data->cdev.name = led->name; 103 + led_data->cdev.default_trigger = led->default_trigger; 104 + led_data->cdev.brightness_set = led_pwm_set; 105 + led_data->cdev.brightness = LED_OFF; 106 + led_data->cdev.max_brightness = led->max_brightness; 107 + led_data->cdev.flags = LED_CORE_SUSPENDRESUME; 107 108 108 - led_dat->cdev.name = of_get_property(child, "label", 109 - NULL) ? : child->name; 110 - 111 - led_dat->pwm = devm_of_pwm_get(&pdev->dev, child, NULL); 112 - if (IS_ERR(led_dat->pwm)) { 113 - dev_err(&pdev->dev, "unable to request PWM for %s\n", 114 - led_dat->cdev.name); 115 - ret = PTR_ERR(led_dat->pwm); 116 - goto err; 117 - } 118 - /* Get the period from PWM core when n*/ 119 - led_dat->period = pwm_get_period(led_dat->pwm); 120 - 121 - led_dat->cdev.default_trigger = of_get_property(child, 122 - "linux,default-trigger", NULL); 123 - of_property_read_u32(child, "max-brightness", 124 - &led_dat->cdev.max_brightness); 125 - 126 - led_dat->cdev.brightness_set = led_pwm_set; 127 - led_dat->cdev.brightness = LED_OFF; 128 - led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 129 - 130 - led_dat->can_sleep = pwm_can_sleep(led_dat->pwm); 131 - if (led_dat->can_sleep) 132 - INIT_WORK(&led_dat->work, led_pwm_work); 133 - 134 - ret = led_classdev_register(&pdev->dev, &led_dat->cdev); 135 - if (ret < 0) { 136 - dev_err(&pdev->dev, "failed to register for %s\n", 137 - led_dat->cdev.name); 138 - of_node_put(child); 139 - goto err; 140 - } 141 - priv->num_leds++; 109 + if (child) 110 + led_data->pwm = devm_of_pwm_get(dev, child, NULL); 111 + else 112 + led_data->pwm = devm_pwm_get(dev, led->name); 113 + if (IS_ERR(led_data->pwm)) { 114 + ret = PTR_ERR(led_data->pwm); 115 + dev_err(dev, "unable to request PWM for %s: %d\n", 116 + led->name, ret); 117 + return ret; 142 118 } 143 119 144 - return 0; 145 - err: 146 - led_pwm_cleanup(priv); 120 + if (child) 121 + led_data->period = pwm_get_period(led_data->pwm); 122 + 123 + led_data->can_sleep = pwm_can_sleep(led_data->pwm); 124 + if (led_data->can_sleep) 125 + INIT_WORK(&led_data->work, led_pwm_work); 126 + 127 + led_data->period = pwm_get_period(led_data->pwm); 128 + if (!led_data->period && (led->pwm_period_ns > 0)) 129 + led_data->period = led->pwm_period_ns; 130 + 131 + ret = led_classdev_register(dev, &led_data->cdev); 132 + if (ret == 0) { 133 + priv->num_leds++; 134 + } else { 135 + dev_err(dev, "failed to register PWM led for %s: %d\n", 136 + led->name, ret); 137 + } 138 + 139 + return ret; 140 + } 141 + 142 + static int led_pwm_create_of(struct device *dev, struct led_pwm_priv *priv) 143 + { 144 + struct device_node *child; 145 + struct led_pwm led; 146 + int ret = 0; 147 + 148 + memset(&led, 0, sizeof(led)); 149 + 150 + for_each_child_of_node(dev->of_node, child) { 151 + led.name = of_get_property(child, "label", NULL) ? : 152 + child->name; 153 + 154 + led.default_trigger = of_get_property(child, 155 + "linux,default-trigger", NULL); 156 + led.active_low = of_property_read_bool(child, "active-low"); 157 + of_property_read_u32(child, "max-brightness", 158 + &led.max_brightness); 159 + 160 + ret = led_pwm_add(dev, priv, &led, child); 161 + if (ret) { 162 + of_node_put(child); 163 + break; 164 + } 165 + } 147 166 148 167 return ret; 149 168 } ··· 193 166 194 167 if (pdata) { 195 168 for (i = 0; i < count; i++) { 196 - struct led_pwm *cur_led = &pdata->leds[i]; 197 - struct led_pwm_data *led_dat = &priv->leds[i]; 198 - 199 - led_dat->pwm = devm_pwm_get(&pdev->dev, cur_led->name); 200 - if (IS_ERR(led_dat->pwm)) { 201 - ret = PTR_ERR(led_dat->pwm); 202 - dev_err(&pdev->dev, 203 - "unable to request PWM for %s\n", 204 - cur_led->name); 205 - goto err; 206 - } 207 - 208 - led_dat->cdev.name = cur_led->name; 209 - led_dat->cdev.default_trigger = cur_led->default_trigger; 210 - led_dat->active_low = cur_led->active_low; 211 - led_dat->cdev.brightness_set = led_pwm_set; 212 - led_dat->cdev.brightness = LED_OFF; 213 - led_dat->cdev.max_brightness = cur_led->max_brightness; 214 - led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 215 - 216 - led_dat->can_sleep = pwm_can_sleep(led_dat->pwm); 217 - if (led_dat->can_sleep) 218 - INIT_WORK(&led_dat->work, led_pwm_work); 219 - 220 - led_dat->period = pwm_get_period(led_dat->pwm); 221 - if (!led_dat->period && (cur_led->pwm_period_ns > 0)) 222 - led_dat->period = cur_led->pwm_period_ns; 223 - 224 - ret = led_classdev_register(&pdev->dev, &led_dat->cdev); 225 - if (ret < 0) 226 - goto err; 169 + ret = led_pwm_add(&pdev->dev, priv, &pdata->leds[i], 170 + NULL); 171 + if (ret) 172 + break; 227 173 } 228 - priv->num_leds = count; 229 174 } else { 230 - ret = led_pwm_create_of(pdev, priv); 231 - if (ret) 232 - return ret; 175 + ret = led_pwm_create_of(&pdev->dev, priv); 176 + } 177 + 178 + if (ret) { 179 + led_pwm_cleanup(priv); 180 + return ret; 233 181 } 234 182 235 183 platform_set_drvdata(pdev, priv); 236 184 237 185 return 0; 238 - 239 - err: 240 - priv->num_leds = i; 241 - led_pwm_cleanup(priv); 242 - 243 - return ret; 244 186 } 245 187 246 188 static int led_pwm_remove(struct platform_device *pdev)
+1 -3
drivers/leds/leds-s3c24xx.c
··· 76 76 77 77 led = devm_kzalloc(&dev->dev, sizeof(struct s3c24xx_gpio_led), 78 78 GFP_KERNEL); 79 - if (led == NULL) { 80 - dev_err(&dev->dev, "No memory for device\n"); 79 + if (!led) 81 80 return -ENOMEM; 82 - } 83 81 84 82 platform_set_drvdata(dev, led); 85 83
+1 -3
drivers/leds/leds-sunfire.c
··· 135 135 } 136 136 137 137 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 138 - if (!p) { 139 - dev_err(&pdev->dev, "Could not allocate struct sunfire_drvdata\n"); 138 + if (!p) 140 139 return -ENOMEM; 141 - } 142 140 143 141 for (i = 0; i < NUM_LEDS_PER_BOARD; i++) { 144 142 struct led_classdev *lp = &p->leds[i].led_cdev;
+1 -1
drivers/leds/trigger/ledtrig-cpu.c
··· 47 47 */ 48 48 void ledtrig_cpu(enum cpu_led_event ledevt) 49 49 { 50 - struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); 50 + struct led_trigger_cpu *trig = this_cpu_ptr(&cpu_trig); 51 51 52 52 /* Locate the correct CPU LED */ 53 53 switch (ledevt) {
+10
include/linux/dell-led.h
··· 1 + #ifndef __DELL_LED_H__ 2 + #define __DELL_LED_H__ 3 + 4 + enum { 5 + DELL_LED_MICMUTE, 6 + }; 7 + 8 + int dell_app_wmi_led_set(int whichled, int on); 9 + 10 + #endif
-35
include/linux/platform_data/leds-pca9685.h
··· 1 - /* 2 - * Copyright 2013 Maximilian Güntner <maximilian.guentner@gmail.com> 3 - * 4 - * This file is subject to the terms and conditions of version 2 of 5 - * the GNU General Public License. See the file COPYING in the main 6 - * directory of this archive for more details. 7 - * 8 - * Based on leds-pca963x.h by Peter Meerwald <p.meerwald@bct-electronic.com> 9 - * 10 - * LED driver for the NXP PCA9685 PWM chip 11 - * 12 - */ 13 - 14 - #ifndef __LINUX_PCA9685_H 15 - #define __LINUX_PCA9685_H 16 - 17 - #include <linux/leds.h> 18 - 19 - enum pca9685_outdrv { 20 - PCA9685_OPEN_DRAIN, 21 - PCA9685_TOTEM_POLE, 22 - }; 23 - 24 - enum pca9685_inverted { 25 - PCA9685_NOT_INVERTED, 26 - PCA9685_INVERTED, 27 - }; 28 - 29 - struct pca9685_platform_data { 30 - struct led_platform_data leds; 31 - enum pca9685_outdrv outdrv; 32 - enum pca9685_inverted inverted; 33 - }; 34 - 35 - #endif /* __LINUX_PCA9685_H */