aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpuid.c4
-rw-r--r--arch/x86/kernel/msr.c4
-rw-r--r--drivers/base/core.c29
-rw-r--r--drivers/base/power/main.c40
-rw-r--r--drivers/char/hw_random/core.c10
-rw-r--r--drivers/char/misc.c13
-rw-r--r--drivers/leds/led-class.c11
-rw-r--r--drivers/net/wireless/b43/leds.c5
-rw-r--r--drivers/net/wireless/b43/main.c8
-rw-r--r--include/linux/device.h14
-rw-r--r--include/linux/hw_random.h10
-rw-r--r--include/linux/leds.h10
-rw-r--r--include/linux/miscdevice.h10
13 files changed, 22 insertions, 146 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 288e7a6598ac..daff52a62248 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -154,12 +154,10 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
154 err = cpuid_device_create(cpu); 154 err = cpuid_device_create(cpu);
155 break; 155 break;
156 case CPU_UP_CANCELED: 156 case CPU_UP_CANCELED:
157 case CPU_UP_CANCELED_FROZEN:
157 case CPU_DEAD: 158 case CPU_DEAD:
158 cpuid_device_destroy(cpu); 159 cpuid_device_destroy(cpu);
159 break; 160 break;
160 case CPU_UP_CANCELED_FROZEN:
161 destroy_suspended_device(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
162 break;
163 } 161 }
164 return err ? NOTIFY_BAD : NOTIFY_OK; 162 return err ? NOTIFY_BAD : NOTIFY_OK;
165} 163}
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 4dfb40530057..1f3abe048e93 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -162,12 +162,10 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
162 err = msr_device_create(cpu); 162 err = msr_device_create(cpu);
163 break; 163 break;
164 case CPU_UP_CANCELED: 164 case CPU_UP_CANCELED:
165 case CPU_UP_CANCELED_FROZEN:
165 case CPU_DEAD: 166 case CPU_DEAD:
166 msr_device_destroy(cpu); 167 msr_device_destroy(cpu);
167 break; 168 break;
168 case CPU_UP_CANCELED_FROZEN:
169 destroy_suspended_device(msr_class, MKDEV(MSR_MAJOR, cpu));
170 break;
171 } 169 }
172 return err ? NOTIFY_BAD : NOTIFY_OK; 170 return err ? NOTIFY_BAD : NOTIFY_OK;
173} 171}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index adbc01788447..0262fc7c45fc 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1163,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt)
1163} 1163}
1164EXPORT_SYMBOL_GPL(device_destroy); 1164EXPORT_SYMBOL_GPL(device_destroy);
1165 1165
1166#ifdef CONFIG_PM_SLEEP
1167/**
1168 * destroy_suspended_device - asks the PM core to remove a suspended device
1169 * @class: pointer to the struct class that this device was registered with
1170 * @devt: the dev_t of the device that was previously registered
1171 *
1172 * This call notifies the PM core of the necessity to unregister a suspended
1173 * device created with a call to device_create() (devices cannot be
1174 * unregistered directly while suspended, since the PM core holds their
1175 * semaphores at that time).
1176 *
1177 * It can only be called within the scope of a system sleep transition. In
1178 * practice this means it has to be directly or indirectly invoked either by
1179 * a suspend or resume method, or by the PM core (e.g. via
1180 * disable_nonboot_cpus() or enable_nonboot_cpus()).
1181 */
1182void destroy_suspended_device(struct class *class, dev_t devt)
1183{
1184 struct device *dev;
1185
1186 dev = class_find_device(class, &devt, __match_devt);
1187 if (dev) {
1188 device_pm_schedule_removal(dev);
1189 put_device(dev);
1190 }
1191}
1192EXPORT_SYMBOL_GPL(destroy_suspended_device);
1193#endif /* CONFIG_PM_SLEEP */
1194
1195/** 1166/**
1196 * device_rename - renames a device 1167 * device_rename - renames a device
1197 * @dev: the pointer to the struct device to be renamed 1168 * @dev: the pointer to the struct device to be renamed
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 5630af302b2f..c4568b82875b 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -50,7 +50,6 @@
50LIST_HEAD(dpm_active); 50LIST_HEAD(dpm_active);
51static LIST_HEAD(dpm_off); 51static LIST_HEAD(dpm_off);
52static LIST_HEAD(dpm_off_irq); 52static LIST_HEAD(dpm_off_irq);
53static LIST_HEAD(dpm_destroy);
54 53
55static DEFINE_MUTEX(dpm_list_mtx); 54static DEFINE_MUTEX(dpm_list_mtx);
56 55
@@ -104,24 +103,6 @@ void device_pm_remove(struct device *dev)
104 mutex_unlock(&dpm_list_mtx); 103 mutex_unlock(&dpm_list_mtx);
105} 104}
106 105
107/**
108 * device_pm_schedule_removal - schedule the removal of a suspended device
109 * @dev: Device to destroy
110 *
111 * Moves the device to the dpm_destroy list for further processing by
112 * unregister_dropped_devices().
113 */
114void device_pm_schedule_removal(struct device *dev)
115{
116 pr_debug("PM: Preparing for removal: %s:%s\n",
117 dev->bus ? dev->bus->name : "No Bus",
118 kobject_name(&dev->kobj));
119 mutex_lock(&dpm_list_mtx);
120 list_move_tail(&dev->power.entry, &dpm_destroy);
121 mutex_unlock(&dpm_list_mtx);
122}
123EXPORT_SYMBOL_GPL(device_pm_schedule_removal);
124
125/*------------------------- Resume routines -------------------------*/ 106/*------------------------- Resume routines -------------------------*/
126 107
127/** 108/**
@@ -246,26 +227,6 @@ static void dpm_resume(void)
246} 227}
247 228
248/** 229/**
249 * unregister_dropped_devices - Unregister devices scheduled for removal
250 *
251 * Unregister all devices on the dpm_destroy list.
252 */
253static void unregister_dropped_devices(void)
254{
255 mutex_lock(&dpm_list_mtx);
256 while (!list_empty(&dpm_destroy)) {
257 struct list_head *entry = dpm_destroy.next;
258 struct device *dev = to_device(entry);
259
260 mutex_unlock(&dpm_list_mtx);
261 /* This also removes the device from the list */
262 device_unregister(dev);
263 mutex_lock(&dpm_list_mtx);
264 }
265 mutex_unlock(&dpm_list_mtx);
266}
267
268/**
269 * device_resume - Restore state of each device in system. 230 * device_resume - Restore state of each device in system.
270 * 231 *
271 * Resume all the devices, unlock them all, and allow new 232 * Resume all the devices, unlock them all, and allow new
@@ -275,7 +236,6 @@ void device_resume(void)
275{ 236{
276 might_sleep(); 237 might_sleep();
277 dpm_resume(); 238 dpm_resume();
278 unregister_dropped_devices();
279} 239}
280EXPORT_SYMBOL_GPL(device_resume); 240EXPORT_SYMBOL_GPL(device_resume);
281 241
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 349b6edc5794..662d60e44e9a 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO,
238 NULL); 238 NULL);
239 239
240 240
241static void unregister_miscdev(bool suspended) 241static void unregister_miscdev(void)
242{ 242{
243 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); 243 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
244 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); 244 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
245 __misc_deregister(&rng_miscdev, suspended); 245 misc_deregister(&rng_miscdev);
246} 246}
247 247
248static int register_miscdev(void) 248static int register_miscdev(void)
@@ -317,7 +317,7 @@ out:
317} 317}
318EXPORT_SYMBOL_GPL(hwrng_register); 318EXPORT_SYMBOL_GPL(hwrng_register);
319 319
320void __hwrng_unregister(struct hwrng *rng, bool suspended) 320void hwrng_unregister(struct hwrng *rng)
321{ 321{
322 int err; 322 int err;
323 323
@@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended)
336 } 336 }
337 } 337 }
338 if (list_empty(&rng_list)) 338 if (list_empty(&rng_list))
339 unregister_miscdev(suspended); 339 unregister_miscdev();
340 340
341 mutex_unlock(&rng_mutex); 341 mutex_unlock(&rng_mutex);
342} 342}
343EXPORT_SYMBOL_GPL(__hwrng_unregister); 343EXPORT_SYMBOL_GPL(hwrng_unregister);
344 344
345 345
346MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); 346MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index a39101feb2ed..4d058dadbfcc 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -232,9 +232,8 @@ int misc_register(struct miscdevice * misc)
232} 232}
233 233
234/** 234/**
235 * __misc_deregister - unregister a miscellaneous device 235 * misc_deregister - unregister a miscellaneous device
236 * @misc: device to unregister 236 * @misc: device to unregister
237 * @suspended: to be set if the function is used during suspend/resume
238 * 237 *
239 * Unregister a miscellaneous device that was previously 238 * Unregister a miscellaneous device that was previously
240 * successfully registered with misc_register(). Success 239 * successfully registered with misc_register(). Success
@@ -242,7 +241,7 @@ int misc_register(struct miscdevice * misc)
242 * indicates an error. 241 * indicates an error.
243 */ 242 */
244 243
245int __misc_deregister(struct miscdevice *misc, bool suspended) 244int misc_deregister(struct miscdevice *misc)
246{ 245{
247 int i = misc->minor; 246 int i = misc->minor;
248 247
@@ -251,11 +250,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
251 250
252 mutex_lock(&misc_mtx); 251 mutex_lock(&misc_mtx);
253 list_del(&misc->list); 252 list_del(&misc->list);
254 if (suspended) 253 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
255 destroy_suspended_device(misc_class,
256 MKDEV(MISC_MAJOR, misc->minor));
257 else
258 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
259 if (i < DYNAMIC_MINORS && i>0) { 254 if (i < DYNAMIC_MINORS && i>0) {
260 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 255 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
261 } 256 }
@@ -264,7 +259,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended)
264} 259}
265 260
266EXPORT_SYMBOL(misc_register); 261EXPORT_SYMBOL(misc_register);
267EXPORT_SYMBOL(__misc_deregister); 262EXPORT_SYMBOL(misc_deregister);
268 263
269static int __init misc_init(void) 264static int __init misc_init(void)
270{ 265{
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 4a938780dfc3..63aad90247c4 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -139,12 +139,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register);
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
143 * 142 *
144 * Unregisters a previously registered via led_classdev_register object. 143 * Unregisters a previously registered via led_classdev_register object.
145 */ 144 */
146void __led_classdev_unregister(struct led_classdev *led_cdev, 145void led_classdev_unregister(struct led_classdev *led_cdev)
147 bool suspended)
148{ 146{
149 device_remove_file(led_cdev->dev, &dev_attr_brightness); 147 device_remove_file(led_cdev->dev, &dev_attr_brightness);
150#ifdef CONFIG_LEDS_TRIGGERS 148#ifdef CONFIG_LEDS_TRIGGERS
@@ -155,16 +153,13 @@ void __led_classdev_unregister(struct led_classdev *led_cdev,
155 up_write(&led_cdev->trigger_lock); 153 up_write(&led_cdev->trigger_lock);
156#endif 154#endif
157 155
158 if (suspended) 156 device_unregister(led_cdev->dev);
159 device_pm_schedule_removal(led_cdev->dev);
160 else
161 device_unregister(led_cdev->dev);
162 157
163 down_write(&leds_list_lock); 158 down_write(&leds_list_lock);
164 list_del(&led_cdev->node); 159 list_del(&led_cdev->node);
165 up_write(&leds_list_lock); 160 up_write(&leds_list_lock);
166} 161}
167EXPORT_SYMBOL_GPL(__led_classdev_unregister); 162EXPORT_SYMBOL_GPL(led_classdev_unregister);
168 163
169static int __init leds_init(void) 164static int __init leds_init(void)
170{ 165{
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c
index 0aac1ff511df..36a9c42df835 100644
--- a/drivers/net/wireless/b43/leds.c
+++ b/drivers/net/wireless/b43/leds.c
@@ -116,10 +116,7 @@ static void b43_unregister_led(struct b43_led *led)
116{ 116{
117 if (!led->dev) 117 if (!led->dev)
118 return; 118 return;
119 if (led->dev->suspend_in_progress) 119 led_classdev_unregister(&led->led_dev);
120 led_classdev_unregister_suspended(&led->led_dev);
121 else
122 led_classdev_unregister(&led->led_dev);
123 b43_led_turn_off(led->dev, led->index, led->activelow); 120 b43_led_turn_off(led->dev, led->index, led->activelow);
124 led->dev = NULL; 121 led->dev = NULL;
125} 122}
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index cf5c046c9fa8..943cc851c504 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2804,10 +2804,10 @@ static int b43_rng_read(struct hwrng *rng, u32 * data)
2804 return (sizeof(u16)); 2804 return (sizeof(u16));
2805} 2805}
2806 2806
2807static void b43_rng_exit(struct b43_wl *wl, bool suspended) 2807static void b43_rng_exit(struct b43_wl *wl)
2808{ 2808{
2809 if (wl->rng_initialized) 2809 if (wl->rng_initialized)
2810 __hwrng_unregister(&wl->rng, suspended); 2810 hwrng_unregister(&wl->rng);
2811} 2811}
2812 2812
2813static int b43_rng_init(struct b43_wl *wl) 2813static int b43_rng_init(struct b43_wl *wl)
@@ -3824,7 +3824,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
3824 3824
3825 if (!dev->suspend_in_progress) { 3825 if (!dev->suspend_in_progress) {
3826 b43_leds_exit(dev); 3826 b43_leds_exit(dev);
3827 b43_rng_exit(dev->wl, false); 3827 b43_rng_exit(dev->wl);
3828 } 3828 }
3829 b43_dma_free(dev); 3829 b43_dma_free(dev);
3830 b43_pio_free(dev); 3830 b43_pio_free(dev);
@@ -4589,7 +4589,7 @@ static int b43_resume(struct ssb_device *dev)
4589 err = b43_wireless_core_start(wldev); 4589 err = b43_wireless_core_start(wldev);
4590 if (err) { 4590 if (err) {
4591 b43_leds_exit(wldev); 4591 b43_leds_exit(wldev);
4592 b43_rng_exit(wldev->wl, true); 4592 b43_rng_exit(wldev->wl);
4593 b43_wireless_core_exit(wldev); 4593 b43_wireless_core_exit(wldev);
4594 b43err(wl, "Resume failed at core start\n"); 4594 b43err(wl, "Resume failed at core start\n");
4595 goto out; 4595 goto out;
diff --git a/include/linux/device.h b/include/linux/device.h
index 441461f5ee20..dc3429e2eb0f 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -545,20 +545,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
545 dev_t devt, const char *fmt, ...) 545 dev_t devt, const char *fmt, ...)
546 __attribute__((format(printf, 4, 5))); 546 __attribute__((format(printf, 4, 5)));
547extern void device_destroy(struct class *cls, dev_t devt); 547extern void device_destroy(struct class *cls, dev_t devt);
548#ifdef CONFIG_PM_SLEEP
549extern void destroy_suspended_device(struct class *cls, dev_t devt);
550extern void device_pm_schedule_removal(struct device *);
551#else /* !CONFIG_PM_SLEEP */
552static inline void destroy_suspended_device(struct class *cls, dev_t devt)
553{
554 device_destroy(cls, devt);
555}
556
557static inline void device_pm_schedule_removal(struct device *dev)
558{
559 device_unregister(dev);
560}
561#endif /* !CONFIG_PM_SLEEP */
562 548
563/* 549/*
564 * Platform "fixup" functions - allow the platform to have their say 550 * Platform "fixup" functions - allow the platform to have their say
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 42131820bb89..85d11916e9ea 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -44,15 +44,7 @@ struct hwrng {
44/** Register a new Hardware Random Number Generator driver. */ 44/** Register a new Hardware Random Number Generator driver. */
45extern int hwrng_register(struct hwrng *rng); 45extern int hwrng_register(struct hwrng *rng);
46/** Unregister a Hardware Random Number Generator driver. */ 46/** Unregister a Hardware Random Number Generator driver. */
47extern void __hwrng_unregister(struct hwrng *rng, bool suspended); 47extern void hwrng_unregister(struct hwrng *rng);
48static inline void hwrng_unregister(struct hwrng *rng)
49{
50 __hwrng_unregister(rng, false);
51}
52static inline void hwrng_unregister_suspended(struct hwrng *rng)
53{
54 __hwrng_unregister(rng, true);
55}
56 48
57#endif /* __KERNEL__ */ 49#endif /* __KERNEL__ */
58#endif /* LINUX_HWRANDOM_H_ */ 50#endif /* LINUX_HWRANDOM_H_ */
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 0201f6f51cea..b07e3d400bd6 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -59,15 +59,7 @@ struct led_classdev {
59 59
60extern int led_classdev_register(struct device *parent, 60extern int led_classdev_register(struct device *parent,
61 struct led_classdev *led_cdev); 61 struct led_classdev *led_cdev);
62extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus); 62extern void led_classdev_unregister(struct led_classdev *lcd);
63static inline void led_classdev_unregister(struct led_classdev *lcd)
64{
65 __led_classdev_unregister(lcd, false);
66}
67static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
68{
69 __led_classdev_unregister(lcd, true);
70}
71extern void led_classdev_suspend(struct led_classdev *led_cdev); 63extern void led_classdev_suspend(struct led_classdev *led_cdev);
72extern void led_classdev_resume(struct led_classdev *led_cdev); 64extern void led_classdev_resume(struct led_classdev *led_cdev);
73 65
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 24b30b9b4f8a..26433ec520b3 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -43,15 +43,7 @@ struct miscdevice {
43}; 43};
44 44
45extern int misc_register(struct miscdevice * misc); 45extern int misc_register(struct miscdevice * misc);
46extern int __misc_deregister(struct miscdevice *misc, bool suspended); 46extern int misc_deregister(struct miscdevice *misc);
47static inline int misc_deregister(struct miscdevice *misc)
48{
49 return __misc_deregister(misc, false);
50}
51static inline int misc_deregister_suspended(struct miscdevice *misc)
52{
53 return __misc_deregister(misc, true);
54}
55 47
56#define MODULE_ALIAS_MISCDEV(minor) \ 48#define MODULE_ALIAS_MISCDEV(minor) \
57 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \ 49 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \