diff options
Diffstat (limited to 'drivers/firewire/fw-card.c')
-rw-r--r-- | drivers/firewire/fw-card.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index 5b4c0d9f5173..da873d795aad 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c | |||
@@ -16,12 +16,15 @@ | |||
16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/errno.h> | 20 | #include <linux/crc-itu-t.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/errno.h> | ||
24 | #include <linux/kref.h> | ||
25 | #include <linux/module.h> | ||
23 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
24 | #include <linux/crc-itu-t.h> | 27 | |
25 | #include "fw-transaction.h" | 28 | #include "fw-transaction.h" |
26 | #include "fw-topology.h" | 29 | #include "fw-topology.h" |
27 | #include "fw-device.h" | 30 | #include "fw-device.h" |
@@ -396,14 +399,16 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, | |||
396 | { | 399 | { |
397 | static atomic_t index = ATOMIC_INIT(-1); | 400 | static atomic_t index = ATOMIC_INIT(-1); |
398 | 401 | ||
399 | atomic_set(&card->device_count, 0); | ||
400 | card->index = atomic_inc_return(&index); | 402 | card->index = atomic_inc_return(&index); |
401 | card->driver = driver; | 403 | card->driver = driver; |
402 | card->device = device; | 404 | card->device = device; |
403 | card->current_tlabel = 0; | 405 | card->current_tlabel = 0; |
404 | card->tlabel_mask = 0; | 406 | card->tlabel_mask = 0; |
405 | card->color = 0; | 407 | card->color = 0; |
408 | card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; | ||
406 | 409 | ||
410 | kref_init(&card->kref); | ||
411 | init_completion(&card->done); | ||
407 | INIT_LIST_HEAD(&card->transaction_list); | 412 | INIT_LIST_HEAD(&card->transaction_list); |
408 | spin_lock_init(&card->lock); | 413 | spin_lock_init(&card->lock); |
409 | setup_timer(&card->flush_timer, | 414 | setup_timer(&card->flush_timer, |
@@ -496,7 +501,6 @@ dummy_enable_phys_dma(struct fw_card *card, | |||
496 | } | 501 | } |
497 | 502 | ||
498 | static struct fw_card_driver dummy_driver = { | 503 | static struct fw_card_driver dummy_driver = { |
499 | .name = "dummy", | ||
500 | .enable = dummy_enable, | 504 | .enable = dummy_enable, |
501 | .update_phy_reg = dummy_update_phy_reg, | 505 | .update_phy_reg = dummy_update_phy_reg, |
502 | .set_config_rom = dummy_set_config_rom, | 506 | .set_config_rom = dummy_set_config_rom, |
@@ -507,6 +511,14 @@ static struct fw_card_driver dummy_driver = { | |||
507 | }; | 511 | }; |
508 | 512 | ||
509 | void | 513 | void |
514 | fw_card_release(struct kref *kref) | ||
515 | { | ||
516 | struct fw_card *card = container_of(kref, struct fw_card, kref); | ||
517 | |||
518 | complete(&card->done); | ||
519 | } | ||
520 | |||
521 | void | ||
510 | fw_core_remove_card(struct fw_card *card) | 522 | fw_core_remove_card(struct fw_card *card) |
511 | { | 523 | { |
512 | card->driver->update_phy_reg(card, 4, | 524 | card->driver->update_phy_reg(card, 4, |
@@ -521,12 +533,10 @@ fw_core_remove_card(struct fw_card *card) | |||
521 | card->driver = &dummy_driver; | 533 | card->driver = &dummy_driver; |
522 | 534 | ||
523 | fw_destroy_nodes(card); | 535 | fw_destroy_nodes(card); |
524 | /* | 536 | |
525 | * Wait for all device workqueue jobs to finish. Otherwise the | 537 | /* Wait for all users, especially device workqueue jobs, to finish. */ |
526 | * firewire-core module could be unloaded before the jobs ran. | 538 | fw_card_put(card); |
527 | */ | 539 | wait_for_completion(&card->done); |
528 | while (atomic_read(&card->device_count) > 0) | ||
529 | msleep(100); | ||
530 | 540 | ||
531 | cancel_delayed_work_sync(&card->work); | 541 | cancel_delayed_work_sync(&card->work); |
532 | fw_flush_transactions(card); | 542 | fw_flush_transactions(card); |