lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131230183302.GA28430@amd.pavel.ucw.cz>
Date:	Mon, 30 Dec 2013 19:33:03 +0100
From:	Pavel Machek <pavel@....cz>
To:	Joe Xue <lgxue@...mail.com>
Cc:	cooloney@...il.com, rpurdie@...ys.net, rob@...dley.net,
	milo.kim@...com, linux-leds@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org
Subject: Re: [PATCH] Add LED pattern trigger

Hi!

> The LED pattern trigger allows LEDs blink in user defined pattern.
> 
> 	new file:   Documentation/leds/ledtrig-pattern.txt
> 	modified:   drivers/leds/trigger/Kconfig
> 	modified:   drivers/leds/trigger/Makefile
> 	new file:   drivers/leds/trigger/ledtrig-pattern.c
> 
> Suggested-by: Pavel Machek <pavel@....cz>
> Signed-off-by: Joe Xue <lgxue@...mail.com>

> +     echo pattern > trigger
> +     echo "# ## /"
> +
> +     The behaviour is like below:
> +
> +     on(125ms)off(125ms)on(250ms)off


> +static void pattern_timer_function(unsigned long data)
> +{
> +	struct led_classdev *led_cdev = (struct led_classdev *) data;
> +	struct pattern_trig_data *pattern_data = led_cdev->trigger_data;
> +
> +	if (pattern_data->pattern[pattern_data->count] == '#') {
> +		__led_set_brightness(led_cdev, pattern_data->brightness_on);
> +		mod_timer(&pattern_data->timer,
> +			jiffies + msecs_to_jiffies(pattern_data->delay_unit));
> +	} else if (pattern_data->pattern[pattern_data->count] == ' ') {
> +		__led_set_brightness(led_cdev, LED_OFF);
> +		mod_timer(&pattern_data->timer,
> +			jiffies + msecs_to_jiffies(pattern_data->delay_unit));
> +	/* stop blinking */
> +	} else if (pattern_data->pattern[pattern_data->count] == '/') {
> +		return;
> +	}

What about something like this?

Not shcheduling timer when nothing changed should save a bit of power/cpu...

  	if (pattern_data->pattern[pattern_data->count] == '/') {
		return;
	}

	this = pattern_data->pattern[pattern_data->count]
	if (this == '#')
		new_brigtness = pattern_data->brightness_on;
	if (this == ' ')
		new_brigtness = LED_OFF;
	repeat = 1;
	while (pattern_data->pattern[pattern_data->count + repeat] == this)
	      repeat++;

	mod_timer(&pattern_data->timer,
		jiffies + msecs_to_jiffies(pattern_data->delay_unit * repeat));


Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ