thinkpad-acpi: split delayed LEDs stuff, clean up code.
Reduce code duplication and clean up thinkpad_acpi a bit. In future, I'd like to make delayed-leds.h to be useful for HP accelerometer driver (and move to drivers/leds, of course)...
Signed-off-by Pavel Machek <[email protected]>
Cc Henrique de Moraes Holschuh <[email protected]>
Cc Richard Purdie <[email protected]>
---
commit fb1dcb74b250c591442a8755d0e2520f1739fc91
tree 8e786ce272ae95489680191190a538fea054b44d
parent 5157de35ea72f159decd98846829b06297be933d
author Pavel <[email protected]> Thu, 08 Jan 2009 11:47:45 +0100 committer Pavel <[email protected]> Thu, 08 Jan 2009 11:47:45 +0100
drivers/misc/delayed-leds.h | 39 +++++++++++++++++ drivers/misc/thinkpad_acpi.c | 96 +++++++++++++----------------------------- 2 files changed, 68 insertions(+), 67 deletions(-)
drivers/misc/delayed-leds.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* delayed-leds.h - LEDs that can't be set from atomic context +* +* +* Copyright (C) 2004-2005 Borislav Deianov <[email protected]> +* Copyright (C) 2006-2008 Henrique de Moraes Holschuh <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +/* Special LED class that can defer work */ +struct delayed_led_classdev { +struct led_classdev led_classdev; +struct work_struct work; +enum led_brightness new_brightness; + +unsigned int led;/* For driver */ +int (*set_status)(struct delayed_led_classdev *data); +}; + +static void delayed_set_status_worker (struct work_struct *work) +{ +struct delayed_led_classdev *data = + container_of(work, struct delayed_led_classdev, work); + + data->set_status (data); +} + +static void delayed_sysfs_set (struct led_classdev *led_cdev, +enum led_brightness brightness) +{ +struct delayed_led_classdev *data =container_of (led_cdev, + struct delayed_led_classdev, led_classdev); + data->new_brightness = brightness; +queue_work (tpacpi_wq, &data->work); +}
drivers/misc/thinkpad_acpi.c +29 -67
186 lines not on this page · raw message
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html