leds: wm8350: Remove work queue
authorAndrew Lunn <andrew@lunn.ch>
Thu, 20 Aug 2015 10:59:45 +0000 (12:59 +0200)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Mon, 4 Jan 2016 08:57:35 +0000 (09:57 +0100)
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 <andrew@lunn.ch>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Antonio Ospite <ao2@ao2.it>
Reviewed-by: Mark Brown <broonie@kernel.org>
drivers/leds/leds-wm8350.c
include/linux/mfd/wm8350/pmic.h

index 0d121835673f2180edd30f8cdf53a53ca6e474af..e1e4e9d0b8b187a35b55e8fe0213b4eb96428491 100644 (file)
@@ -89,40 +89,42 @@ static const int isink_cur[] = {
 #define to_wm8350_led(led_cdev) \
        container_of(led_cdev, struct wm8350_led, cdev)
 
-static void wm8350_led_enable(struct wm8350_led *led)
+static int wm8350_led_enable(struct wm8350_led *led)
 {
-       int ret;
+       int ret = 0;
 
        if (led->enabled)
-               return;
+               return ret;
 
        ret = regulator_enable(led->isink);
        if (ret != 0) {
                dev_err(led->cdev.dev, "Failed to enable ISINK: %d\n", ret);
-               return;
+               return ret;
        }
 
        ret = regulator_enable(led->dcdc);
        if (ret != 0) {
                dev_err(led->cdev.dev, "Failed to enable DCDC: %d\n", ret);
                regulator_disable(led->isink);
-               return;
+               return ret;
        }
 
        led->enabled = 1;
+
+       return ret;
 }
 
-static void wm8350_led_disable(struct wm8350_led *led)
+static int wm8350_led_disable(struct wm8350_led *led)
 {
-       int ret;
+       int ret = 0;
 
        if (!led->enabled)
-               return;
+               return ret;
 
        ret = regulator_disable(led->dcdc);
        if (ret != 0) {
                dev_err(led->cdev.dev, "Failed to disable DCDC: %d\n", ret);
-               return;
+               return ret;
        }
 
        ret = regulator_disable(led->isink);
@@ -132,27 +134,29 @@ static void wm8350_led_disable(struct wm8350_led *led)
                if (ret != 0)
                        dev_err(led->cdev.dev, "Failed to reenable DCDC: %d\n",
                                ret);
-               return;
+               return ret;
        }
 
        led->enabled = 0;
+
+       return ret;
 }
 
-static void led_work(struct work_struct *work)
+static int wm8350_led_set(struct led_classdev *led_cdev,
+                          enum led_brightness value)
 {
-       struct wm8350_led *led = container_of(work, struct wm8350_led, work);
+       struct wm8350_led *led = to_wm8350_led(led_cdev);
+       unsigned long flags;
        int ret;
        int uA;
-       unsigned long flags;
 
-       mutex_lock(&led->mutex);
+       led->value = value;
 
        spin_lock_irqsave(&led->value_lock, flags);
 
        if (led->value == LED_OFF) {
                spin_unlock_irqrestore(&led->value_lock, flags);
-               wm8350_led_disable(led);
-               goto out;
+               return wm8350_led_disable(led);
        }
 
        /* This scales linearly into the index of valid current
@@ -166,36 +170,21 @@ static void led_work(struct work_struct *work)
 
        ret = regulator_set_current_limit(led->isink, isink_cur[uA],
                                          isink_cur[uA]);
-       if (ret != 0)
+       if (ret != 0) {
                dev_err(led->cdev.dev, "Failed to set %duA: %d\n",
                        isink_cur[uA], ret);
+               return ret;
+       }
 
-       wm8350_led_enable(led);
-
-out:
-       mutex_unlock(&led->mutex);
-}
-
-static void wm8350_led_set(struct led_classdev *led_cdev,
-                          enum led_brightness value)
-{
-       struct wm8350_led *led = to_wm8350_led(led_cdev);
-       unsigned long flags;
-
-       spin_lock_irqsave(&led->value_lock, flags);
-       led->value = value;
-       schedule_work(&led->work);
-       spin_unlock_irqrestore(&led->value_lock, flags);
+       return wm8350_led_enable(led);
 }
 
 static void wm8350_led_shutdown(struct platform_device *pdev)
 {
        struct wm8350_led *led = platform_get_drvdata(pdev);
 
-       mutex_lock(&led->mutex);
        led->value = LED_OFF;
        wm8350_led_disable(led);
-       mutex_unlock(&led->mutex);
 }
 
 static int wm8350_led_probe(struct platform_device *pdev)
@@ -232,7 +221,7 @@ static int wm8350_led_probe(struct platform_device *pdev)
        if (led == NULL)
                return -ENOMEM;
 
-       led->cdev.brightness_set = wm8350_led_set;
+       led->cdev.brightness_set_blocking = wm8350_led_set;
        led->cdev.default_trigger = pdata->default_trigger;
        led->cdev.name = pdata->name;
        led->cdev.flags |= LED_CORE_SUSPENDRESUME;
@@ -251,8 +240,6 @@ static int wm8350_led_probe(struct platform_device *pdev)
                         pdata->max_uA);
 
        spin_lock_init(&led->value_lock);
-       mutex_init(&led->mutex);
-       INIT_WORK(&led->work, led_work);
        led->value = LED_OFF;
        platform_set_drvdata(pdev, led);
 
@@ -264,7 +251,6 @@ static int wm8350_led_remove(struct platform_device *pdev)
        struct wm8350_led *led = platform_get_drvdata(pdev);
 
        led_classdev_unregister(&led->cdev);
-       flush_work(&led->work);
        wm8350_led_disable(led);
        return 0;
 }
index 579b50ca2e026b783f48759b099ff51ca5d219ba..7a09e7f1f984bfdb83c4075bd9d71951285af5e7 100644 (file)
@@ -715,7 +715,6 @@ struct wm8350_led_platform_data {
 
 struct wm8350_led {
        struct platform_device *pdev;
-       struct mutex mutex;
        struct work_struct work;
        spinlock_t value_lock;
        enum led_brightness value;