diff options
Diffstat (limited to 'drivers/base/dd.c')
| -rw-r--r-- | drivers/base/dd.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index db01b95a47a5..c5d6bb4290ad 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/device.h> | 18 | #include <linux/device.h> |
| 19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 20 | #include <linux/kthread.h> | 20 | #include <linux/kthread.h> |
| 21 | #include <linux/wait.h> | ||
| 21 | 22 | ||
| 22 | #include "base.h" | 23 | #include "base.h" |
| 23 | #include "power/power.h" | 24 | #include "power/power.h" |
| @@ -70,6 +71,8 @@ struct stupid_thread_structure { | |||
| 70 | }; | 71 | }; |
| 71 | 72 | ||
| 72 | static atomic_t probe_count = ATOMIC_INIT(0); | 73 | static atomic_t probe_count = ATOMIC_INIT(0); |
| 74 | static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); | ||
| 75 | |||
| 73 | static int really_probe(void *void_data) | 76 | static int really_probe(void *void_data) |
| 74 | { | 77 | { |
| 75 | struct stupid_thread_structure *data = void_data; | 78 | struct stupid_thread_structure *data = void_data; |
| @@ -121,6 +124,7 @@ probe_failed: | |||
| 121 | done: | 124 | done: |
| 122 | kfree(data); | 125 | kfree(data); |
| 123 | atomic_dec(&probe_count); | 126 | atomic_dec(&probe_count); |
| 127 | wake_up(&probe_waitqueue); | ||
| 124 | return ret; | 128 | return ret; |
| 125 | } | 129 | } |
| 126 | 130 | ||
| @@ -337,6 +341,32 @@ void driver_detach(struct device_driver * drv) | |||
| 337 | } | 341 | } |
| 338 | } | 342 | } |
| 339 | 343 | ||
| 344 | #ifdef CONFIG_PCI_MULTITHREAD_PROBE | ||
| 345 | static int __init wait_for_probes(void) | ||
| 346 | { | ||
| 347 | DEFINE_WAIT(wait); | ||
| 348 | |||
| 349 | printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__, | ||
| 350 | atomic_read(&probe_count)); | ||
| 351 | if (!atomic_read(&probe_count)) | ||
| 352 | return 0; | ||
| 353 | while (atomic_read(&probe_count)) { | ||
| 354 | prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE); | ||
| 355 | if (atomic_read(&probe_count)) | ||
| 356 | schedule(); | ||
| 357 | } | ||
| 358 | finish_wait(&probe_waitqueue, &wait); | ||
| 359 | return 0; | ||
| 360 | } | ||
| 361 | |||
| 362 | core_initcall_sync(wait_for_probes); | ||
| 363 | postcore_initcall_sync(wait_for_probes); | ||
| 364 | arch_initcall_sync(wait_for_probes); | ||
| 365 | subsys_initcall_sync(wait_for_probes); | ||
| 366 | fs_initcall_sync(wait_for_probes); | ||
| 367 | device_initcall_sync(wait_for_probes); | ||
| 368 | late_initcall_sync(wait_for_probes); | ||
| 369 | #endif | ||
| 340 | 370 | ||
| 341 | EXPORT_SYMBOL_GPL(device_bind_driver); | 371 | EXPORT_SYMBOL_GPL(device_bind_driver); |
| 342 | EXPORT_SYMBOL_GPL(device_release_driver); | 372 | EXPORT_SYMBOL_GPL(device_release_driver); |
