leds: lp8550: Fix regulator enable/disable in lp8550 driver
authorRebecca Schultz Zavin <rebecca@android.com>
Thu, 16 Dec 2010 02:36:22 +0000 (18:36 -0800)
committerRebecca Schultz Zavin <rebecca@android.com>
Thu, 16 Dec 2010 02:36:22 +0000 (18:36 -0800)
Change-Id: I6ec17f20b92eb4f02489be82d5943882e2266633
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
drivers/leds/leds-lp8550.c

index 3a89a99b9a4d18a48ecfc9506690a38253f9d5ce..cdf48a47b24ada0fc61648c9fa2057281a147220 100755 (executable)
@@ -248,9 +248,9 @@ static void lp8550_brightness_write(struct lp8550_data *led_data)
                        pr_err("%s:writing failed while setting brightness:%d\n",
                                __func__, error);
                }
-               atomic_set(&led_data->enabled, 0);
-               if (!IS_ERR_OR_NULL(led_data->regulator))
-                       regulator_disable(led_data->regulator);
+               if (atomic_cmpxchg(&led_data->enabled, 1, 0))
+                       if (!IS_ERR_OR_NULL(led_data->regulator))
+                               regulator_disable(led_data->regulator);
        } else {
                if (!atomic_cmpxchg(&led_data->enabled, 0, 1)) {
                        if (!IS_ERR_OR_NULL(led_data->regulator))
@@ -452,8 +452,6 @@ static int ld_lp8550_probe(struct i2c_client *client,
 #endif
 
        led_data->regulator = regulator_get(&client->dev, "vio");
-       if (!IS_ERR_OR_NULL(led_data->regulator))
-               regulator_enable(led_data->regulator);
 
        return 0;