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))
#endif
led_data->regulator = regulator_get(&client->dev, "vio");
- if (!IS_ERR_OR_NULL(led_data->regulator))
- regulator_enable(led_data->regulator);
return 0;