From eccb6638569ae80eb4cb198640baac229fde4ff0 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 7 Oct 2012 20:54:23 -0700 Subject: leds: lm3642: Return proper error in lm3642_[torch|strobe]_pin_store error paths Signed-off-by: Axel Lin Acked-by: G.Shark Jeong Signed-off-by: Bryan Wu --- drivers/leds/leds-lm3642.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c index 3285006e988..b69acac6d71 100644 --- a/drivers/leds/leds-lm3642.c +++ b/drivers/leds/leds-lm3642.c @@ -201,10 +201,10 @@ 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); @@ -258,10 +258,10 @@ 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); -- cgit v1.2.3-70-g09d2 From 14ce82e536455ace3d6ca70f77bbc2c6b25b8268 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 7 Oct 2012 09:05:36 -0700 Subject: leds: lm355x: Return proper error for lm3556_indicator_pattern_store error path Signed-off-by: Axel Lin Acked-by: G.Shark Jeong Signed-off-by: Bryan Wu --- drivers/leds/leds-lm355x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c index 065ec015d67..8f4e8e21ddb 100644 --- a/drivers/leds/leds-lm355x.c +++ b/drivers/leds/leds-lm355x.c @@ -408,7 +408,7 @@ 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); -- cgit v1.2.3-70-g09d2 From a99d76f9eb5336291fa6af713844d1c779484e30 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:17:11 -0700 Subject: leds: leds-gpio: use gpio_request_one Using gpio_request_one can make the code simpler because it can set the direction and initial value in one shot. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-gpio.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 087d1e66f4f..0b418531526 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -106,10 +106,6 @@ static int __devinit create_gpio_led(const struct gpio_led *template, 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,10 +125,12 @@ static int __devinit 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 = gpio_request_one(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); -- cgit v1.2.3-70-g09d2 From 507d967bc1d103695440e27f888244e014bcf7be Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:17:56 -0700 Subject: leds: leds-lt3593: use gpio_request_one Using gpio_request_one can make the code simpler because it can set the direction and initial value in one shot. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-lt3593.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 09a732217f6..17b710c6399 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -94,10 +94,6 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, 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,9 +106,10 @@ static int __devinit 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 = gpio_request_one(template->gpio, GPIOF_DIR_OUT | state, + template->name); if (ret < 0) - goto err; + return ret; INIT_WORK(&led_dat->work, lt3593_led_work); -- cgit v1.2.3-70-g09d2 From 31c3dc7488f2564fc398d5a416726031f56d6343 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:18:21 -0700 Subject: leds: leds-ns2: use gpio_request_one Using gpio_request_one can make the code simpler because it can set the direction and initial value in one shot. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-ns2.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index d176ec83f5d..ae8f93b3364 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -191,25 +191,18 @@ 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 = gpio_request_one(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 = gpio_request_one(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); -- cgit v1.2.3-70-g09d2 From b0053aaa23907cb3e10e6d13923b9afd735c7272 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:18:47 -0700 Subject: leds: renesas: use gpio_request_one Using gpio_request_one can make the code simpler because it can set the direction and initial value in one shot. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-renesas-tpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c index 771ea067e68..614776a3094 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); -- cgit v1.2.3-70-g09d2 From aa2dcf9dc150d4d077d8fa4a19f6e05196e9b9a5 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:19:41 -0700 Subject: leds: leds-fsg: use devm_ioremap The devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_ioremap() for these functions. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-fsg.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c index b9053fa6e25..b4d5a44cc41 100644 --- a/drivers/leds/leds-fsg.c +++ b/drivers/leds/leds-fsg.c @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #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; } -- cgit v1.2.3-70-g09d2 From 50e5194385a7be0f3c6b1f97749854cf29562619 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:20:50 -0700 Subject: leds: leds-cobalt-raq: use devm_ioremap The devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_ioremap() for these functions. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-cobalt-raq.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c index aac1c073fe7..7e41aa91bc5 100644 --- a/drivers/leds/leds-cobalt-raq.c +++ b/drivers/leds/leds-cobalt-raq.c @@ -85,13 +85,13 @@ static int __devinit 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 __devinit 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 __devexit 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; } -- cgit v1.2.3-70-g09d2 From f87ef101056a34d69d7aa2611da0eb95ff4414f9 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:21:27 -0700 Subject: leds: leds-cobalt-qube: use devm_ioremap The devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_ioremap() for these functions. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-cobalt-qube.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c index 6a8725cc7b4..86d6db74efd 100644 --- a/drivers/leds/leds-cobalt-qube.c +++ b/drivers/leds/leds-cobalt-qube.c @@ -43,7 +43,7 @@ static int __devinit 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 __devinit 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 __devexit 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; } -- cgit v1.2.3-70-g09d2 From f9e007fffd44ba508c0b9c62c8126eb350bcff1e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:22:11 -0700 Subject: leds: renesas: use devm_ functions The devm_ functions allocate memory that is released when a driver detaches. This makes the code smaller and a bit simpler. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-renesas-tpu.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c index 614776a3094..99bec6cf330 100644 --- a/drivers/leds/leds-renesas-tpu.c +++ b/drivers/leds/leds-renesas-tpu.c @@ -263,18 +263,18 @@ static int __devinit 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 __devinit 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 __devinit 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 __devexit 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; } -- cgit v1.2.3-70-g09d2 From fd80fc762c58411d5e64836dd778052df0f99d4e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:23:33 -0700 Subject: leds: leds-bd2802: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-bd2802.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c index 89ca6a2a19d..ebdfe295d83 100644 --- a/drivers/leds/leds-bd2802.c +++ b/drivers/leds/leds-bd2802.c @@ -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); \ -- cgit v1.2.3-70-g09d2 From 7517611a4c301a362d3e3d4f7357881ea3db5385 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:24:33 -0700 Subject: leds: leds-netxbig: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-netxbig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index 461bbf9b33f..c4b482b8f7d 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; -- cgit v1.2.3-70-g09d2 From 3874350c598d7796a6dd2da111247be88e56d002 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:25:35 -0700 Subject: leds: leds-ns2: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-ns2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index ae8f93b3364..5df2a250a13 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -149,7 +149,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; -- cgit v1.2.3-70-g09d2 From d3b6492afada275d2e33b81a8a3737c9cb0016a4 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:26:09 -0700 Subject: leds: leds-ss4200: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-ss4200.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c index 57371e1485a..758c55fa0c0 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; -- cgit v1.2.3-70-g09d2 From 75253b3cff98674d6bf98071b7bce78ae6315a9d Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:26:56 -0700 Subject: leds: ledtrig-backlight: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/ledtrig-backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c index b941685f222..c74aff1fe70 100644 --- a/drivers/leds/ledtrig-backlight.c +++ b/drivers/leds/ledtrig-backlight.c @@ -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; -- cgit v1.2.3-70-g09d2 From e8941928faf248530c0eff95462e9fee0b1cc8da Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 23 Oct 2012 05:27:52 -0700 Subject: leds: ledtrig-gpio: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/ledtrig-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c index ba215dc42f9..72e3ebfc281 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; -- cgit v1.2.3-70-g09d2 From 04553e925baaa815025c6fd3cdc301a794fa2c74 Mon Sep 17 00:00:00 2001 From: Roland Stigge Date: Sun, 28 Oct 2012 08:34:59 -0700 Subject: leds: leds-gpio: Defer probing in case of deferred gpio probing This patch makes leds-gpio's probe() return -EPROBE_DEFER if any of the gpios to register are deferred themselves. This makes a change of gpio_leds_create_of()'s return value necessary: Instead of returning NULL on error, we now use ERR_PTR() error coding. Signed-off-by: Roland Stigge Signed-off-by: Bryan Wu --- drivers/leds/leds-gpio.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 0b418531526..6a2109638fb 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -21,6 +21,7 @@ #include #include #include +#include struct gpio_led_data { struct led_classdev cdev; @@ -174,12 +175,16 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev /* 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 = {}; @@ -214,7 +219,7 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev 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[] = { @@ -224,7 +229,7 @@ static const struct of_device_id of_gpio_leds_match[] = { #else /* CONFIG_OF_GPIO */ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_device *pdev) { - return NULL; + return ERR_PTR(-ENODEV); } #endif /* CONFIG_OF_GPIO */ @@ -262,8 +267,8 @@ static int __devinit 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); -- cgit v1.2.3-70-g09d2 From 1b21ec5a2852ffd8db4189d4ef1c221aabc64936 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Sun, 28 Oct 2012 18:45:11 -0700 Subject: leds: leds-lp5523: fix build warnings This patch fixes build warnings as below: drivers/leds/leds-lp5523.c: In function 'lp5523_selftest': drivers/leds/leds-lp5523.c:496:18: warning: 'adc' may be used uninitialized in this function [-Wuninitialized] drivers/leds/leds-lp5523.c:471:5: warning: 'vdd' may be used uninitialized in this function [-Wuninitialized] drivers/leds/leds-lp5523.c: In function 'lp5523_probe': drivers/leds/leds-lp5523.c:252:9: warning: 'status' may be used uninitialized in this function [-Wuninitialized] drivers/leds/leds-lp5523.c:201:5: note: 'status' was declared here If lp5523_read() returns an error, problems will happen. Thus, when lp5523_read() returns an error, it should be handled. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5523.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 97994ffdc01..4ddf7b445a8 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -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); -- cgit v1.2.3-70-g09d2 From 3651c4b904b005fcba757c529184e8c3c596cb05 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Sun, 28 Oct 2012 21:31:07 -0700 Subject: leds: leds-88pm860x: drop devm_kfree of devm_kzalloc'd data The devm_kfree function allocates memory that is released when a driver detaches. Thus, there is no reason to explicitly call devm_kfree in probe or remove functions. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-88pm860x.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index b7e8cc0957f..6be2edd4117 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) -- cgit v1.2.3-70-g09d2 From 5bbf150cca196cb973e14d0a80508ba7f588dfd1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 29 Oct 2012 01:40:21 -0700 Subject: leds: lm355x: Fix up world writable sysfs file We don't need the sysfs file to be world writable or group writable. This file is write-only, change it to S_IWUSR (0200). Signed-off-by: Axel Lin Acked-by: G.Shark Jeong Signed-off-by: Bryan Wu --- drivers/leds/leds-lm355x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c index 8f4e8e21ddb..6bc029255e5 100644 --- a/drivers/leds/leds-lm355x.c +++ b/drivers/leds/leds-lm355x.c @@ -411,7 +411,7 @@ out: 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, -- cgit v1.2.3-70-g09d2 From 5cce0105c8d07d3bd5f578c77d273e1a1e09f157 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 29 Oct 2012 01:41:46 -0700 Subject: leds: lm3642: Fix up world writable sysfs files We don't need these sysfs files to be world writable or group writable. These files are write-only, change them to S_IWUSR (0200). Signed-off-by: Axel Lin Acked-by: G.Shark Jeong Signed-off-by: Bryan Wu --- drivers/leds/leds-lm3642.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c index b69acac6d71..83fc7d70da1 100644 --- a/drivers/leds/leds-lm3642.c +++ b/drivers/leds/leds-lm3642.c @@ -207,7 +207,7 @@ out_strtoint: 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) { @@ -264,7 +264,7 @@ out_strtoint: 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) { -- cgit v1.2.3-70-g09d2 From a8df7b1ab70bfd6f261fa5e96985fca638299acc Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Sun, 4 Nov 2012 01:54:34 -0800 Subject: leds: add led_trigger_rename function Implements a "led_trigger_rename" function to rename a trigger with proper locking. This assumes that led name was originally allocated in non-constant storage. Signed-off-by: Fabio Baltieri Cc: Kurt Van Dijck Signed-off-by: Bryan Wu --- drivers/leds/led-triggers.c | 13 +++++++++++++ include/linux/leds.h | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 262eb419371..a4fa4bf02d5 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) diff --git a/include/linux/leds.h b/include/linux/leds.h index 6e53bb31c22..8107592cfc4 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -139,6 +139,24 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, extern void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness); +/** + * led_trigger_rename_static - rename a trigger + * @name: the new trigger name + * @trig: the LED trigger to rename + * + * Change a LED trigger name by copying the string passed in + * name into current trigger name, which MUST be large + * enough for the new string. + * + * Note that name must NOT point to the same string used + * during LED registration, as that could lead to races. + * + * This is meant to be used on triggers with statically + * allocated name. + */ +extern void led_trigger_rename_static(const char *name, + struct led_trigger *trig); + /* * LED Triggers */ -- cgit v1.2.3-70-g09d2 From 057407c732b7761cf417a1e6633a02d9d473340d Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Sun, 18 Nov 2012 21:35:55 -0800 Subject: led: Add dependency on CONFIG_LEDS_TRIGGERS to led_trigger_rename_static() This patch fixes build warnings when CONFIG_LEDS_TRIGGERS is disabled as below: include/linux/leds.h:158:18: warning: 'struct led_trigger' declared inside parameter list [enabled by default] include/linux/leds.h:158:18: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] Signed-off-by: Jingoo Han Acked-by: Fabio Baltieri Signed-off-by: Bryan Wu --- include/linux/leds.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/include/linux/leds.h b/include/linux/leds.h index 8107592cfc4..0d9b5eed714 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -139,24 +139,6 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, extern void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness); -/** - * led_trigger_rename_static - rename a trigger - * @name: the new trigger name - * @trig: the LED trigger to rename - * - * Change a LED trigger name by copying the string passed in - * name into current trigger name, which MUST be large - * enough for the new string. - * - * Note that name must NOT point to the same string used - * during LED registration, as that could lead to races. - * - * This is meant to be used on triggers with statically - * allocated name. - */ -extern void led_trigger_rename_static(const char *name, - struct led_trigger *trig); - /* * LED Triggers */ @@ -197,6 +179,23 @@ extern void led_trigger_blink_oneshot(struct led_trigger *trigger, unsigned long *delay_on, unsigned long *delay_off, int invert); +/** + * led_trigger_rename_static - rename a trigger + * @name: the new trigger name + * @trig: the LED trigger to rename + * + * Change a LED trigger name by copying the string passed in + * name into current trigger name, which MUST be large + * enough for the new string. + * + * Note that name must NOT point to the same string used + * during LED registration, as that could lead to races. + * + * This is meant to be used on triggers with statically + * allocated name. + */ +extern void led_trigger_rename_static(const char *name, + struct led_trigger *trig); #else -- cgit v1.2.3-70-g09d2 From 69b44c1630b7f618c9dec217d5497744224d90b8 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Sun, 18 Nov 2012 20:51:20 -0800 Subject: leds: leds-lp5521: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5521.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 2064aefedc0..362e29e27db 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -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; -- cgit v1.2.3-70-g09d2 From eef4aa652c40237f73258d5418b03d60a2ffec40 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Sun, 18 Nov 2012 20:51:47 -0800 Subject: leds: leds-lp5523: replace strict_strtoul() with kstrtoul() The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 4ddf7b445a8..59ec383900d 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -710,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) -- cgit v1.2.3-70-g09d2 From 313e8b50c89a76c4f36af527f937c2f8cf4cad41 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 01:59:00 -0800 Subject: leds: lp5521: Fix return value Return the value obtained from i2c_smbus_read_byte_data() instead of -EIO. Silences the following smatch warning: drivers/leds/leds-lp5521.c:155 lp5521_read() info: why not propagate 'ret' from i2c_smbus_read_byte_data() instead of -5? Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5521.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 362e29e27db..8505afe4b52 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; -- cgit v1.2.3-70-g09d2 From 5ebab74a711388fc30e6d839eee79aa06d1ce0af Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 01:59:01 -0800 Subject: leds: lp5523: Fix return value Return the value obtained from i2c_smbus_read_byte_data() instead of -EIO. Silences the following smatch warning: drivers/leds/leds-lp5523.c:174 lp5523_read() info: why not propagate 'ret' from i2c_smbus_read_byte_data() instead of -5? Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 59ec383900d..eb89cbd419c 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; -- cgit v1.2.3-70-g09d2 From 4401e48737c4068604144a5c0ba23a9c82ea3a37 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 01:59:02 -0800 Subject: leds: lp3944: Fix return value Return the value obtained from i2c_smbus_read_byte_data() instead of -EINVAL. Silences the following smatch warning: drivers/leds/leds-lp3944.c:89 lp3944_reg_read() info: why not propagate 'tmp' from i2c_smbus_read_byte_data() instead of -22? Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-lp3944.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c index c298f7d9f53..b2d82e2d2e9 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; -- cgit v1.2.3-70-g09d2 From e3b1d44c3550e5badfa5b78ffec80e15d7d9b287 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 10:10:20 +0530 Subject: leds: leds-gpio: use devm_gpio_request_one devm_gpio_request_one is device managed and makes error handling and cleanup simpler. Cc: Raphael Assenat Cc: Trent Piepho Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-gpio.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 6a2109638fb..77e2e405792 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -126,7 +126,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template, if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_request_one(template->gpio, + ret = devm_gpio_request_one(parent, template->gpio, GPIOF_DIR_OUT | (led_dat->active_low ^ state), template->name); if (ret < 0) @@ -136,12 +136,9 @@ static int __devinit create_gpio_led(const struct gpio_led *template, 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) @@ -150,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 { -- cgit v1.2.3-70-g09d2 From 95a8ff835674e1156c0640f83829773f8bfe655a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 10:14:27 +0530 Subject: leds: leds-lt3593: use devm_gpio_request_one devm_gpio_request_one is device managed and makes error handling and cleanup simpler. Signed-off-by: Sachin Kamat Acked-by: Daniel Mack Signed-off-by: Bryan Wu --- drivers/leds/leds-lt3593.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 17b710c6399..5ee6b8b7e4d 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -106,8 +106,8 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_request_one(template->gpio, GPIOF_DIR_OUT | state, - template->name); + ret = devm_gpio_request_one(parent, template->gpio, + GPIOF_DIR_OUT | state, template->name); if (ret < 0) return ret; @@ -115,16 +115,12 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, 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", 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) @@ -134,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 __devinit lt3593_led_probe(struct platform_device *pdev) -- cgit v1.2.3-70-g09d2 From 04195823aa16d648cd7f52abd2ea6df1b9aee53f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 10:28:10 +0530 Subject: leds: leds-ns2: use devm_gpio_request_one devm_gpio_request_one is device managed and makes error handling and cleanup simpler. Cc: Simon Guinot Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-ns2.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 5df2a250a13..9505d862a21 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -191,7 +191,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, int ret; enum ns2_led_modes mode; - ret = gpio_request_one(template->cmd, + ret = devm_gpio_request_one(&pdev->dev, template->cmd, GPIOF_DIR_OUT | gpio_get_value(template->cmd), template->name); if (ret) { @@ -200,13 +200,13 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, return ret; } - ret = gpio_request_one(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); @@ -221,7 +221,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; @@ -230,7 +230,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) @@ -240,11 +240,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; } @@ -252,8 +247,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); } static int __devinit ns2_led_probe(struct platform_device *pdev) -- cgit v1.2.3-70-g09d2 From d23e7b8b61d012e8a86097c5c6f411ede04ca955 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 10:57:35 +0530 Subject: leds: led-class: Fix checkpatch warning Fixes the following checkpatch warning: WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ... FILE: leds/led-class.c:214: printk(KERN_DEBUG "Registered led device: %s\n", Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/led-class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 48cce18e9d6..a20752f562b 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; -- cgit v1.2.3-70-g09d2 From ef734162757a27e7492e32a269e6af5a8e757d8e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 11:05:41 +0530 Subject: leds: leds-adp5520: Fix checkpatch warnings Fixes the following type of checkpatch warnings: WARNING: please, no space before tabs Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-adp5520.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c index aa56a867693..ed15e6e55b9 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 Rapoport * * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao + * Eric Miao * * Licensed under the GPL-2 or later. */ -- cgit v1.2.3-70-g09d2 From 6b8aa9726264a099f0f15d9d25841ed97866c48e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 11:09:52 +0530 Subject: leds: leds-bd2802: Fix checkpatch warnings Fixes the following type of checkpatch warnings: WARNING: please, no space before tabs Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-bd2802.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c index ebdfe295d83..7044c460ede 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; -- cgit v1.2.3-70-g09d2 From 141bfeea561fd19e599153e31d1b46e86ffa5753 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 11:16:28 +0530 Subject: leds: leds-da903x: Fix checkpatch error and warnings Fixes the following type of checkpatch error and warnings: WARNING: please, no space before tabs ERROR: trailing whitespace WARNING: quoted string split across lines Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-da903x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c index cc77c9d9261..d7671afa4d2 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 Rapoport * * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao + * Eric Miao * * 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 " - "Mike Rapoport "); +MODULE_AUTHOR("Eric Miao "); +MODULE_AUTHOR("Mike Rapoport "); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:da903x-led"); -- cgit v1.2.3-70-g09d2 From 39de81a963ad261bcf2275ce5b1d6674a30c0428 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 11:38:05 +0530 Subject: leds: leds-gpio: Use dev_info instead of printk Fixes the following checkpatch warning: WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... FILE: leds/leds-gpio.c:105: printk(KERN_INFO "Skipping unavailable LED gpio %d (%s)\n", Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 77e2e405792..4f3179245ff 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -102,7 +102,7 @@ static int __devinit 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; } -- cgit v1.2.3-70-g09d2 From 30e5c3e6b74b6f8998a2b8407c66acf33ac521d0 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:10:27 +0530 Subject: leds: leds-lt3593: Fix checkpatch warnings Fixes the following type of checkpatch warnings: WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-lt3593.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 5ee6b8b7e4d..f415c20d6fa 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -89,7 +89,7 @@ static int __devinit 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; } @@ -117,7 +117,7 @@ static int __devinit create_lt3593_led(const struct gpio_led *template, if (ret < 0) 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; -- cgit v1.2.3-70-g09d2 From 6023ff738a29dfc27237eea8ba5da9540504a5be Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:14:13 +0530 Subject: leds: leds-net48xx: Use linux/io.h instead of asm/io.h Fixes the following checkpatch warning: WARNING: Use #include instead of Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-net48xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-net48xx.c b/drivers/leds/leds-net48xx.c index f117f7326c5..27d06c52824 100644 --- a/drivers/leds/leds-net48xx.c +++ b/drivers/leds/leds-net48xx.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v1.2.3-70-g09d2 From b40b0c17d7fa5973e88e5453e000b7ff6ba4060d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:21:47 +0530 Subject: leds: leds-pca955x: Use dev_info instead of printk Fixes the following checkpatch warning: WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-pca955x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index aef3cf0432f..f1b36ada099 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -277,7 +277,7 @@ static int __devinit 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); -- cgit v1.2.3-70-g09d2 From dcba91056f1271ced1aca111e11514dcbf059922 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:24:55 +0530 Subject: leds: leds-pwm: Fix checkpatch warning Fixes the following checkpatch warning: WARNING: please, no space before tabs FILE: leds/leds-pwm.c:29: ^Iunsigned int ^I^Iactive_low;$ Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index f2e44c71943..827cb6eb55d 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; }; -- cgit v1.2.3-70-g09d2 From b75d280272bd0cbc79024b4635b0ccd67c416953 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:45:11 +0530 Subject: leds: leds-wm8350: Use dev_err instead of printk Fixes the following type of checkpatch warnings: WARNING: Prefer netdev_err(netdev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-wm8350.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c index 88f23f84559..ed15157c8f6 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); } -- cgit v1.2.3-70-g09d2 From 572dc62078440b32cbfb42a4221bf9880a5846c8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:48:32 +0530 Subject: leds: leds-wrap: Use instead of Fixes the following checkpatch warning: WARNING: Use #include instead of Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c index 6e21e654bb0..b358cc05eff 100644 --- a/drivers/leds/leds-wrap.c +++ b/drivers/leds/leds-wrap.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include -- cgit v1.2.3-70-g09d2 From 18e6f1392d6679b51799bfbc090eba3bea1f540a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 12:52:28 +0530 Subject: leds: ledtrig-backlight: Fix checkpatch error Fixes the following checkpatch error: ERROR: space prohibited before that ':' (ctx:WxE) Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/ledtrig-backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c index c74aff1fe70..027a2b15d7d 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; -- cgit v1.2.3-70-g09d2 From 09f5fe756329fd7fb6ccb94563960d6a22eaaab2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sun, 25 Nov 2012 13:00:44 +0530 Subject: leds: led-triggers: Fix checkpatch warnings Fixes the following type of warnings: WARNING: Prefer netdev_warn(netdev, ... then dev_warn(dev, ... then pr_warn(... to printk(KERN_WARNING ... WARNING: quoted string split across lines While at it also fix a coding style issue w.r.t braces. Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/led-triggers.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index a4fa4bf02d5..3c972b2f989 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -313,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); -- cgit v1.2.3-70-g09d2 From 7a0eff4d83165dc8f90a4e77c59d7fef6da04bed Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 Nov 2012 20:38:09 -0800 Subject: leds: leds-rb532: Fix checkpatch errors Fixes the following issues: ERROR: code indent should use tabs where possible WARNING: please, no spaces at the start of a line Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-rb532.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c index a7815b6cd85..f4a48519030 100644 --- a/drivers/leds/leds-rb532.c +++ b/drivers/leds/leds-rb532.c @@ -16,7 +16,7 @@ #include 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); -- cgit v1.2.3-70-g09d2 From 5c6f844cee2139182b3a778f2a883a77e5bb8f7d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 Nov 2012 20:38:10 -0800 Subject: leds: leds-clevo-mail: Use pr_* instead of printks Silences checkpatch warnings related to the use of printks. Signed-off-by: Sachin Kamat Signed-off-by: Bryan Wu --- drivers/leds/leds-clevo-mail.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c index e024b0b1c3b..4fd0493ea4c 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 @@ -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 -- cgit v1.2.3-70-g09d2 From 2f05e1d4458f9cb68d4d36fb47e6830fec03c80e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sun, 2 Dec 2012 09:29:30 -0800 Subject: leds: leds-lp5521: return an error code on error in probe() If "buf" wasn't equal to LP5521_REG_R_CURR_DEFAULT the probe fails but we still return zero. I've changed it to print an error message and return -EINVAL. Reported-by: Ben Hutchings Signed-off-by: Dan Carpenter Signed-off-by: Bryan Wu --- drivers/leds/leds-lp5521.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 8505afe4b52..ddc43152915 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -788,10 +788,17 @@ static int __devinit 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); -- cgit v1.2.3-70-g09d2