static void led_work_func(struct work_struct *work)
{
	struct pm8058_led_data *ldata;

	ldata = container_of(work, struct pm8058_led_data, led_work);
	LED_ALM("%s led alarm led work +" , ldata->ldev.name);
	pwm_disable(ldata->pwm_led);
	LED_ALM("%s led alarm led work -" , ldata->ldev.name);
}
static void led_alarm_handler(struct alarm *alarm)
{
	struct pm8058_led_data *ldata;

	ldata = container_of(alarm, struct pm8058_led_data, led_alarm);
	LED_ALM("%s led alarm trigger +", ldata->ldev.name);
	queue_work(g_led_work_queue, &ldata->led_work);
	LED_ALM("%s led alarm trigger -", ldata->ldev.name);
}
Example #3
0
static void led_work_func(struct work_struct *work)
{
	struct pm8058_led_data *ldata;

	ldata = container_of(work, struct pm8058_led_data, led_work);
	LED_ALM("%s led alarm led work +" , ldata->ldev.name);
	pwm_disable(ldata->pwm_led);
	LED_ALM("%s led alarm led work -" , ldata->ldev.name);

	if (strcmp(ldata->ldev.name, "charming-led") == 0)
		charming_led_enable(0);
}
static ssize_t pm8058_led_off_timer_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{
	struct led_classdev *led_cdev;
	struct pm8058_led_data *ldata;
	int min, sec;
	uint16_t off_timer;
	ktime_t interval;
	ktime_t next_alarm;

	min = -1;
	sec = -1;
	sscanf(buf, "%d %d", &min, &sec);

	if (min < 0 || min > 255 || min == 5)
		return -EINVAL;
	if (sec < 0 || sec > 255)
		return -EINVAL;

	led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
	ldata = container_of(led_cdev, struct pm8058_led_data, ldev);

	printk(KERN_INFO "Setting %s off_timer to %d min %d sec +\n",
					   led_cdev->name, min, sec);

	off_timer = min * 60 + sec;

	alarm_cancel(&ldata->led_alarm);
	cancel_work_sync(&ldata->led_work);
	if (off_timer) {
		interval = ktime_set(off_timer, 0);
		next_alarm = ktime_add(alarm_get_elapsed_realtime(), interval);
		alarm_start_range(&ldata->led_alarm, next_alarm, next_alarm);
		LED_ALM("led alarm start -");
	}
	printk(KERN_INFO "Setting %s off_timer to %d min %d sec -\n",
					   led_cdev->name, min, sec);
	return count;
}