aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-card.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-card.c')
-rw-r--r--drivers/firewire/fw-card.c50
1 files changed, 5 insertions, 45 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index a03462750b95..5b4c0d9f5173 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -167,7 +167,6 @@ fw_core_add_descriptor(struct fw_descriptor *desc)
167 167
168 return 0; 168 return 0;
169} 169}
170EXPORT_SYMBOL(fw_core_add_descriptor);
171 170
172void 171void
173fw_core_remove_descriptor(struct fw_descriptor *desc) 172fw_core_remove_descriptor(struct fw_descriptor *desc)
@@ -182,7 +181,6 @@ fw_core_remove_descriptor(struct fw_descriptor *desc)
182 181
183 mutex_unlock(&card_mutex); 182 mutex_unlock(&card_mutex);
184} 183}
185EXPORT_SYMBOL(fw_core_remove_descriptor);
186 184
187static const char gap_count_table[] = { 185static const char gap_count_table[] = {
188 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 186 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
@@ -220,7 +218,7 @@ fw_card_bm_work(struct work_struct *work)
220 struct bm_data bmd; 218 struct bm_data bmd;
221 unsigned long flags; 219 unsigned long flags;
222 int root_id, new_root_id, irm_id, gap_count, generation, grace; 220 int root_id, new_root_id, irm_id, gap_count, generation, grace;
223 int do_reset = 0; 221 bool do_reset = false;
224 222
225 spin_lock_irqsave(&card->lock, flags); 223 spin_lock_irqsave(&card->lock, flags);
226 local_node = card->local_node; 224 local_node = card->local_node;
@@ -331,7 +329,7 @@ fw_card_bm_work(struct work_struct *work)
331 */ 329 */
332 spin_unlock_irqrestore(&card->lock, flags); 330 spin_unlock_irqrestore(&card->lock, flags);
333 goto out; 331 goto out;
334 } else if (root_device->config_rom[2] & BIB_CMC) { 332 } else if (root_device->cmc) {
335 /* 333 /*
336 * FIXME: I suppose we should set the cmstr bit in the 334 * FIXME: I suppose we should set the cmstr bit in the
337 * STATE_CLEAR register of this node, as described in 335 * STATE_CLEAR register of this node, as described in
@@ -360,14 +358,14 @@ fw_card_bm_work(struct work_struct *work)
360 gap_count = 63; 358 gap_count = 63;
361 359
362 /* 360 /*
363 * Finally, figure out if we should do a reset or not. If we've 361 * Finally, figure out if we should do a reset or not. If we have
364 * done less that 5 resets with the same physical topology and we 362 * done less than 5 resets with the same physical topology and we
365 * have either a new root or a new gap count setting, let's do it. 363 * have either a new root or a new gap count setting, let's do it.
366 */ 364 */
367 365
368 if (card->bm_retries++ < 5 && 366 if (card->bm_retries++ < 5 &&
369 (card->gap_count != gap_count || new_root_id != root_id)) 367 (card->gap_count != gap_count || new_root_id != root_id))
370 do_reset = 1; 368 do_reset = true;
371 369
372 spin_unlock_irqrestore(&card->lock, flags); 370 spin_unlock_irqrestore(&card->lock, flags);
373 371
@@ -398,7 +396,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
398{ 396{
399 static atomic_t index = ATOMIC_INIT(-1); 397 static atomic_t index = ATOMIC_INIT(-1);
400 398
401 kref_init(&card->kref);
402 atomic_set(&card->device_count, 0); 399 atomic_set(&card->device_count, 0);
403 card->index = atomic_inc_return(&index); 400 card->index = atomic_inc_return(&index);
404 card->driver = driver; 401 card->driver = driver;
@@ -429,12 +426,6 @@ fw_card_add(struct fw_card *card,
429 card->link_speed = link_speed; 426 card->link_speed = link_speed;
430 card->guid = guid; 427 card->guid = guid;
431 428
432 /*
433 * The subsystem grabs a reference when the card is added and
434 * drops it when the driver calls fw_core_remove_card.
435 */
436 fw_card_get(card);
437
438 mutex_lock(&card_mutex); 429 mutex_lock(&card_mutex);
439 config_rom = generate_config_rom(card, &length); 430 config_rom = generate_config_rom(card, &length);
440 list_add_tail(&card->link, &card_list); 431 list_add_tail(&card->link, &card_list);
@@ -540,40 +531,9 @@ fw_core_remove_card(struct fw_card *card)
540 cancel_delayed_work_sync(&card->work); 531 cancel_delayed_work_sync(&card->work);
541 fw_flush_transactions(card); 532 fw_flush_transactions(card);
542 del_timer_sync(&card->flush_timer); 533 del_timer_sync(&card->flush_timer);
543
544 fw_card_put(card);
545} 534}
546EXPORT_SYMBOL(fw_core_remove_card); 535EXPORT_SYMBOL(fw_core_remove_card);
547 536
548struct fw_card *
549fw_card_get(struct fw_card *card)
550{
551 kref_get(&card->kref);
552
553 return card;
554}
555EXPORT_SYMBOL(fw_card_get);
556
557static void
558release_card(struct kref *kref)
559{
560 struct fw_card *card = container_of(kref, struct fw_card, kref);
561
562 kfree(card);
563}
564
565/*
566 * An assumption for fw_card_put() is that the card driver allocates
567 * the fw_card struct with kalloc and that it has been shut down
568 * before the last ref is dropped.
569 */
570void
571fw_card_put(struct fw_card *card)
572{
573 kref_put(&card->kref, release_card);
574}
575EXPORT_SYMBOL(fw_card_put);
576
577int 537int
578fw_core_initiate_bus_reset(struct fw_card *card, int short_reset) 538fw_core_initiate_bus_reset(struct fw_card *card, int short_reset)
579{ 539{