#include <linux/slab.h>
#include <linux/types.h>
#include <linux/earlysuspend.h>
+#include <linux/regulator/consumer.h>
+#include <linux/err.h>
#define DEBUG
int brightness;
atomic_t enabled;
bool suspended;
+ struct regulator *regulator;
#ifdef CONFIG_HAS_EARLYSUSPEND
struct early_suspend early_suspender;
#endif
__func__, error);
}
atomic_set(&led_data->enabled, 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))
+ regulator_enable(led_data->regulator);
if (lp8550_write_reg(led_data, LP8550_DEVICE_CTRL,
led_data->led_pdata->dev_ctrl_config | 0x01))
pr_err("%s:writing failed while setting brightness:%d\n",
}
#endif
+ led_data->regulator = regulator_get(&client->dev, "vio");
+ if (!IS_ERR_OR_NULL(led_data->regulator))
+ regulator_enable(led_data->regulator);
+
return 0;
err_class_reg_failed:
#ifdef DEBUG
device_remove_file(led_data->led_dev.dev, &dev_attr_registers);
#endif
+ if (!IS_ERR_OR_NULL(led_data->regulator))
+ regulator_put(led_data->regulator);
led_classdev_unregister(&led_data->led_dev);
kfree(led_data);
return 0;