From: Rebecca Schultz Zavin Date: Thu, 16 Dec 2010 02:36:22 +0000 (-0800) Subject: leds: lp8550: Fix regulator enable/disable in lp8550 driver X-Git-Tag: firefly_0821_release~9834^2~238 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=41c5e6ff9150d92593618c4473860bd8b15a4aa7;p=firefly-linux-kernel-4.4.55.git leds: lp8550: Fix regulator enable/disable in lp8550 driver Change-Id: I6ec17f20b92eb4f02489be82d5943882e2266633 Signed-off-by: Rebecca Schultz Zavin --- diff --git a/drivers/leds/leds-lp8550.c b/drivers/leds/leds-lp8550.c index 3a89a99b9a4d..cdf48a47b24a 100755 --- a/drivers/leds/leds-lp8550.c +++ b/drivers/leds/leds-lp8550.c @@ -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;