diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 12:52:42 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 12:52:42 -0800 |
commit | e81d372ff9f694e13fa46e8b5aaed505c7fd2a1f (patch) | |
tree | 058d5004b6ca7602aaec6ef2d992be9c71a8e81c /drivers/leds | |
parent | 75e300c8ba5864367634d946c729d8fd05c1cbc2 (diff) | |
parent | 2f05e1d4458f9cb68d4d36fb47e6830fec03c80e (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu.
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (47 commits)
leds: leds-lp5521: return an error code on error in probe()
leds: leds-clevo-mail: Use pr_* instead of printks
leds: leds-rb532: Fix checkpatch errors
leds: led-triggers: Fix checkpatch warnings
leds: ledtrig-backlight: Fix checkpatch error
leds: leds-wrap: Use <linux/io.h> instead of <asm/io.h>
leds: leds-wm8350: Use dev_err instead of printk
leds: leds-pwm: Fix checkpatch warning
leds: leds-pca955x: Use dev_info instead of printk
leds: leds-net48xx: Use linux/io.h instead of asm/io.h
leds: leds-lt3593: Fix checkpatch warnings
leds: leds-gpio: Use dev_info instead of printk
leds: leds-da903x: Fix checkpatch error and warnings
leds: leds-bd2802: Fix checkpatch warnings
leds: leds-adp5520: Fix checkpatch warnings
leds: led-class: Fix checkpatch warning
leds: leds-ns2: use devm_gpio_request_one
leds: leds-lt3593: use devm_gpio_request_one
leds: leds-gpio: use devm_gpio_request_one
leds: lp3944: Fix return value
...
Diffstat (limited to 'drivers/leds')
29 files changed, 147 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) led_trigger_set_default(led_cdev); #endif - printk(KERN_DEBUG "Registered led device: %s\n", + dev_dbg(parent, "Registered led device: %s\n", led_cdev->name); 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) } EXPORT_SYMBOL_GPL(led_trigger_set_default); +void led_trigger_rename_static(const char *name, struct led_trigger *trig) +{ + /* new name must be on a temporary string to prevent races */ + BUG_ON(name == trig->name); + + down_write(&triggers_list_lock); + /* this assumes that trig->name was originaly allocated to + * non constant storage */ + strcpy((char *)trig->name, name); + up_write(&triggers_list_lock); +} +EXPORT_SYMBOL_GPL(led_trigger_rename_static); + /* LED Trigger Interface */ int led_trigger_register(struct led_trigger *trig) @@ -300,13 +313,13 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp) if (err < 0) { kfree(trig); trig = NULL; - printk(KERN_WARNING "LED trigger %s failed to register" - " (%d)\n", name, err); + pr_warn("LED trigger %s failed to register (%d)\n", + name, err); } - } else - printk(KERN_WARNING "LED trigger %s failed to register" - " (no memory)\n", name); - + } else { + pr_warn("LED trigger %s failed to register (no memory)\n", + name); + } *tp = trig; } 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) res = platform_get_resource_byname(pdev, IORESOURCE_REG, "control"); if (!res) { dev_err(&pdev->dev, "No REG resource for control\n"); - ret = -ENXIO; - goto out; + return -ENXIO; } data->reg_control = res->start; res = platform_get_resource_byname(pdev, IORESOURCE_REG, "blink"); if (!res) { dev_err(&pdev->dev, "No REG resource for blink\n"); - ret = -ENXIO; - goto out; + return -ENXIO; } data->reg_blink = res->start; memset(data->name, 0, MFD_NAME_SIZE); @@ -224,9 +222,6 @@ static int pm860x_led_probe(struct platform_device *pdev) } pm860x_led_set(&data->cdev, 0); return 0; -out: - devm_kfree(&pdev->dev, data); - return ret; } 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 @@ * * Loosely derived from leds-da903x: * Copyright (C) 2008 Compulab, Ltd. - * Mike Rapoport <mike@compulab.co.il> + * Mike Rapoport <mike@compulab.co.il> * * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao <eric.miao@marvell.com> + * Eric Miao <eric.miao@marvell.com> * * Licensed under the GPL-2 or later. */ 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 @@ #define BD2802_LED_OFFSET 0xa #define BD2802_COLOR_OFFSET 0x3 -#define BD2802_REG_CLKSETUP 0x00 -#define BD2802_REG_CONTROL 0x01 +#define BD2802_REG_CLKSETUP 0x00 +#define BD2802_REG_CONTROL 0x01 #define BD2802_REG_HOURSETUP 0x02 #define BD2802_REG_CURRENT1SETUP 0x03 #define BD2802_REG_CURRENT2SETUP 0x04 @@ -93,7 +93,7 @@ struct bd2802_led { * In ADF mode, user can set registers of BD2802GU directly, * therefore BD2802GU doesn't enter reset state. */ - int adf_on; + int adf_on; enum led_ids led_id; enum led_colors color; @@ -328,7 +328,7 @@ static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ int ret; \ if (!count) \ return -EINVAL; \ - ret = strict_strtoul(buf, 16, &val); \ + ret = kstrtoul(buf, 16, &val); \ if (ret) \ return ret; \ down_write(&led->rwsem); \ @@ -492,7 +492,7 @@ static ssize_t bd2802_store_##attr_name(struct device *dev, \ int ret; \ if (!count) \ return -EINVAL; \ - ret = strict_strtoul(buf, 16, &val); \ + ret = kstrtoul(buf, 16, &val); \ if (ret) \ return ret; \ 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 @@ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> @@ -26,7 +27,7 @@ static struct platform_device *pdev; static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id) { - printk(KERN_INFO KBUILD_MODNAME ": '%s' found\n", id->ident); + pr_info("'%s' found\n", id->ident); return 1; } @@ -135,8 +136,7 @@ static int clevo_mail_led_blink(struct led_classdev *led_cdev, status = 0; } else { - printk(KERN_DEBUG KBUILD_MODNAME - ": clevo_mail_led_blink(..., %lu, %lu)," + pr_debug("clevo_mail_led_blink(..., %lu, %lu)," " returning -EINVAL (unsupported)\n", *delay_on, *delay_off); } @@ -183,7 +183,7 @@ static int __init clevo_mail_led_init(void) count = dmi_check_system(clevo_mail_led_dmi_table); } else { count = 1; - printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. " + pr_err("Skipping DMI detection. " "If the driver works on your hardware please " "report model and the output of dmidecode in tracker " "at http://sourceforge.net/projects/clevo-mailled/\n"); @@ -197,8 +197,7 @@ static int __init clevo_mail_led_init(void) error = platform_driver_probe(&clevo_mail_led_driver, clevo_mail_led_probe); if (error) { - printk(KERN_ERR KBUILD_MODNAME - ": Can't probe platform driver\n"); + pr_err("Can't probe platform driver\n"); platform_device_unregister(pdev); } } 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) if (!res) return -EBUSY; - led_port = ioremap(res->start, resource_size(res)); + led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!led_port) return -ENOMEM; @@ -52,12 +52,11 @@ static int cobalt_qube_led_probe(struct platform_device *pdev) retval = led_classdev_register(&pdev->dev, &qube_front_led); if (retval) - goto err_iounmap; + goto err_null; return 0; -err_iounmap: - iounmap(led_port); +err_null: led_port = NULL; return retval; @@ -67,10 +66,8 @@ static int cobalt_qube_led_remove(struct platform_device *pdev) { led_classdev_unregister(&qube_front_led); - if (led_port) { - iounmap(led_port); + if (led_port) led_port = NULL; - } return 0; } 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) if (!res) return -EBUSY; - led_port = ioremap(res->start, resource_size(res)); + led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!led_port) return -ENOMEM; retval = led_classdev_register(&pdev->dev, &raq_power_off_led); if (retval) - goto err_iounmap; + goto err_null; retval = led_classdev_register(&pdev->dev, &raq_web_led); if (retval) @@ -102,8 +102,7 @@ static int cobalt_raq_led_probe(struct platform_device *pdev) err_unregister: led_classdev_unregister(&raq_power_off_led); -err_iounmap: - iounmap(led_port); +err_null: led_port = NULL; return retval; @@ -114,10 +113,8 @@ static int cobalt_raq_led_remove(struct platform_device *pdev) led_classdev_unregister(&raq_power_off_led); led_classdev_unregister(&raq_web_led); - if (led_port) { - iounmap(led_port); + if (led_port) led_port = NULL; - } return 0; } 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 @@ * LEDs driver for Dialog Semiconductor DA9030/DA9034 * * Copyright (C) 2008 Compulab, Ltd. - * Mike Rapoport <mike@compulab.co.il> + * Mike Rapoport <mike@compulab.co.il> * * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao <eric.miao@marvell.com> + * Eric Miao <eric.miao@marvell.com> * * This program is free software; you can redistribute it and/or modify * 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, enum led_brightness value) { struct da903x_led *led; - + led = container_of(led_cdev, struct da903x_led, cdev); led->new_brightness = value; schedule_work(&led->work); @@ -156,7 +156,7 @@ static struct platform_driver da903x_led_driver = { module_platform_driver(da903x_led_driver); MODULE_DESCRIPTION("LEDs driver for Dialog Semiconductor DA9030/DA9034"); -MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>" - "Mike Rapoport <mike@compulab.co.il>"); +MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); +MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); MODULE_LICENSE("GPL"); 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 @@ #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/module.h> +#include <linux/io.h> #include <mach/hardware.h> -#include <asm/io.h> #define FSG_LED_WLAN_BIT 0 #define FSG_LED_WAN_BIT 1 @@ -149,11 +149,10 @@ static int fsg_led_probe(struct platform_device *pdev) int ret; /* Map the LED chip select address space */ - latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512); - if (!latch_address) { - ret = -ENOMEM; - goto failremap; - } + latch_address = (unsigned short *) devm_ioremap(&pdev->dev, + IXP4XX_EXP_BUS_BASE(2), 512); + if (!latch_address) + return -ENOMEM; latch_value = 0xffff; *latch_address = latch_value; @@ -195,8 +194,6 @@ static int fsg_led_probe(struct platform_device *pdev) failwan: led_classdev_unregister(&fsg_wlan_led); failwlan: - iounmap(latch_address); - failremap: return ret; } @@ -210,8 +207,6 @@ static int fsg_led_remove(struct platform_device *pdev) led_classdev_unregister(&fsg_sync_led); led_classdev_unregister(&fsg_ring_led); - iounmap(latch_address); - return 0; } 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 @@ #include <linux/workqueue.h> #include <linux/module.h> #include <linux/pinctrl/consumer.h> +#include <linux/err.h> struct gpio_led_data { struct led_classdev cdev; @@ -101,15 +102,11 @@ static int create_gpio_led(const struct gpio_led *template, /* skip leds that aren't available */ if (!gpio_is_valid(template->gpio)) { - printk(KERN_INFO "Skipping unavailable LED gpio %d (%s)\n", + dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n", template->gpio, template->name); return 0; } - ret = gpio_request(template->gpio, template->name); - if (ret < 0) - return ret; - led_dat->cdev.name = template->name; led_dat->cdev.default_trigger = template->default_trigger; led_dat->gpio = template->gpio; @@ -129,20 +126,19 @@ static int create_gpio_led(const struct gpio_led *template, if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state); + ret = devm_gpio_request_one(parent, template->gpio, + GPIOF_DIR_OUT | (led_dat->active_low ^ state), + template->name); if (ret < 0) - goto err; - + return ret; + INIT_WORK(&led_dat->work, gpio_led_work); ret = led_classdev_register(parent, &led_dat->cdev); if (ret < 0) - goto err; + return ret; return 0; -err: - gpio_free(led_dat->gpio); - return ret; } static void delete_gpio_led(struct gpio_led_data *led) @@ -151,7 +147,6 @@ static void delete_gpio_led(struct gpio_led_data *led) return; led_classdev_unregister(&led->cdev); cancel_work_sync(&led->work); - gpio_free(led->gpio); } struct gpio_leds_priv { @@ -176,12 +171,16 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) /* count LEDs in this device, so we know how much to allocate */ count = of_get_child_count(np); if (!count) - return NULL; + return ERR_PTR(-ENODEV); + + for_each_child_of_node(np, child) + if (of_get_gpio(child, 0) == -EPROBE_DEFER) + return ERR_PTR(-EPROBE_DEFER); priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), GFP_KERNEL); if (!priv) - return NULL; + return ERR_PTR(-ENOMEM); for_each_child_of_node(np, child) { struct gpio_led led = {}; @@ -216,7 +215,7 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) err: for (count = priv->num_leds - 2; count >= 0; count--) delete_gpio_led(&priv->leds[count]); - return NULL; + return ERR_PTR(-ENODEV); } static const struct of_device_id of_gpio_leds_match[] = { @@ -226,7 +225,7 @@ static const struct of_device_id of_gpio_leds_match[] = { #else /* CONFIG_OF_GPIO */ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) { - return NULL; + return ERR_PTR(-ENODEV); } #endif /* CONFIG_OF_GPIO */ @@ -264,8 +263,8 @@ static int gpio_led_probe(struct platform_device *pdev) } } else { priv = gpio_leds_create_of(pdev); - if (!priv) - return -ENODEV; + if (IS_ERR(priv)) + return PTR_ERR(priv); } 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, return size; out: dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); - return size; + return ret; } -static DEVICE_ATTR(pattern, 0666, NULL, lm3556_indicator_pattern_store); +static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); static const struct regmap_config lm355x_regmap = { .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, return size; out: dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); - return size; + return ret; out_strtoint: dev_err(chip->dev, "%s: fail to change str to int\n", __func__); - return size; + return ret; } -static DEVICE_ATTR(torch_pin, 0666, NULL, lm3642_torch_pin_store); +static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); static void lm3642_deferred_torch_brightness_set(struct work_struct *work) { @@ -258,13 +258,13 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev, return size; out: dev_err(chip->dev, "%s:i2c access fail to register\n", __func__); - return size; + return ret; out_strtoint: dev_err(chip->dev, "%s: fail to change str to int\n", __func__); - return size; + return ret; } -static DEVICE_ATTR(strobe_pin, 0666, NULL, lm3642_strobe_pin_store); +static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); static void lm3642_deferred_strobe_brightness_set(struct work_struct *work) { 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) tmp = i2c_smbus_read_byte_data(client, reg); if (tmp < 0) - return -EINVAL; + return tmp; *value = tmp; 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) ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) - return -EIO; + return ret; *buf = ret; return 0; @@ -616,7 +616,7 @@ static ssize_t store_led_pattern(struct device *dev, unsigned long val; int ret; - ret = strict_strtoul(buf, 16, &val); + ret = kstrtoul(buf, 16, &val); if (ret) return ret; @@ -788,10 +788,17 @@ static int lp5521_probe(struct i2c_client *client, * LP5521_REG_ENABLE register will not have any effect - strange! */ ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); - if (ret || buf != LP5521_REG_R_CURR_DEFAULT) { + if (ret) { dev_err(&client->dev, "error in resetting chip\n"); goto fail2; } + if (buf != LP5521_REG_R_CURR_DEFAULT) { + dev_err(&client->dev, + "unexpected data in register (expected 0x%x got 0x%x)\n", + LP5521_REG_R_CURR_DEFAULT, buf); + ret = -EINVAL; + goto fail2; + } usleep_range(10000, 20000); 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) s32 ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) - return -EIO; + return ret; *buf = ret; return 0; @@ -248,7 +248,10 @@ static int lp5523_configure(struct i2c_client *client) /* Let the programs run for couple of ms and check the engine status */ usleep_range(3000, 6000); - lp5523_read(client, LP5523_REG_STATUS, &status); + ret = lp5523_read(client, LP5523_REG_STATUS, &status); + if (ret < 0) + return ret; + status &= LP5523_ENG_STATUS_MASK; if (status == LP5523_ENG_STATUS_MASK) { @@ -464,10 +467,16 @@ static ssize_t lp5523_selftest(struct device *dev, LP5523_EN_LEDTEST | 16); usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */ ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); + if (ret < 0) + goto fail; + if (!(status & LP5523_LEDTEST_DONE)) usleep_range(3000, 6000); /* Was not ready. Wait little bit */ - ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); + ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); + if (ret < 0) + goto fail; + vdd--; /* There may be some fluctuation in measurement */ for (i = 0; i < LP5523_LEDS; i++) { @@ -489,9 +498,14 @@ static ssize_t lp5523_selftest(struct device *dev, /* ADC conversion time is 2.7 ms typically */ usleep_range(3000, 6000); ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); + if (ret < 0) + goto fail; + if (!(status & LP5523_LEDTEST_DONE)) usleep_range(3000, 6000);/* Was not ready. Wait. */ - ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); + ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); + if (ret < 0) + goto fail; if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) pos += sprintf(buf + pos, "LED %d FAIL\n", i); @@ -696,7 +710,7 @@ static ssize_t store_current(struct device *dev, ssize_t ret; unsigned long curr; - if (strict_strtoul(buf, 0, &curr)) + if (kstrtoul(buf, 0, &curr)) return -EINVAL; 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, /* skip leds on GPIOs that aren't available */ if (!gpio_is_valid(template->gpio)) { - printk(KERN_INFO "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n", + dev_info(parent, "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n", KBUILD_MODNAME, template->gpio, template->name); return 0; } - ret = gpio_request(template->gpio, template->name); - if (ret < 0) - return ret; - led_dat->cdev.name = template->name; led_dat->cdev.default_trigger = template->default_trigger; led_dat->gpio = template->gpio; @@ -110,24 +106,21 @@ static int create_lt3593_led(const struct gpio_led *template, if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_direction_output(led_dat->gpio, state); + ret = devm_gpio_request_one(parent, template->gpio, + GPIOF_DIR_OUT | state, template->name); if (ret < 0) - goto err; + return ret; INIT_WORK(&led_dat->work, lt3593_led_work); ret = led_classdev_register(parent, &led_dat->cdev); if (ret < 0) - goto err; + return ret; - printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n", + dev_info(parent, "%s: registered LT3593 LED '%s' at GPIO %d\n", KBUILD_MODNAME, template->name, template->gpio); return 0; - -err: - gpio_free(led_dat->gpio); - return ret; } static void delete_lt3593_led(struct lt3593_led_data *led) @@ -137,7 +130,6 @@ static void delete_lt3593_led(struct lt3593_led_data *led) led_classdev_unregister(&led->cdev); cancel_work_sync(&led->work); - gpio_free(led->gpio); } 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 @@ #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/err.h> -#include <asm/io.h> +#include <linux/io.h> #include <linux/nsc_gpio.h> #include <linux/scx200_gpio.h> #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, int mode_val; int ret; - ret = strict_strtoul(buff, 10, &enable); + ret = kstrtoul(buff, 10, &enable); if (ret < 0) return ret; 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, unsigned long enable; enum ns2_led_modes mode; - ret = strict_strtoul(buff, 10, &enable); + ret = kstrtoul(buff, 10, &enable); if (ret < 0) return ret; @@ -192,29 +192,22 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, int ret; enum ns2_led_modes mode; - ret = gpio_request(template->cmd, template->name); - if (ret == 0) { - ret = gpio_direction_output(template->cmd, - gpio_get_value(template->cmd)); - if (ret) - gpio_free(template->cmd); - } + ret = devm_gpio_request_one(&pdev->dev, template->cmd, + GPIOF_DIR_OUT | gpio_get_value(template->cmd), + template->name); if (ret) { dev_err(&pdev->dev, "%s: failed to setup command GPIO\n", template->name); + return ret; } - ret = gpio_request(template->slow, template->name); - if (ret == 0) { - ret = gpio_direction_output(template->slow, - gpio_get_value(template->slow)); - if (ret) - gpio_free(template->slow); - } + ret = devm_gpio_request_one(&pdev->dev, template->slow, + GPIOF_DIR_OUT | gpio_get_value(template->slow), + template->name); if (ret) { dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n", template->name); - goto err_free_cmd; + return ret; } rwlock_init(&led_dat->rw_lock); @@ -229,7 +222,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, ret = ns2_led_get_mode(led_dat, &mode); if (ret < 0) - goto err_free_slow; + return ret; /* Set LED initial state. */ 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, ret = led_classdev_register(&pdev->dev, &led_dat->cdev); if (ret < 0) - goto err_free_slow; + return ret; ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); if (ret < 0) @@ -248,11 +241,6 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, err_free_cdev: led_classdev_unregister(&led_dat->cdev); -err_free_slow: - gpio_free(led_dat->slow); -err_free_cmd: - gpio_free(led_dat->cmd); - return ret; } @@ -260,8 +248,6 @@ static void delete_ns2_led(struct ns2_led_data *led_dat) { device_remove_file(led_dat->cdev.dev, &dev_attr_sata); led_classdev_unregister(&led_dat->cdev); - gpio_free(led_dat->cmd); - gpio_free(led_dat->slow); } #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, return -ENODEV; } - printk(KERN_INFO "leds-pca955x: Using %s %d-bit LED driver at " + dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " "slave address 0x%02x\n", id->name, chip->bits, client->addr); 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 @@ struct led_pwm_data { struct led_classdev cdev; struct pwm_device *pwm; - unsigned int active_low; + unsigned int active_low; unsigned int period; }; 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 @@ #include <asm/mach-rc32434/rb.h> static void rb532_led_set(struct led_classdev *cdev, - enum led_brightness brightness) + enum led_brightness brightness) { if (brightness) 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, if (p->pin_state == R_TPU_PIN_GPIO_FN) gpio_free(cfg->pin_gpio_fn); - if (new_state == R_TPU_PIN_GPIO) { - gpio_request(cfg->pin_gpio, cfg->name); - gpio_direction_output(cfg->pin_gpio, !!brightness); - } + if (new_state == R_TPU_PIN_GPIO) + gpio_request_one(cfg->pin_gpio, GPIOF_DIR_OUT | !!brightness, + cfg->name); + if (new_state == R_TPU_PIN_GPIO_FN) gpio_request(cfg->pin_gpio_fn, cfg->name); @@ -263,18 +263,18 @@ static int r_tpu_probe(struct platform_device *pdev) } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); + p->mapbase = devm_ioremap_nocache(&pdev->dev, res->start, + resource_size(res)); if (p->mapbase == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); return -ENXIO; } /* get hold of clock */ - p->clk = clk_get(&pdev->dev, NULL); + p->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(p->clk)) { dev_err(&pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); - goto err0; + return PTR_ERR(p->clk); } p->pdev = pdev; @@ -293,7 +293,7 @@ static int r_tpu_probe(struct platform_device *pdev) p->ldev.flags |= LED_CORE_SUSPENDRESUME; ret = led_classdev_register(&pdev->dev, &p->ldev); if (ret < 0) - goto err1; + goto err0; /* max_brightness may be updated by the LED core code */ p->min_rate = p->ldev.max_brightness * p->refresh_rate; @@ -301,11 +301,8 @@ static int r_tpu_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); return 0; - err1: - r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); - clk_put(p->clk); err0: - iounmap(p->mapbase); + r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); return ret; } @@ -320,9 +317,7 @@ static int r_tpu_remove(struct platform_device *pdev) r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); pm_runtime_disable(&pdev->dev); - clk_put(p->clk); - iounmap(p->mapbase); return 0; } 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, struct led_classdev *led = dev_get_drvdata(dev); unsigned long blink_state; - ret = strict_strtoul(buf, 10, &blink_state); + ret = kstrtoul(buf, 10, &blink_state); if (ret) return ret; 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) isink = devm_regulator_get(&pdev->dev, "led_isink"); if (IS_ERR(isink)) { - printk(KERN_ERR "%s: can't get ISINK\n", __func__); + dev_err(&pdev->dev, "%s: can't get ISINK\n", __func__); return PTR_ERR(isink); } dcdc = devm_regulator_get(&pdev->dev, "led_vcc"); if (IS_ERR(dcdc)) { - printk(KERN_ERR "%s: can't get DCDC\n", __func__); + dev_err(&pdev->dev, "%s: can't get DCDC\n", __func__); return PTR_ERR(dcdc); } 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 @@ #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/err.h> -#include <asm/io.h> +#include <linux/io.h> #include <linux/scx200_gpio.h> #include <linux/module.h> 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, int new_status = *blank ? BLANK : UNBLANK; switch (event) { - case FB_EVENT_BLANK : + case FB_EVENT_BLANK: if (new_status == n->old_status) break; @@ -76,7 +76,7 @@ static ssize_t bl_trig_invert_store(struct device *dev, unsigned long invert; int ret; - ret = strict_strtoul(buf, 10, &invert); + ret = kstrtoul(buf, 10, &invert); if (ret < 0) return ret; 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, unsigned long inverted; int ret; - ret = strict_strtoul(buf, 10, &inverted); + ret = kstrtoul(buf, 10, &inverted); if (ret < 0) return ret; |