diff options
30 files changed, 164 insertions, 158 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 48cce18e9d6d..a20752f562bc 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -211,7 +211,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) | |||
211 | led_trigger_set_default(led_cdev); | 211 | led_trigger_set_default(led_cdev); |
212 | #endif | 212 | #endif |
213 | 213 | ||
214 | printk(KERN_DEBUG "Registered led device: %s\n", | 214 | dev_dbg(parent, "Registered led device: %s\n", |
215 | led_cdev->name); | 215 | led_cdev->name); |
216 | 216 | ||
217 | return 0; | 217 | return 0; |
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 262eb4193710..3c972b2f9893 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
@@ -166,6 +166,19 @@ void led_trigger_set_default(struct led_classdev *led_cdev) | |||
166 | } | 166 | } |
167 | EXPORT_SYMBOL_GPL(led_trigger_set_default); | 167 | EXPORT_SYMBOL_GPL(led_trigger_set_default); |
168 | 168 | ||
169 | void led_trigger_rename_static(const char *name, struct led_trigger *trig) | ||
170 | { | ||
171 | /* new name must be on a temporary string to prevent races */ | ||
172 | BUG_ON(name == trig->name); | ||
173 | |||
174 | down_write(&triggers_list_lock); | ||
175 | /* this assumes that trig->name was originaly allocated to | ||
176 | * non constant storage */ | ||
177 | strcpy((char *)trig->name, name); | ||
178 | up_write(&triggers_list_lock); | ||
179 | } | ||
180 | EXPORT_SYMBOL_GPL(led_trigger_rename_static); | ||
181 | |||
169 | /* LED Trigger Interface */ | 182 | /* LED Trigger Interface */ |
170 | 183 | ||
171 | int led_trigger_register(struct led_trigger *trig) | 184 | int led_trigger_register(struct led_trigger *trig) |
@@ -300,13 +313,13 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp) | |||
300 | if (err < 0) { | 313 | if (err < 0) { |
301 | kfree(trig); | 314 | kfree(trig); |
302 | trig = NULL; | 315 | trig = NULL; |
303 | printk(KERN_WARNING "LED trigger %s failed to register" | 316 | pr_warn("LED trigger %s failed to register (%d)\n", |
304 | " (%d)\n", name, err); | 317 | name, err); |
305 | } | 318 | } |
306 | } else | 319 | } else { |
307 | printk(KERN_WARNING "LED trigger %s failed to register" | 320 | pr_warn("LED trigger %s failed to register (no memory)\n", |
308 | " (no memory)\n", name); | 321 | name); |
309 | 322 | } | |
310 | *tp = trig; | 323 | *tp = trig; |
311 | } | 324 | } |
312 | EXPORT_SYMBOL_GPL(led_trigger_register_simple); | 325 | EXPORT_SYMBOL_GPL(led_trigger_register_simple); |
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index b7e8cc0957fc..6be2edd41173 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c | |||
@@ -165,15 +165,13 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
165 | res = platform_get_resource_byname(pdev, IORESOURCE_REG, "control"); | 165 | res = platform_get_resource_byname(pdev, IORESOURCE_REG, "control"); |
166 | if (!res) { | 166 | if (!res) { |
167 | dev_err(&pdev->dev, "No REG resource for control\n"); | 167 | dev_err(&pdev->dev, "No REG resource for control\n"); |
168 | ret = -ENXIO; | 168 | return -ENXIO; |
169 | goto out; | ||
170 | } | 169 | } |
171 | data->reg_control = res->start; | 170 | data->reg_control = res->start; |
172 | res = platform_get_resource_byname(pdev, IORESOURCE_REG, "blink"); | 171 | res = platform_get_resource_byname(pdev, IORESOURCE_REG, "blink"); |
173 | if (!res) { | 172 | if (!res) { |
174 | dev_err(&pdev->dev, "No REG resource for blink\n"); | 173 | dev_err(&pdev->dev, "No REG resource for blink\n"); |
175 | ret = -ENXIO; | 174 | return -ENXIO; |
176 | goto out; | ||
177 | } | 175 | } |
178 | data->reg_blink = res->start; | 176 | data->reg_blink = res->start; |
179 | memset(data->name, 0, MFD_NAME_SIZE); | 177 | memset(data->name, 0, MFD_NAME_SIZE); |
@@ -224,9 +222,6 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
224 | } | 222 | } |
225 | pm860x_led_set(&data->cdev, 0); | 223 | pm860x_led_set(&data->cdev, 0); |
226 | return 0; | 224 | return 0; |
227 | out: | ||
228 | devm_kfree(&pdev->dev, data); | ||
229 | return ret; | ||
230 | } | 225 | } |
231 | 226 | ||
232 | static int pm860x_led_remove(struct platform_device *pdev) | 227 | static int pm860x_led_remove(struct platform_device *pdev) |
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c index dcd9128a51a9..e8072abe76e5 100644 --- a/drivers/leds/leds-adp5520.c +++ b/drivers/leds/leds-adp5520.c | |||
@@ -5,10 +5,10 @@ | |||
5 | * | 5 | * |
6 | * Loosely derived from leds-da903x: | 6 | * Loosely derived from leds-da903x: |
7 | * Copyright (C) 2008 Compulab, Ltd. | 7 | * Copyright (C) 2008 Compulab, Ltd. |
8 | * Mike Rapoport <mike@compulab.co.il> | 8 | * Mike Rapoport <mike@compulab.co.il> |
9 | * | 9 | * |
10 | * Copyright (C) 2006-2008 Marvell International Ltd. | 10 | * Copyright (C) 2006-2008 Marvell International Ltd. |
11 | * Eric Miao <eric.miao@marvell.com> | 11 | * Eric Miao <eric.miao@marvell.com> |
12 | * | 12 | * |
13 | * Licensed under the GPL-2 or later. | 13 | * Licensed under the GPL-2 or later. |
14 | */ | 14 | */ |
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c index 9abe8de40edd..851517030cc1 100644 --- a/drivers/leds/leds-bd2802.c +++ b/drivers/leds/leds-bd2802.c | |||
@@ -26,8 +26,8 @@ | |||
26 | #define BD2802_LED_OFFSET 0xa | 26 | #define BD2802_LED_OFFSET 0xa |
27 | #define BD2802_COLOR_OFFSET 0x3 | 27 | #define BD2802_COLOR_OFFSET 0x3 |
28 | 28 | ||
29 | #define BD2802_REG_CLKSETUP 0x00 | 29 | #define BD2802_REG_CLKSETUP 0x00 |
30 | #define BD2802_REG_CONTROL 0x01 | 30 | #define BD2802_REG_CONTROL 0x01 |
31 | #define BD2802_REG_HOURSETUP 0x02 | 31 | #define BD2802_REG_HOURSETUP 0x02 |
32 | #define BD2802_REG_CURRENT1SETUP 0x03 | 32 | #define BD2802_REG_CURRENT1SETUP 0x03 |
33 | #define BD2802_REG_CURRENT2SETUP 0x04 | 33 | #define BD2802_REG_CURRENT2SETUP 0x04 |
@@ -93,7 +93,7 @@ struct bd2802_led { | |||
93 | * In ADF mode, user can set registers of BD2802GU directly, | 93 | * In ADF mode, user can set registers of BD2802GU directly, |
94 | * therefore BD2802GU doesn't enter reset state. | 94 | * therefore BD2802GU doesn't enter reset state. |
95 | */ | 95 | */ |
96 | int adf_on; | 96 | int adf_on; |
97 | 97 | ||
98 | enum led_ids led_id; | 98 | enum led_ids led_id; |
99 | enum led_colors color; | 99 | enum led_colors color; |
@@ -328,7 +328,7 @@ static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ | |||
328 | int ret; \ | 328 | int ret; \ |
329 | if (!count) \ | 329 | if (!count) \ |
330 | return -EINVAL; \ | 330 | return -EINVAL; \ |
331 | ret = strict_strtoul(buf, 16, &val); \ | 331 | ret = kstrtoul(buf, 16, &val); \ |
332 | if (ret) \ | 332 | if (ret) \ |
333 | return ret; \ | 333 | return ret; \ |
334 | down_write(&led->rwsem); \ | 334 | down_write(&led->rwsem); \ |
@@ -492,7 +492,7 @@ static ssize_t bd2802_store_##attr_name(struct device *dev, \ | |||
492 | int ret; \ | 492 | int ret; \ |
493 | if (!count) \ | 493 | if (!count) \ |
494 | return -EINVAL; \ | 494 | return -EINVAL; \ |
495 | ret = strict_strtoul(buf, 16, &val); \ | 495 | ret = kstrtoul(buf, 16, &val); \ |
496 | if (ret) \ | 496 | if (ret) \ |
497 | return ret; \ | 497 | return ret; \ |
498 | down_write(&led->rwsem); \ | 498 | down_write(&led->rwsem); \ |
diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c index b02547052e12..6a8405df76a3 100644 --- a/drivers/leds/leds-clevo-mail.c +++ b/drivers/leds/leds-clevo-mail.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
1 | 2 | ||
2 | #include <linux/module.h> | 3 | #include <linux/module.h> |
3 | 4 | ||
@@ -26,7 +27,7 @@ static struct platform_device *pdev; | |||
26 | 27 | ||
27 | static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id) | 28 | static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id) |
28 | { | 29 | { |
29 | printk(KERN_INFO KBUILD_MODNAME ": '%s' found\n", id->ident); | 30 | pr_info("'%s' found\n", id->ident); |
30 | return 1; | 31 | return 1; |
31 | } | 32 | } |
32 | 33 | ||
@@ -135,8 +136,7 @@ static int clevo_mail_led_blink(struct led_classdev *led_cdev, | |||
135 | status = 0; | 136 | status = 0; |
136 | 137 | ||
137 | } else { | 138 | } else { |
138 | printk(KERN_DEBUG KBUILD_MODNAME | 139 | pr_debug("clevo_mail_led_blink(..., %lu, %lu)," |
139 | ": clevo_mail_led_blink(..., %lu, %lu)," | ||
140 | " returning -EINVAL (unsupported)\n", | 140 | " returning -EINVAL (unsupported)\n", |
141 | *delay_on, *delay_off); | 141 | *delay_on, *delay_off); |
142 | } | 142 | } |
@@ -183,7 +183,7 @@ static int __init clevo_mail_led_init(void) | |||
183 | count = dmi_check_system(clevo_mail_led_dmi_table); | 183 | count = dmi_check_system(clevo_mail_led_dmi_table); |
184 | } else { | 184 | } else { |
185 | count = 1; | 185 | count = 1; |
186 | printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. " | 186 | pr_err("Skipping DMI detection. " |
187 | "If the driver works on your hardware please " | 187 | "If the driver works on your hardware please " |
188 | "report model and the output of dmidecode in tracker " | 188 | "report model and the output of dmidecode in tracker " |
189 | "at http://sourceforge.net/projects/clevo-mailled/\n"); | 189 | "at http://sourceforge.net/projects/clevo-mailled/\n"); |
@@ -197,8 +197,7 @@ static int __init clevo_mail_led_init(void) | |||
197 | error = platform_driver_probe(&clevo_mail_led_driver, | 197 | error = platform_driver_probe(&clevo_mail_led_driver, |
198 | clevo_mail_led_probe); | 198 | clevo_mail_led_probe); |
199 | if (error) { | 199 | if (error) { |
200 | printk(KERN_ERR KBUILD_MODNAME | 200 | pr_err("Can't probe platform driver\n"); |
201 | ": Can't probe platform driver\n"); | ||
202 | platform_device_unregister(pdev); | 201 | platform_device_unregister(pdev); |
203 | } | 202 | } |
204 | } else | 203 | } else |
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c index ffa99303b629..8abcb66db01c 100644 --- a/drivers/leds/leds-cobalt-qube.c +++ b/drivers/leds/leds-cobalt-qube.c | |||
@@ -43,7 +43,7 @@ static int cobalt_qube_led_probe(struct platform_device *pdev) | |||
43 | if (!res) | 43 | if (!res) |
44 | return -EBUSY; | 44 | return -EBUSY; |
45 | 45 | ||
46 | led_port = ioremap(res->start, resource_size(res)); | 46 | led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
47 | if (!led_port) | 47 | if (!led_port) |
48 | return -ENOMEM; | 48 | return -ENOMEM; |
49 | 49 | ||
@@ -52,12 +52,11 @@ static int cobalt_qube_led_probe(struct platform_device *pdev) | |||
52 | 52 | ||
53 | retval = led_classdev_register(&pdev->dev, &qube_front_led); | 53 | retval = led_classdev_register(&pdev->dev, &qube_front_led); |
54 | if (retval) | 54 | if (retval) |
55 | goto err_iounmap; | 55 | goto err_null; |
56 | 56 | ||
57 | return 0; | 57 | return 0; |
58 | 58 | ||
59 | err_iounmap: | 59 | err_null: |
60 | iounmap(led_port); | ||
61 | led_port = NULL; | 60 | led_port = NULL; |
62 | 61 | ||
63 | return retval; | 62 | return retval; |
@@ -67,10 +66,8 @@ static int cobalt_qube_led_remove(struct platform_device *pdev) | |||
67 | { | 66 | { |
68 | led_classdev_unregister(&qube_front_led); | 67 | led_classdev_unregister(&qube_front_led); |
69 | 68 | ||
70 | if (led_port) { | 69 | if (led_port) |
71 | iounmap(led_port); | ||
72 | led_port = NULL; | 70 | led_port = NULL; |
73 | } | ||
74 | 71 | ||
75 | return 0; | 72 | return 0; |
76 | } | 73 | } |
diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c index d52e47de396f..001088b31373 100644 --- a/drivers/leds/leds-cobalt-raq.c +++ b/drivers/leds/leds-cobalt-raq.c | |||
@@ -85,13 +85,13 @@ static int cobalt_raq_led_probe(struct platform_device *pdev) | |||
85 | if (!res) | 85 | if (!res) |
86 | return -EBUSY; | 86 | return -EBUSY; |
87 | 87 | ||
88 | led_port = ioremap(res->start, resource_size(res)); | 88 | led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
89 | if (!led_port) | 89 | if (!led_port) |
90 | return -ENOMEM; | 90 | return -ENOMEM; |
91 | 91 | ||
92 | retval = led_classdev_register(&pdev->dev, &raq_power_off_led); | 92 | retval = led_classdev_register(&pdev->dev, &raq_power_off_led); |
93 | if (retval) | 93 | if (retval) |
94 | goto err_iounmap; | 94 | goto err_null; |
95 | 95 | ||
96 | retval = led_classdev_register(&pdev->dev, &raq_web_led); | 96 | retval = led_classdev_register(&pdev->dev, &raq_web_led); |
97 | if (retval) | 97 | if (retval) |
@@ -102,8 +102,7 @@ static int cobalt_raq_led_probe(struct platform_device *pdev) | |||
102 | err_unregister: | 102 | err_unregister: |
103 | led_classdev_unregister(&raq_power_off_led); | 103 | led_classdev_unregister(&raq_power_off_led); |
104 | 104 | ||
105 | err_iounmap: | 105 | err_null: |
106 | iounmap(led_port); | ||
107 | led_port = NULL; | 106 | led_port = NULL; |
108 | 107 | ||
109 | return retval; | 108 | return retval; |
@@ -114,10 +113,8 @@ static int cobalt_raq_led_remove(struct platform_device *pdev) | |||
114 | led_classdev_unregister(&raq_power_off_led); | 113 | led_classdev_unregister(&raq_power_off_led); |
115 | led_classdev_unregister(&raq_web_led); | 114 | led_classdev_unregister(&raq_web_led); |
116 | 115 | ||
117 | if (led_port) { | 116 | if (led_port) |
118 | iounmap(led_port); | ||
119 | led_port = NULL; | 117 | led_port = NULL; |
120 | } | ||
121 | 118 | ||
122 | return 0; | 119 | return 0; |
123 | } | 120 | } |
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c index 6f31b776765b..c263a21db829 100644 --- a/drivers/leds/leds-da903x.c +++ b/drivers/leds/leds-da903x.c | |||
@@ -2,10 +2,10 @@ | |||
2 | * LEDs driver for Dialog Semiconductor DA9030/DA9034 | 2 | * LEDs driver for Dialog Semiconductor DA9030/DA9034 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Compulab, Ltd. | 4 | * Copyright (C) 2008 Compulab, Ltd. |
5 | * Mike Rapoport <mike@compulab.co.il> | 5 | * Mike Rapoport <mike@compulab.co.il> |
6 | * | 6 | * |
7 | * Copyright (C) 2006-2008 Marvell International Ltd. | 7 | * Copyright (C) 2006-2008 Marvell International Ltd. |
8 | * Eric Miao <eric.miao@marvell.com> | 8 | * Eric Miao <eric.miao@marvell.com> |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
@@ -85,7 +85,7 @@ static void da903x_led_set(struct led_classdev *led_cdev, | |||
85 | enum led_brightness value) | 85 | enum led_brightness value) |
86 | { | 86 | { |
87 | struct da903x_led *led; | 87 | struct da903x_led *led; |
88 | 88 | ||
89 | led = container_of(led_cdev, struct da903x_led, cdev); | 89 | led = container_of(led_cdev, struct da903x_led, cdev); |
90 | led->new_brightness = value; | 90 | led->new_brightness = value; |
91 | schedule_work(&led->work); | 91 | schedule_work(&led->work); |
@@ -156,7 +156,7 @@ static struct platform_driver da903x_led_driver = { | |||
156 | module_platform_driver(da903x_led_driver); | 156 | module_platform_driver(da903x_led_driver); |
157 | 157 | ||
158 | MODULE_DESCRIPTION("LEDs driver for Dialog Semiconductor DA9030/DA9034"); | 158 | MODULE_DESCRIPTION("LEDs driver for Dialog Semiconductor DA9030/DA9034"); |
159 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>" | 159 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); |
160 | "Mike Rapoport <mike@compulab.co.il>"); | 160 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); |
161 | MODULE_LICENSE("GPL"); | 161 | MODULE_LICENSE("GPL"); |
162 | MODULE_ALIAS("platform:da903x-led"); | 162 | MODULE_ALIAS("platform:da903x-led"); |
diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c index b9053fa6e253..b4d5a44cc41b 100644 --- a/drivers/leds/leds-fsg.c +++ b/drivers/leds/leds-fsg.c | |||
@@ -20,8 +20,8 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/leds.h> | 21 | #include <linux/leds.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/io.h> | ||
23 | #include <mach/hardware.h> | 24 | #include <mach/hardware.h> |
24 | #include <asm/io.h> | ||
25 | 25 | ||
26 | #define FSG_LED_WLAN_BIT 0 | 26 | #define FSG_LED_WLAN_BIT 0 |
27 | #define FSG_LED_WAN_BIT 1 | 27 | #define FSG_LED_WAN_BIT 1 |
@@ -149,11 +149,10 @@ static int fsg_led_probe(struct platform_device *pdev) | |||
149 | int ret; | 149 | int ret; |
150 | 150 | ||
151 | /* Map the LED chip select address space */ | 151 | /* Map the LED chip select address space */ |
152 | latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512); | 152 | latch_address = (unsigned short *) devm_ioremap(&pdev->dev, |
153 | if (!latch_address) { | 153 | IXP4XX_EXP_BUS_BASE(2), 512); |
154 | ret = -ENOMEM; | 154 | if (!latch_address) |
155 | goto failremap; | 155 | return -ENOMEM; |
156 | } | ||
157 | 156 | ||
158 | latch_value = 0xffff; | 157 | latch_value = 0xffff; |
159 | *latch_address = latch_value; | 158 | *latch_address = latch_value; |
@@ -195,8 +194,6 @@ static int fsg_led_probe(struct platform_device *pdev) | |||
195 | failwan: | 194 | failwan: |
196 | led_classdev_unregister(&fsg_wlan_led); | 195 | led_classdev_unregister(&fsg_wlan_led); |
197 | failwlan: | 196 | failwlan: |
198 | iounmap(latch_address); | ||
199 | failremap: | ||
200 | 197 | ||
201 | return ret; | 198 | return ret; |
202 | } | 199 | } |
@@ -210,8 +207,6 @@ static int fsg_led_remove(struct platform_device *pdev) | |||
210 | led_classdev_unregister(&fsg_sync_led); | 207 | led_classdev_unregister(&fsg_sync_led); |
211 | led_classdev_unregister(&fsg_ring_led); | 208 | led_classdev_unregister(&fsg_ring_led); |
212 | 209 | ||
213 | iounmap(latch_address); | ||
214 | |||
215 | return 0; | 210 | return 0; |
216 | } | 211 | } |
217 | 212 | ||
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 291c20797ca0..1885a26776b1 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/pinctrl/consumer.h> | 23 | #include <linux/pinctrl/consumer.h> |
24 | #include <linux/err.h> | ||
24 | 25 | ||
25 | struct gpio_led_data { | 26 | struct gpio_led_data { |
26 | struct led_classdev cdev; | 27 | struct led_classdev cdev; |
@@ -101,15 +102,11 @@ static int create_gpio_led(const struct gpio_led *template, | |||
101 | 102 | ||
102 | /* skip leds that aren't available */ | 103 | /* skip leds that aren't available */ |
103 | if (!gpio_is_valid(template->gpio)) { | 104 | if (!gpio_is_valid(template->gpio)) { |
104 | printk(KERN_INFO "Skipping unavailable LED gpio %d (%s)\n", | 105 | dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n", |
105 | template->gpio, template->name); | 106 | template->gpio, template->name); |
106 | return 0; | 107 | return 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | ret = gpio_request(template->gpio, template->name); | ||
110 | if (ret < 0) | ||
111 | return ret; | ||
112 | |||
113 | led_dat->cdev.name = template->name; | 110 | led_dat->cdev.name = template->name; |
114 | led_dat->cdev.default_trigger = template->default_trigger; | 111 | led_dat->cdev.default_trigger = template->default_trigger; |
115 | led_dat->gpio = template->gpio; | 112 | led_dat->gpio = template->gpio; |
@@ -129,20 +126,19 @@ static int create_gpio_led(const struct gpio_led *template, | |||
129 | if (!template->retain_state_suspended) | 126 | if (!template->retain_state_suspended) |
130 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | 127 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; |
131 | 128 | ||
132 | ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state); | 129 | ret = devm_gpio_request_one(parent, template->gpio, |
130 | GPIOF_DIR_OUT | (led_dat->active_low ^ state), | ||
131 | template->name); | ||
133 | if (ret < 0) | 132 | if (ret < 0) |
134 | goto err; | 133 | return ret; |
135 | 134 | ||
136 | INIT_WORK(&led_dat->work, gpio_led_work); | 135 | INIT_WORK(&led_dat->work, gpio_led_work); |
137 | 136 | ||
138 | ret = led_classdev_register(parent, &led_dat->cdev); | 137 | ret = led_classdev_register(parent, &led_dat->cdev); |
139 | if (ret < 0) | 138 | if (ret < 0) |
140 | goto err; | 139 | return ret; |
141 | 140 | ||
142 | return 0; | 141 | return 0; |
143 | err: | ||
144 | gpio_free(led_dat->gpio); | ||
145 | return ret; | ||
146 | } | 142 | } |
147 | 143 | ||
148 | static void delete_gpio_led(struct gpio_led_data *led) | 144 | static void delete_gpio_led(struct gpio_led_data *led) |
@@ -151,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led) | |||
151 | return; | 147 | return; |
152 | led_classdev_unregister(&led->cdev); | 148 | led_classdev_unregister(&led->cdev); |
153 | cancel_work_sync(&led->work); | 149 | cancel_work_sync(&led->work); |
154 | gpio_free(led->gpio); | ||
155 | } | 150 | } |
156 | 151 | ||
157 | struct gpio_leds_priv { | 152 | struct gpio_leds_priv { |
@@ -176,12 +171,16 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) | |||
176 | /* count LEDs in this device, so we know how much to allocate */ | 171 | /* count LEDs in this device, so we know how much to allocate */ |
177 | count = of_get_child_count(np); | 172 | count = of_get_child_count(np); |
178 | if (!count) | 173 | if (!count) |
179 | return NULL; | 174 | return ERR_PTR(-ENODEV); |
175 | |||
176 | for_each_child_of_node(np, child) | ||
177 | if (of_get_gpio(child, 0) == -EPROBE_DEFER) | ||
178 | return ERR_PTR(-EPROBE_DEFER); | ||
180 | 179 | ||
181 | priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), | 180 | priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), |
182 | GFP_KERNEL); | 181 | GFP_KERNEL); |
183 | if (!priv) | 182 | if (!priv) |
184 | return NULL; | 183 | return ERR_PTR(-ENOMEM); |
185 | 184 | ||
186 | for_each_child_of_node(np, child) { | 185 | for_each_child_of_node(np, child) { |
187 | struct gpio_led led = {}; | 186 | struct gpio_led led = {}; |
@@ -216,7 +215,7 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) | |||
216 | err: | 215 | err: |
217 | for (count = priv->num_leds - 2; count >= 0; count--) | 216 | for (count = priv->num_leds - 2; count >= 0; count--) |
218 | delete_gpio_led(&priv->leds[count]); | 217 | delete_gpio_led(&priv->leds[count]); |
219 | return NULL; | 218 | return ERR_PTR(-ENODEV); |
220 | } | 219 | } |
221 | 220 | ||
222 | static const struct of_device_id of_gpio_leds_match[] = { | 221 | static const struct of_device_id of_gpio_leds_match[] = { |
@@ -226,7 +225,7 @@ static const struct of_device_id of_gpio_leds_match[] = { | |||
226 | #else /* CONFIG_OF_GPIO */ | 225 | #else /* CONFIG_OF_GPIO */ |
227 | static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) | 226 | static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) |
228 | { | 227 | { |
229 | return NULL; | 228 | return ERR_PTR(-ENODEV); |
230 | } | 229 | } |
231 | #endif /* CONFIG_OF_GPIO */ | 230 | #endif /* CONFIG_OF_GPIO */ |
232 | 231 | ||
@@ -264,8 +263,8 @@ static int gpio_led_probe(struct platform_device *pdev) | |||
264 | } | 263 | } |
265 | } else { | 264 | } else { |
266 | priv = gpio_leds_create_of(pdev); | 265 | priv = gpio_leds_create_of(pdev); |
267 | if (!priv) | 266 | if (IS_ERR(priv)) |
268 | return -ENODEV; | 267 | return PTR_ERR(priv); |
269 | } | 268 | } |
270 | 269 | ||
271 | platform_set_drvdata(pdev, priv); | 270 | platform_set_drvdata(pdev, priv); |
diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c index b13ce0371918..65d79284c488 100644 --- a/drivers/leds/leds-lm355x.c +++ b/drivers/leds/leds-lm355x.c | |||
@@ -408,10 +408,10 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev, | |||
408 | return size; | 408 | return size; |
409 | out: | 409 | out: |
410 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); | 410 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); |
411 | return size; | 411 | return ret; |
412 | } | 412 | } |
413 | 413 | ||
414 | static DEVICE_ATTR(pattern, 0666, NULL, lm3556_indicator_pattern_store); | 414 | static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); |
415 | 415 | ||
416 | static const struct regmap_config lm355x_regmap = { | 416 | static const struct regmap_config lm355x_regmap = { |
417 | .reg_bits = 8, | 417 | .reg_bits = 8, |
diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c index 215a7c1e56cc..07b3dde90613 100644 --- a/drivers/leds/leds-lm3642.c +++ b/drivers/leds/leds-lm3642.c | |||
@@ -201,13 +201,13 @@ static ssize_t lm3642_torch_pin_store(struct device *dev, | |||
201 | return size; | 201 | return size; |
202 | out: | 202 | out: |
203 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); | 203 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); |
204 | return size; | 204 | return ret; |
205 | out_strtoint: | 205 | out_strtoint: |
206 | dev_err(chip->dev, "%s: fail to change str to int\n", __func__); | 206 | dev_err(chip->dev, "%s: fail to change str to int\n", __func__); |
207 | return size; | 207 | return ret; |
208 | } | 208 | } |
209 | 209 | ||
210 | static DEVICE_ATTR(torch_pin, 0666, NULL, lm3642_torch_pin_store); | 210 | static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); |
211 | 211 | ||
212 | static void lm3642_deferred_torch_brightness_set(struct work_struct *work) | 212 | static void lm3642_deferred_torch_brightness_set(struct work_struct *work) |
213 | { | 213 | { |
@@ -258,13 +258,13 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev, | |||
258 | return size; | 258 | return size; |
259 | out: | 259 | out: |
260 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); | 260 | dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); |
261 | return size; | 261 | return ret; |
262 | out_strtoint: | 262 | out_strtoint: |
263 | dev_err(chip->dev, "%s: fail to change str to int\n", __func__); | 263 | dev_err(chip->dev, "%s: fail to change str to int\n", __func__); |
264 | return size; | 264 | return ret; |
265 | } | 265 | } |
266 | 266 | ||
267 | static DEVICE_ATTR(strobe_pin, 0666, NULL, lm3642_strobe_pin_store); | 267 | static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); |
268 | 268 | ||
269 | static void lm3642_deferred_strobe_brightness_set(struct work_struct *work) | 269 | static void lm3642_deferred_strobe_brightness_set(struct work_struct *work) |
270 | { | 270 | { |
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c index b081f67e1dea..0c4386e656c1 100644 --- a/drivers/leds/leds-lp3944.c +++ b/drivers/leds/leds-lp3944.c | |||
@@ -86,7 +86,7 @@ static int lp3944_reg_read(struct i2c_client *client, u8 reg, u8 *value) | |||
86 | 86 | ||
87 | tmp = i2c_smbus_read_byte_data(client, reg); | 87 | tmp = i2c_smbus_read_byte_data(client, reg); |
88 | if (tmp < 0) | 88 | if (tmp < 0) |
89 | return -EINVAL; | 89 | return tmp; |
90 | 90 | ||
91 | *value = tmp; | 91 | *value = tmp; |
92 | 92 | ||
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 966f158a07db..cb8a5220200b 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -152,7 +152,7 @@ static int lp5521_read(struct i2c_client *client, u8 reg, u8 *buf) | |||
152 | 152 | ||
153 | ret = i2c_smbus_read_byte_data(client, reg); | 153 | ret = i2c_smbus_read_byte_data(client, reg); |
154 | if (ret < 0) | 154 | if (ret < 0) |
155 | return -EIO; | 155 | return ret; |
156 | 156 | ||
157 | *buf = ret; | 157 | *buf = ret; |
158 | return 0; | 158 | return 0; |
@@ -616,7 +616,7 @@ static ssize_t store_led_pattern(struct device *dev, | |||
616 | unsigned long val; | 616 | unsigned long val; |
617 | int ret; | 617 | int ret; |
618 | 618 | ||
619 | ret = strict_strtoul(buf, 16, &val); | 619 | ret = kstrtoul(buf, 16, &val); |
620 | if (ret) | 620 | if (ret) |
621 | return ret; | 621 | return ret; |
622 | 622 | ||
@@ -788,10 +788,17 @@ static int lp5521_probe(struct i2c_client *client, | |||
788 | * LP5521_REG_ENABLE register will not have any effect - strange! | 788 | * LP5521_REG_ENABLE register will not have any effect - strange! |
789 | */ | 789 | */ |
790 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); | 790 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); |
791 | if (ret || buf != LP5521_REG_R_CURR_DEFAULT) { | 791 | if (ret) { |
792 | dev_err(&client->dev, "error in resetting chip\n"); | 792 | dev_err(&client->dev, "error in resetting chip\n"); |
793 | goto fail2; | 793 | goto fail2; |
794 | } | 794 | } |
795 | if (buf != LP5521_REG_R_CURR_DEFAULT) { | ||
796 | dev_err(&client->dev, | ||
797 | "unexpected data in register (expected 0x%x got 0x%x)\n", | ||
798 | LP5521_REG_R_CURR_DEFAULT, buf); | ||
799 | ret = -EINVAL; | ||
800 | goto fail2; | ||
801 | } | ||
795 | usleep_range(10000, 20000); | 802 | usleep_range(10000, 20000); |
796 | 803 | ||
797 | ret = lp5521_detect(client); | 804 | ret = lp5521_detect(client); |
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 7e304b7ff779..7f5be8948cde 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -171,7 +171,7 @@ static int lp5523_read(struct i2c_client *client, u8 reg, u8 *buf) | |||
171 | s32 ret = i2c_smbus_read_byte_data(client, reg); | 171 | s32 ret = i2c_smbus_read_byte_data(client, reg); |
172 | 172 | ||
173 | if (ret < 0) | 173 | if (ret < 0) |
174 | return -EIO; | 174 | return ret; |
175 | 175 | ||
176 | *buf = ret; | 176 | *buf = ret; |
177 | return 0; | 177 | return 0; |
@@ -248,7 +248,10 @@ static int lp5523_configure(struct i2c_client *client) | |||
248 | 248 | ||
249 | /* Let the programs run for couple of ms and check the engine status */ | 249 | /* Let the programs run for couple of ms and check the engine status */ |
250 | usleep_range(3000, 6000); | 250 | usleep_range(3000, 6000); |
251 | lp5523_read(client, LP5523_REG_STATUS, &status); | 251 | ret = lp5523_read(client, LP5523_REG_STATUS, &status); |
252 | if (ret < 0) | ||
253 | return ret; | ||
254 | |||
252 | status &= LP5523_ENG_STATUS_MASK; | 255 | status &= LP5523_ENG_STATUS_MASK; |
253 | 256 | ||
254 | if (status == LP5523_ENG_STATUS_MASK) { | 257 | if (status == LP5523_ENG_STATUS_MASK) { |
@@ -464,10 +467,16 @@ static ssize_t lp5523_selftest(struct device *dev, | |||
464 | LP5523_EN_LEDTEST | 16); | 467 | LP5523_EN_LEDTEST | 16); |
465 | usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */ | 468 | usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */ |
466 | ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); | 469 | ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); |
470 | if (ret < 0) | ||
471 | goto fail; | ||
472 | |||
467 | if (!(status & LP5523_LEDTEST_DONE)) | 473 | if (!(status & LP5523_LEDTEST_DONE)) |
468 | usleep_range(3000, 6000); /* Was not ready. Wait little bit */ | 474 | usleep_range(3000, 6000); /* Was not ready. Wait little bit */ |
469 | 475 | ||
470 | ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); | 476 | ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); |
477 | if (ret < 0) | ||
478 | goto fail; | ||
479 | |||
471 | vdd--; /* There may be some fluctuation in measurement */ | 480 | vdd--; /* There may be some fluctuation in measurement */ |
472 | 481 | ||
473 | for (i = 0; i < LP5523_LEDS; i++) { | 482 | for (i = 0; i < LP5523_LEDS; i++) { |
@@ -489,9 +498,14 @@ static ssize_t lp5523_selftest(struct device *dev, | |||
489 | /* ADC conversion time is 2.7 ms typically */ | 498 | /* ADC conversion time is 2.7 ms typically */ |
490 | usleep_range(3000, 6000); | 499 | usleep_range(3000, 6000); |
491 | ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); | 500 | ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); |
501 | if (ret < 0) | ||
502 | goto fail; | ||
503 | |||
492 | if (!(status & LP5523_LEDTEST_DONE)) | 504 | if (!(status & LP5523_LEDTEST_DONE)) |
493 | usleep_range(3000, 6000);/* Was not ready. Wait. */ | 505 | usleep_range(3000, 6000);/* Was not ready. Wait. */ |
494 | ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); | 506 | ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); |
507 | if (ret < 0) | ||
508 | goto fail; | ||
495 | 509 | ||
496 | if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) | 510 | if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) |
497 | pos += sprintf(buf + pos, "LED %d FAIL\n", i); | 511 | pos += sprintf(buf + pos, "LED %d FAIL\n", i); |
@@ -696,7 +710,7 @@ static ssize_t store_current(struct device *dev, | |||
696 | ssize_t ret; | 710 | ssize_t ret; |
697 | unsigned long curr; | 711 | unsigned long curr; |
698 | 712 | ||
699 | if (strict_strtoul(buf, 0, &curr)) | 713 | if (kstrtoul(buf, 0, &curr)) |
700 | return -EINVAL; | 714 | return -EINVAL; |
701 | 715 | ||
702 | if (curr > led->max_current) | 716 | if (curr > led->max_current) |
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 34b3ba4376fc..c9b9e1fec587 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c | |||
@@ -89,15 +89,11 @@ static int create_lt3593_led(const struct gpio_led *template, | |||
89 | 89 | ||
90 | /* skip leds on GPIOs that aren't available */ | 90 | /* skip leds on GPIOs that aren't available */ |
91 | if (!gpio_is_valid(template->gpio)) { | 91 | if (!gpio_is_valid(template->gpio)) { |
92 | printk(KERN_INFO "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n", | 92 | dev_info(parent, "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n", |
93 | KBUILD_MODNAME, template->gpio, template->name); | 93 | KBUILD_MODNAME, template->gpio, template->name); |
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
96 | 96 | ||
97 | ret = gpio_request(template->gpio, template->name); | ||
98 | if (ret < 0) | ||
99 | return ret; | ||
100 | |||
101 | led_dat->cdev.name = template->name; | 97 | led_dat->cdev.name = template->name; |
102 | led_dat->cdev.default_trigger = template->default_trigger; | 98 | led_dat->cdev.default_trigger = template->default_trigger; |
103 | led_dat->gpio = template->gpio; | 99 | led_dat->gpio = template->gpio; |
@@ -110,24 +106,21 @@ static int create_lt3593_led(const struct gpio_led *template, | |||
110 | if (!template->retain_state_suspended) | 106 | if (!template->retain_state_suspended) |
111 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | 107 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; |
112 | 108 | ||
113 | ret = gpio_direction_output(led_dat->gpio, state); | 109 | ret = devm_gpio_request_one(parent, template->gpio, |
110 | GPIOF_DIR_OUT | state, template->name); | ||
114 | if (ret < 0) | 111 | if (ret < 0) |
115 | goto err; | 112 | return ret; |
116 | 113 | ||
117 | INIT_WORK(&led_dat->work, lt3593_led_work); | 114 | INIT_WORK(&led_dat->work, lt3593_led_work); |
118 | 115 | ||
119 | ret = led_classdev_register(parent, &led_dat->cdev); | 116 | ret = led_classdev_register(parent, &led_dat->cdev); |
120 | if (ret < 0) | 117 | if (ret < 0) |
121 | goto err; | 118 | return ret; |
122 | 119 | ||
123 | printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n", | 120 | dev_info(parent, "%s: registered LT3593 LED '%s' at GPIO %d\n", |
124 | KBUILD_MODNAME, template->name, template->gpio); | 121 | KBUILD_MODNAME, template->name, template->gpio); |
125 | 122 | ||
126 | return 0; | 123 | return 0; |
127 | |||
128 | err: | ||
129 | gpio_free(led_dat->gpio); | ||
130 | return ret; | ||
131 | } | 124 | } |
132 | 125 | ||
133 | static void delete_lt3593_led(struct lt3593_led_data *led) | 126 | static void delete_lt3593_led(struct lt3593_led_data *led) |
@@ -137,7 +130,6 @@ static void delete_lt3593_led(struct lt3593_led_data *led) | |||
137 | 130 | ||
138 | led_classdev_unregister(&led->cdev); | 131 | led_classdev_unregister(&led->cdev); |
139 | cancel_work_sync(&led->work); | 132 | cancel_work_sync(&led->work); |
140 | gpio_free(led->gpio); | ||
141 | } | 133 | } |
142 | 134 | ||
143 | static int lt3593_led_probe(struct platform_device *pdev) | 135 | static int lt3593_led_probe(struct platform_device *pdev) |
diff --git a/drivers/leds/leds-net48xx.c b/drivers/leds/leds-net48xx.c index f117f7326c5b..27d06c528246 100644 --- a/drivers/leds/leds-net48xx.c +++ b/drivers/leds/leds-net48xx.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/leds.h> | 16 | #include <linux/leds.h> |
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | #include <asm/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/nsc_gpio.h> | 19 | #include <linux/nsc_gpio.h> |
20 | #include <linux/scx200_gpio.h> | 20 | #include <linux/scx200_gpio.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index 58a800b17dc7..c61c5ebcc08e 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c | |||
@@ -243,7 +243,7 @@ static ssize_t netxbig_led_sata_store(struct device *dev, | |||
243 | int mode_val; | 243 | int mode_val; |
244 | int ret; | 244 | int ret; |
245 | 245 | ||
246 | ret = strict_strtoul(buff, 10, &enable); | 246 | ret = kstrtoul(buff, 10, &enable); |
247 | if (ret < 0) | 247 | if (ret < 0) |
248 | return ret; | 248 | return ret; |
249 | 249 | ||
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 7b75affb308a..d978171c25b4 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c | |||
@@ -150,7 +150,7 @@ static ssize_t ns2_led_sata_store(struct device *dev, | |||
150 | unsigned long enable; | 150 | unsigned long enable; |
151 | enum ns2_led_modes mode; | 151 | enum ns2_led_modes mode; |
152 | 152 | ||
153 | ret = strict_strtoul(buff, 10, &enable); | 153 | ret = kstrtoul(buff, 10, &enable); |
154 | if (ret < 0) | 154 | if (ret < 0) |
155 | return ret; | 155 | return ret; |
156 | 156 | ||
@@ -192,29 +192,22 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | |||
192 | int ret; | 192 | int ret; |
193 | enum ns2_led_modes mode; | 193 | enum ns2_led_modes mode; |
194 | 194 | ||
195 | ret = gpio_request(template->cmd, template->name); | 195 | ret = devm_gpio_request_one(&pdev->dev, template->cmd, |
196 | if (ret == 0) { | 196 | GPIOF_DIR_OUT | gpio_get_value(template->cmd), |
197 | ret = gpio_direction_output(template->cmd, | 197 | template->name); |
198 | gpio_get_value(template->cmd)); | ||
199 | if (ret) | ||
200 | gpio_free(template->cmd); | ||
201 | } | ||
202 | if (ret) { | 198 | if (ret) { |
203 | dev_err(&pdev->dev, "%s: failed to setup command GPIO\n", | 199 | dev_err(&pdev->dev, "%s: failed to setup command GPIO\n", |
204 | template->name); | 200 | template->name); |
201 | return ret; | ||
205 | } | 202 | } |
206 | 203 | ||
207 | ret = gpio_request(template->slow, template->name); | 204 | ret = devm_gpio_request_one(&pdev->dev, template->slow, |
208 | if (ret == 0) { | 205 | GPIOF_DIR_OUT | gpio_get_value(template->slow), |
209 | ret = gpio_direction_output(template->slow, | 206 | template->name); |
210 | gpio_get_value(template->slow)); | ||
211 | if (ret) | ||
212 | gpio_free(template->slow); | ||
213 | } | ||
214 | if (ret) { | 207 | if (ret) { |
215 | dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n", | 208 | dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n", |
216 | template->name); | 209 | template->name); |
217 | goto err_free_cmd; | 210 | return ret; |
218 | } | 211 | } |
219 | 212 | ||
220 | rwlock_init(&led_dat->rw_lock); | 213 | rwlock_init(&led_dat->rw_lock); |
@@ -229,7 +222,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | |||
229 | 222 | ||
230 | ret = ns2_led_get_mode(led_dat, &mode); | 223 | ret = ns2_led_get_mode(led_dat, &mode); |
231 | if (ret < 0) | 224 | if (ret < 0) |
232 | goto err_free_slow; | 225 | return ret; |
233 | 226 | ||
234 | /* Set LED initial state. */ | 227 | /* Set LED initial state. */ |
235 | led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; | 228 | led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; |
@@ -238,7 +231,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | |||
238 | 231 | ||
239 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); | 232 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); |
240 | if (ret < 0) | 233 | if (ret < 0) |
241 | goto err_free_slow; | 234 | return ret; |
242 | 235 | ||
243 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); | 236 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); |
244 | if (ret < 0) | 237 | if (ret < 0) |
@@ -248,11 +241,6 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | |||
248 | 241 | ||
249 | err_free_cdev: | 242 | err_free_cdev: |
250 | led_classdev_unregister(&led_dat->cdev); | 243 | led_classdev_unregister(&led_dat->cdev); |
251 | err_free_slow: | ||
252 | gpio_free(led_dat->slow); | ||
253 | err_free_cmd: | ||
254 | gpio_free(led_dat->cmd); | ||
255 | |||
256 | return ret; | 244 | return ret; |
257 | } | 245 | } |
258 | 246 | ||
@@ -260,8 +248,6 @@ static void delete_ns2_led(struct ns2_led_data *led_dat) | |||
260 | { | 248 | { |
261 | device_remove_file(led_dat->cdev.dev, &dev_attr_sata); | 249 | device_remove_file(led_dat->cdev.dev, &dev_attr_sata); |
262 | led_classdev_unregister(&led_dat->cdev); | 250 | led_classdev_unregister(&led_dat->cdev); |
263 | gpio_free(led_dat->cmd); | ||
264 | gpio_free(led_dat->slow); | ||
265 | } | 251 | } |
266 | 252 | ||
267 | #ifdef CONFIG_OF_GPIO | 253 | #ifdef CONFIG_OF_GPIO |
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 706791af8fc8..edf485b773c8 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c | |||
@@ -277,7 +277,7 @@ static int pca955x_probe(struct i2c_client *client, | |||
277 | return -ENODEV; | 277 | return -ENODEV; |
278 | } | 278 | } |
279 | 279 | ||
280 | printk(KERN_INFO "leds-pca955x: Using %s %d-bit LED driver at " | 280 | dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " |
281 | "slave address 0x%02x\n", | 281 | "slave address 0x%02x\n", |
282 | id->name, chip->bits, client->addr); | 282 | id->name, chip->bits, client->addr); |
283 | 283 | ||
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index e51ff7a3cd88..2157524f277c 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c | |||
@@ -26,7 +26,7 @@ | |||
26 | struct led_pwm_data { | 26 | struct led_pwm_data { |
27 | struct led_classdev cdev; | 27 | struct led_classdev cdev; |
28 | struct pwm_device *pwm; | 28 | struct pwm_device *pwm; |
29 | unsigned int active_low; | 29 | unsigned int active_low; |
30 | unsigned int period; | 30 | unsigned int period; |
31 | }; | 31 | }; |
32 | 32 | ||
diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c index 9ebdd5011a7c..2e746d257b02 100644 --- a/drivers/leds/leds-rb532.c +++ b/drivers/leds/leds-rb532.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <asm/mach-rc32434/rb.h> | 16 | #include <asm/mach-rc32434/rb.h> |
17 | 17 | ||
18 | static void rb532_led_set(struct led_classdev *cdev, | 18 | static void rb532_led_set(struct led_classdev *cdev, |
19 | enum led_brightness brightness) | 19 | enum led_brightness brightness) |
20 | { | 20 | { |
21 | if (brightness) | 21 | if (brightness) |
22 | set_latch_u5(LO_ULED, 0); | 22 | set_latch_u5(LO_ULED, 0); |
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c index bc8984795a3e..e0fff1ca5923 100644 --- a/drivers/leds/leds-renesas-tpu.c +++ b/drivers/leds/leds-renesas-tpu.c | |||
@@ -204,10 +204,10 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state, | |||
204 | if (p->pin_state == R_TPU_PIN_GPIO_FN) | 204 | if (p->pin_state == R_TPU_PIN_GPIO_FN) |
205 | gpio_free(cfg->pin_gpio_fn); | 205 | gpio_free(cfg->pin_gpio_fn); |
206 | 206 | ||
207 | if (new_state == R_TPU_PIN_GPIO) { | 207 | if (new_state == R_TPU_PIN_GPIO) |
208 | gpio_request(cfg->pin_gpio, cfg->name); | 208 | gpio_request_one(cfg->pin_gpio, GPIOF_DIR_OUT | !!brightness, |
209 | gpio_direction_output(cfg->pin_gpio, !!brightness); | 209 | cfg->name); |
210 | } | 210 | |
211 | if (new_state == R_TPU_PIN_GPIO_FN) | 211 | if (new_state == R_TPU_PIN_GPIO_FN) |
212 | gpio_request(cfg->pin_gpio_fn, cfg->name); | 212 | gpio_request(cfg->pin_gpio_fn, cfg->name); |
213 | 213 | ||
@@ -263,18 +263,18 @@ static int r_tpu_probe(struct platform_device *pdev) | |||
263 | } | 263 | } |
264 | 264 | ||
265 | /* map memory, let mapbase point to our channel */ | 265 | /* map memory, let mapbase point to our channel */ |
266 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); | 266 | p->mapbase = devm_ioremap_nocache(&pdev->dev, res->start, |
267 | resource_size(res)); | ||
267 | if (p->mapbase == NULL) { | 268 | if (p->mapbase == NULL) { |
268 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); | 269 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); |
269 | return -ENXIO; | 270 | return -ENXIO; |
270 | } | 271 | } |
271 | 272 | ||
272 | /* get hold of clock */ | 273 | /* get hold of clock */ |
273 | p->clk = clk_get(&pdev->dev, NULL); | 274 | p->clk = devm_clk_get(&pdev->dev, NULL); |
274 | if (IS_ERR(p->clk)) { | 275 | if (IS_ERR(p->clk)) { |
275 | dev_err(&pdev->dev, "cannot get clock\n"); | 276 | dev_err(&pdev->dev, "cannot get clock\n"); |
276 | ret = PTR_ERR(p->clk); | 277 | return PTR_ERR(p->clk); |
277 | goto err0; | ||
278 | } | 278 | } |
279 | 279 | ||
280 | p->pdev = pdev; | 280 | p->pdev = pdev; |
@@ -293,7 +293,7 @@ static int r_tpu_probe(struct platform_device *pdev) | |||
293 | p->ldev.flags |= LED_CORE_SUSPENDRESUME; | 293 | p->ldev.flags |= LED_CORE_SUSPENDRESUME; |
294 | ret = led_classdev_register(&pdev->dev, &p->ldev); | 294 | ret = led_classdev_register(&pdev->dev, &p->ldev); |
295 | if (ret < 0) | 295 | if (ret < 0) |
296 | goto err1; | 296 | goto err0; |
297 | 297 | ||
298 | /* max_brightness may be updated by the LED core code */ | 298 | /* max_brightness may be updated by the LED core code */ |
299 | p->min_rate = p->ldev.max_brightness * p->refresh_rate; | 299 | p->min_rate = p->ldev.max_brightness * p->refresh_rate; |
@@ -301,11 +301,8 @@ static int r_tpu_probe(struct platform_device *pdev) | |||
301 | pm_runtime_enable(&pdev->dev); | 301 | pm_runtime_enable(&pdev->dev); |
302 | return 0; | 302 | return 0; |
303 | 303 | ||
304 | err1: | ||
305 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); | ||
306 | clk_put(p->clk); | ||
307 | err0: | 304 | err0: |
308 | iounmap(p->mapbase); | 305 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); |
309 | return ret; | 306 | return ret; |
310 | } | 307 | } |
311 | 308 | ||
@@ -320,9 +317,7 @@ static int r_tpu_remove(struct platform_device *pdev) | |||
320 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); | 317 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); |
321 | 318 | ||
322 | pm_runtime_disable(&pdev->dev); | 319 | pm_runtime_disable(&pdev->dev); |
323 | clk_put(p->clk); | ||
324 | 320 | ||
325 | iounmap(p->mapbase); | ||
326 | return 0; | 321 | return 0; |
327 | } | 322 | } |
328 | 323 | ||
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c index 6469849e8266..ec9b287ecfbf 100644 --- a/drivers/leds/leds-ss4200.c +++ b/drivers/leds/leds-ss4200.c | |||
@@ -459,7 +459,7 @@ static ssize_t nas_led_blink_store(struct device *dev, | |||
459 | struct led_classdev *led = dev_get_drvdata(dev); | 459 | struct led_classdev *led = dev_get_drvdata(dev); |
460 | unsigned long blink_state; | 460 | unsigned long blink_state; |
461 | 461 | ||
462 | ret = strict_strtoul(buf, 10, &blink_state); | 462 | ret = kstrtoul(buf, 10, &blink_state); |
463 | if (ret) | 463 | if (ret) |
464 | return ret; | 464 | return ret; |
465 | 465 | ||
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c index 88f23f845595..ed15157c8f6c 100644 --- a/drivers/leds/leds-wm8350.c +++ b/drivers/leds/leds-wm8350.c | |||
@@ -216,13 +216,13 @@ static int wm8350_led_probe(struct platform_device *pdev) | |||
216 | 216 | ||
217 | isink = devm_regulator_get(&pdev->dev, "led_isink"); | 217 | isink = devm_regulator_get(&pdev->dev, "led_isink"); |
218 | if (IS_ERR(isink)) { | 218 | if (IS_ERR(isink)) { |
219 | printk(KERN_ERR "%s: can't get ISINK\n", __func__); | 219 | dev_err(&pdev->dev, "%s: can't get ISINK\n", __func__); |
220 | return PTR_ERR(isink); | 220 | return PTR_ERR(isink); |
221 | } | 221 | } |
222 | 222 | ||
223 | dcdc = devm_regulator_get(&pdev->dev, "led_vcc"); | 223 | dcdc = devm_regulator_get(&pdev->dev, "led_vcc"); |
224 | if (IS_ERR(dcdc)) { | 224 | if (IS_ERR(dcdc)) { |
225 | printk(KERN_ERR "%s: can't get DCDC\n", __func__); | 225 | dev_err(&pdev->dev, "%s: can't get DCDC\n", __func__); |
226 | return PTR_ERR(dcdc); | 226 | return PTR_ERR(dcdc); |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c index 6e21e654bb02..b358cc05eff5 100644 --- a/drivers/leds/leds-wrap.c +++ b/drivers/leds/leds-wrap.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/leds.h> | 16 | #include <linux/leds.h> |
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | #include <asm/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/scx200_gpio.h> | 19 | #include <linux/scx200_gpio.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | 21 | ||
diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c index b941685f2227..027a2b15d7d8 100644 --- a/drivers/leds/ledtrig-backlight.c +++ b/drivers/leds/ledtrig-backlight.c | |||
@@ -40,7 +40,7 @@ static int fb_notifier_callback(struct notifier_block *p, | |||
40 | int new_status = *blank ? BLANK : UNBLANK; | 40 | int new_status = *blank ? BLANK : UNBLANK; |
41 | 41 | ||
42 | switch (event) { | 42 | switch (event) { |
43 | case FB_EVENT_BLANK : | 43 | case FB_EVENT_BLANK: |
44 | if (new_status == n->old_status) | 44 | if (new_status == n->old_status) |
45 | break; | 45 | break; |
46 | 46 | ||
@@ -76,7 +76,7 @@ static ssize_t bl_trig_invert_store(struct device *dev, | |||
76 | unsigned long invert; | 76 | unsigned long invert; |
77 | int ret; | 77 | int ret; |
78 | 78 | ||
79 | ret = strict_strtoul(buf, 10, &invert); | 79 | ret = kstrtoul(buf, 10, &invert); |
80 | if (ret < 0) | 80 | if (ret < 0) |
81 | return ret; | 81 | return ret; |
82 | 82 | ||
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c index ba215dc42f98..72e3ebfc281f 100644 --- a/drivers/leds/ledtrig-gpio.c +++ b/drivers/leds/ledtrig-gpio.c | |||
@@ -110,7 +110,7 @@ static ssize_t gpio_trig_inverted_store(struct device *dev, | |||
110 | unsigned long inverted; | 110 | unsigned long inverted; |
111 | int ret; | 111 | int ret; |
112 | 112 | ||
113 | ret = strict_strtoul(buf, 10, &inverted); | 113 | ret = kstrtoul(buf, 10, &inverted); |
114 | if (ret < 0) | 114 | if (ret < 0) |
115 | return ret; | 115 | return ret; |
116 | 116 | ||
diff --git a/include/linux/leds.h b/include/linux/leds.h index 6e53bb31c220..0d9b5eed714e 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h | |||
@@ -179,6 +179,23 @@ extern void led_trigger_blink_oneshot(struct led_trigger *trigger, | |||
179 | unsigned long *delay_on, | 179 | unsigned long *delay_on, |
180 | unsigned long *delay_off, | 180 | unsigned long *delay_off, |
181 | int invert); | 181 | int invert); |
182 | /** | ||
183 | * led_trigger_rename_static - rename a trigger | ||
184 | * @name: the new trigger name | ||
185 | * @trig: the LED trigger to rename | ||
186 | * | ||
187 | * Change a LED trigger name by copying the string passed in | ||
188 | * name into current trigger name, which MUST be large | ||
189 | * enough for the new string. | ||
190 | * | ||
191 | * Note that name must NOT point to the same string used | ||
192 | * during LED registration, as that could lead to races. | ||
193 | * | ||
194 | * This is meant to be used on triggers with statically | ||
195 | * allocated name. | ||
196 | */ | ||
197 | extern void led_trigger_rename_static(const char *name, | ||
198 | struct led_trigger *trig); | ||
182 | 199 | ||
183 | #else | 200 | #else |
184 | 201 | ||