Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbbHTOr0 (ORCPT ); Thu, 20 Aug 2015 10:47:26 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:53019 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbbHTOrW (ORCPT ); Thu, 20 Aug 2015 10:47:22 -0400 X-AuditID: cbfee61b-f79706d000001b96-61-55d5e87970ae From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Lunn , Jacek Anaszewski Subject: [PATCH/RFC v6 27/36] leds: da9052: Remove work queue Date: Thu, 20 Aug 2015 16:43:57 +0200 Message-id: <1440081846-11697-28-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+NgFvrDJMWRmVeSWpSXmKPExsVy+t9jAd3KF1dDDZZM47Y4f/cQs0Xv1eeM Fpd3zWGz2PpmHaMDi8fOHZ+ZPPq2rGL0+LxJLoA5issmJTUnsyy1SN8ugSvjc88lloK7chX3 Xp5hbWCcLtnFyMkhIWAicWD1UTYIW0ziwr31QDYXh5DAUkaJv6v3gyWEBH4ySqy+ywliswkY Svx88ZoJxBYRsJHonTEJzGYW8JW4sn8FM4gtLGArcXP3G7BeFgFVidOP28DivAKeErfOvgOq 5wBapiAxZ5INSJgTKDxv/ld2iFUeEi/eb2GewMi7gJFhFaNEakFyQXFSeq5RXmq5XnFibnFp Xrpecn7uJkZwmDyT3sF4eJf7IUYBDkYlHt4LwldDhVgTy4orcw8xSnAwK4nw3noGFOJNSays Si3Kjy8qzUktPsQozcGiJM6rb7IpVEggPbEkNTs1tSC1CCbLxMEp1cCoJNoqtSfJr/A3n8XZ 68K11ZpP+1yEf+46L/Do2sb9Jcnld5KtXwh5s+1iLpIKeGSZwX5f7uVBTwflIlemqgvVLC81 +itO5xxaVG98b9a214H+SkflFxcl/VrOPXk/L/+qkPNOMl7PYy4YfAmUDtp+YfbB2S7c7+9e E8gMrVvTz9Zg4Bi9+64SS3FGoqEWc1FxIgDSBBUlDwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4049 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 Signed-off-by: Jacek Anaszewski --- drivers/leds/leds-da9052.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c index 28291b6..f8c7d82 100644 --- a/drivers/leds/leds-da9052.c +++ b/drivers/leds/leds-da9052.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -32,11 +31,9 @@ struct da9052_led { struct led_classdev cdev; - struct work_struct work; struct da9052 *da9052; unsigned char led_index; unsigned char id; - int brightness; }; static unsigned char led_reg[] = { @@ -44,12 +41,13 @@ static unsigned char led_reg[] = { DA9052_LED_CONT_5_REG, }; -static int da9052_set_led_brightness(struct da9052_led *led) +static int da9052_set_led_brightness(struct da9052_led *led, + enum led_brightness brightness) { u8 val; int error; - val = (led->brightness & 0x7f) | DA9052_LED_CONT_DIM; + val = (brightness & 0x7f) | DA9052_LED_CONT_DIM; error = da9052_reg_write(led->da9052, led_reg[led->led_index], val); if (error < 0) @@ -58,21 +56,13 @@ static int da9052_set_led_brightness(struct da9052_led *led) return error; } -static void da9052_led_work(struct work_struct *work) -{ - struct da9052_led *led = container_of(work, struct da9052_led, work); - - da9052_set_led_brightness(led); -} - -static void da9052_led_set(struct led_classdev *led_cdev, +static int da9052_led_set(struct led_classdev *led_cdev, enum led_brightness value) { - struct da9052_led *led; + struct da9052_led *led = + container_of(led_cdev, struct da9052_led, cdev); - led = container_of(led_cdev, struct da9052_led, cdev); - led->brightness = value; - schedule_work(&led->work); + return da9052_set_led_brightness(led, value); } static int da9052_configure_leds(struct da9052 *da9052) @@ -133,13 +123,11 @@ static int da9052_led_probe(struct platform_device *pdev) for (i = 0; i < pled->num_leds; i++) { led[i].cdev.name = pled->leds[i].name; - led[i].cdev.brightness_set = da9052_led_set; + led[i].cdev.brightness_set_blocking = da9052_led_set; led[i].cdev.brightness = LED_OFF; led[i].cdev.max_brightness = DA9052_MAX_BRIGHTNESS; - led[i].brightness = LED_OFF; led[i].led_index = pled->leds[i].flags; led[i].da9052 = dev_get_drvdata(pdev->dev.parent); - INIT_WORK(&led[i].work, da9052_led_work); error = led_classdev_register(pdev->dev.parent, &led[i].cdev); if (error) { @@ -148,7 +136,8 @@ static int da9052_led_probe(struct platform_device *pdev) goto err_register; } - error = da9052_set_led_brightness(&led[i]); + error = da9052_set_led_brightness(&led[i], + led[i].cdev.brightness); if (error) { dev_err(&pdev->dev, "Unable to init led %d\n", led[i].led_index); @@ -166,10 +155,8 @@ static int da9052_led_probe(struct platform_device *pdev) return 0; err_register: - for (i = i - 1; i >= 0; i--) { + for (i = i - 1; i >= 0; i--) led_classdev_unregister(&led[i].cdev); - cancel_work_sync(&led[i].work); - } err: return error; } @@ -187,10 +174,8 @@ static int da9052_led_remove(struct platform_device *pdev) pled = pdata->pled; for (i = 0; i < pled->num_leds; i++) { - led[i].brightness = 0; - da9052_set_led_brightness(&led[i]); + da9052_set_led_brightness(&led[i], LED_OFF); led_classdev_unregister(&led[i].cdev); - cancel_work_sync(&led[i].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/