Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbbHTOrJ (ORCPT ); Thu, 20 Aug 2015 10:47:09 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:54949 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753644AbbHTOrC (ORCPT ); Thu, 20 Aug 2015 10:47:02 -0400 X-AuditID: cbfee61b-f79706d000001b96-4a-55d5e86414b8 From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Lunn , Milo Kim , Jacek Anaszewski Subject: [PATCH/RFC v6 21/36] leds: lp8788: Remove work queue Date: Thu, 20 Aug 2015 16:43:51 +0200 Message-id: <1440081846-11697-22-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1440081846-11697-1-git-send-email-j.anaszewski@samsung.com> References: <1440081846-11697-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjluLIzCtJLcpLzFFi42I5/e+xgG7qi6uhBp3f2CzO3z3EbNF79Tmj xeVdc9gstr5Zx2ix/Nc6FgdWj507PjN59G1Zxehx/MZ2Jo/Pm+QCWKK4bFJSczLLUov07RK4 MtZ93M1SsFWmYvrtCawNjPPFuxg5OCQETCQuzy3uYuQEMsUkLtxbz9bFyMUhJLCUUWJ7/xpW COcno8TEU4vZQarYBAwlfr54zQRiiwjYSPTOmARmMwtkS/QtXgtWIyxgK3GmaRIbiM0ioCox fcsRMJtXwFPi4ulvzBCLFSTmTLIBCXMChefN/wrWKiTgIfHi/RbmCYy8CxgZVjFKpBYkFxQn peca5aWW6xUn5haX5qXrJefnbmIEh84z6R2Mh3e5H2IU4GBU4uG9IHw1VIg1say4MvcQowQH s5II761nQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8+iabQoUE0hNLUrNTUwtSi2CyTBycUg2M fc0W65ILMhuebNpkUHdAwyw7Y6XBEh2F5EvzDDam/dJa8L97z6J6ta5lv66zS+4wV95z7UvK +qSUi9O2HPj+Yp2vvuxq+0TRexz/w9nbd/5JtBTeeGxPjbegRJ/FhMTow9877p9YabhW/L/J Ui3dG09qWop2qlY89ytVmRwhmPy/IHyRcFeaEktxRqKhFnNRcSIAULzuLhkCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3753 Lines: 134 From: Andrew Lunn Now the core implements the work queue, remove it from the drivers, and switch to using brightness_set_blocking op. Signed-off-by: Andrew Lunn Cc: Milo Kim Signed-off-by: Jacek Anaszewski --- drivers/leds/leds-lp8788.c | 48 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/leds/leds-lp8788.c b/drivers/leds/leds-lp8788.c index 3409f03..0eee38f 100644 --- a/drivers/leds/leds-lp8788.c +++ b/drivers/leds/leds-lp8788.c @@ -26,10 +26,8 @@ struct lp8788_led { struct lp8788 *lp; struct mutex lock; - struct work_struct work; struct led_classdev led_dev; enum lp8788_isink_number isink_num; - enum led_brightness brightness; int on; }; @@ -76,24 +74,29 @@ static int lp8788_led_init_device(struct lp8788_led *led, return lp8788_update_bits(led->lp, addr, mask, val); } -static void lp8788_led_enable(struct lp8788_led *led, +static int lp8788_led_enable(struct lp8788_led *led, enum lp8788_isink_number num, int on) { + int ret; + u8 mask = 1 << num; u8 val = on << num; - if (lp8788_update_bits(led->lp, LP8788_ISINK_CTRL, mask, val)) - return; + ret = lp8788_update_bits(led->lp, LP8788_ISINK_CTRL, mask, val); + if (ret == 0) + led->on = on; - led->on = on; + return ret; } -static void lp8788_led_work(struct work_struct *work) +static int lp8788_brightness_set(struct led_classdev *led_cdev, + enum led_brightness val) { - struct lp8788_led *led = container_of(work, struct lp8788_led, work); + struct lp8788_led *led = + container_of(led_cdev, struct lp8788_led, led_dev); + enum lp8788_isink_number num = led->isink_num; - int enable; - u8 val = led->brightness; + int enable, ret; mutex_lock(&led->lock); @@ -101,28 +104,21 @@ static void lp8788_led_work(struct work_struct *work) case LP8788_ISINK_1: case LP8788_ISINK_2: case LP8788_ISINK_3: - lp8788_write_byte(led->lp, lp8788_pwm_addr[num], val); + ret = lp8788_write_byte(led->lp, lp8788_pwm_addr[num], val); + if (ret < 0) + goto unlock; break; default: mutex_unlock(&led->lock); - return; + return -EINVAL; } enable = (val > 0) ? 1 : 0; if (enable != led->on) - lp8788_led_enable(led, num, enable); - + ret = lp8788_led_enable(led, num, enable); +unlock: mutex_unlock(&led->lock); -} - -static void lp8788_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brt_val) -{ - struct lp8788_led *led = - container_of(led_cdev, struct lp8788_led, led_dev); - - led->brightness = brt_val; - schedule_work(&led->work); + return ret; } static int lp8788_led_probe(struct platform_device *pdev) @@ -139,7 +135,7 @@ static int lp8788_led_probe(struct platform_device *pdev) led->lp = lp; led->led_dev.max_brightness = MAX_BRIGHTNESS; - led->led_dev.brightness_set = lp8788_brightness_set; + led->led_dev.brightness_set_blocking = lp8788_brightness_set; led_pdata = lp->pdata ? lp->pdata->led_pdata : NULL; @@ -149,7 +145,6 @@ static int lp8788_led_probe(struct platform_device *pdev) led->led_dev.name = led_pdata->name; mutex_init(&led->lock); - INIT_WORK(&led->work, lp8788_led_work); platform_set_drvdata(pdev, led); @@ -173,7 +168,6 @@ static int lp8788_led_remove(struct platform_device *pdev) struct lp8788_led *led = platform_get_drvdata(pdev); led_classdev_unregister(&led->led_dev); - flush_work(&led->work); return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/