diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-02-05 01:30:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:23 -0500 |
commit | fa23f5cce8cda2095013afc837ccf74b352f9f7b (patch) | |
tree | bdb22c6966b9e60eb90c97086f3ceed453223f97 | |
parent | a41e3dc4060cca2599afa14fbd4c745763746ba8 (diff) |
leds: add possibility to remove leds classdevs during suspend/resume
Make it possible to unregister a led classdev object in a safe way during a
suspend/resume cycle.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Michael Buesch <mb@bu3sch.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Len Brown <lenb@kernel.org>
Cc: Greg KH <greg@kroah.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/leds/led-class.c | 13 | ||||
-rw-r--r-- | include/linux/leds.h | 10 |
2 files changed, 18 insertions, 5 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 64c66b3769c9..4a938780dfc3 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -137,12 +137,14 @@ err_out: | |||
137 | EXPORT_SYMBOL_GPL(led_classdev_register); | 137 | EXPORT_SYMBOL_GPL(led_classdev_register); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * led_classdev_unregister - unregisters a object of led_properties class. | 140 | * __led_classdev_unregister - unregisters a object of led_properties class. |
141 | * @led_cdev: the led device to unregister | 141 | * @led_cdev: the led device to unregister |
142 | * @suspended: indicates whether system-wide suspend or resume is in progress | ||
142 | * | 143 | * |
143 | * Unregisters a previously registered via led_classdev_register object. | 144 | * Unregisters a previously registered via led_classdev_register object. |
144 | */ | 145 | */ |
145 | void led_classdev_unregister(struct led_classdev *led_cdev) | 146 | void __led_classdev_unregister(struct led_classdev *led_cdev, |
147 | bool suspended) | ||
146 | { | 148 | { |
147 | device_remove_file(led_cdev->dev, &dev_attr_brightness); | 149 | device_remove_file(led_cdev->dev, &dev_attr_brightness); |
148 | #ifdef CONFIG_LEDS_TRIGGERS | 150 | #ifdef CONFIG_LEDS_TRIGGERS |
@@ -153,13 +155,16 @@ void led_classdev_unregister(struct led_classdev *led_cdev) | |||
153 | up_write(&led_cdev->trigger_lock); | 155 | up_write(&led_cdev->trigger_lock); |
154 | #endif | 156 | #endif |
155 | 157 | ||
156 | device_unregister(led_cdev->dev); | 158 | if (suspended) |
159 | device_pm_schedule_removal(led_cdev->dev); | ||
160 | else | ||
161 | device_unregister(led_cdev->dev); | ||
157 | 162 | ||
158 | down_write(&leds_list_lock); | 163 | down_write(&leds_list_lock); |
159 | list_del(&led_cdev->node); | 164 | list_del(&led_cdev->node); |
160 | up_write(&leds_list_lock); | 165 | up_write(&leds_list_lock); |
161 | } | 166 | } |
162 | EXPORT_SYMBOL_GPL(led_classdev_unregister); | 167 | EXPORT_SYMBOL_GPL(__led_classdev_unregister); |
163 | 168 | ||
164 | static int __init leds_init(void) | 169 | static int __init leds_init(void) |
165 | { | 170 | { |
diff --git a/include/linux/leds.h b/include/linux/leds.h index b4130ff58d0c..00f89fd6c52a 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h | |||
@@ -54,7 +54,15 @@ struct led_classdev { | |||
54 | 54 | ||
55 | extern int led_classdev_register(struct device *parent, | 55 | extern int led_classdev_register(struct device *parent, |
56 | struct led_classdev *led_cdev); | 56 | struct led_classdev *led_cdev); |
57 | extern void led_classdev_unregister(struct led_classdev *led_cdev); | 57 | extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus); |
58 | static inline void led_classdev_unregister(struct led_classdev *lcd) | ||
59 | { | ||
60 | __led_classdev_unregister(lcd, false); | ||
61 | } | ||
62 | static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) | ||
63 | { | ||
64 | __led_classdev_unregister(lcd, true); | ||
65 | } | ||
58 | extern void led_classdev_suspend(struct led_classdev *led_cdev); | 66 | extern void led_classdev_suspend(struct led_classdev *led_cdev); |
59 | extern void led_classdev_resume(struct led_classdev *led_cdev); | 67 | extern void led_classdev_resume(struct led_classdev *led_cdev); |
60 | 68 | ||