aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-card.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-03-07 12:12:37 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-03-09 16:03:06 -0500
commit49e1179b16fe54bfa070cd955a24c5ce82e21d16 (patch)
treec16d10fd3e95f43b49a8a016a4d64198f275fa50 /drivers/firewire/fw-card.c
parent937f687969f77bfeee5efd71cadfa6f1a813665e (diff)
firewire: Drop the unused fw_card device.
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/fw-card.c')
-rw-r--r--drivers/firewire/fw-card.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 8d7c12164bb3..b1deb5214bd4 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -352,15 +352,6 @@ fw_card_bm_work(struct work_struct *work)
352} 352}
353 353
354static void 354static void
355release_card(struct device *device)
356{
357 struct fw_card *card =
358 container_of(device, struct fw_card, card_device);
359
360 kfree(card);
361}
362
363static void
364flush_timer_callback(unsigned long data) 355flush_timer_callback(unsigned long data)
365{ 356{
366 struct fw_card *card = (struct fw_card *)data; 357 struct fw_card *card = (struct fw_card *)data;
@@ -374,6 +365,7 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
374{ 365{
375 static atomic_t index = ATOMIC_INIT(-1); 366 static atomic_t index = ATOMIC_INIT(-1);
376 367
368 kref_init(&card->kref);
377 card->index = atomic_inc_return(&index); 369 card->index = atomic_inc_return(&index);
378 card->driver = driver; 370 card->driver = driver;
379 card->device = device; 371 card->device = device;
@@ -389,14 +381,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
389 card->local_node = NULL; 381 card->local_node = NULL;
390 382
391 INIT_DELAYED_WORK(&card->work, fw_card_bm_work); 383 INIT_DELAYED_WORK(&card->work, fw_card_bm_work);
392
393 card->card_device.bus = &fw_bus_type;
394 card->card_device.release = release_card;
395 card->card_device.parent = card->device;
396 snprintf(card->card_device.bus_id, sizeof card->card_device.bus_id,
397 "fwcard%d", card->index);
398
399 device_initialize(&card->card_device);
400} 384}
401EXPORT_SYMBOL(fw_card_initialize); 385EXPORT_SYMBOL(fw_card_initialize);
402 386
@@ -404,7 +388,6 @@ int
404fw_card_add(struct fw_card *card, 388fw_card_add(struct fw_card *card,
405 u32 max_receive, u32 link_speed, u64 guid) 389 u32 max_receive, u32 link_speed, u64 guid)
406{ 390{
407 int retval;
408 u32 *config_rom; 391 u32 *config_rom;
409 size_t length; 392 size_t length;
410 393
@@ -417,12 +400,6 @@ fw_card_add(struct fw_card *card,
417 if (card->driver->update_phy_reg(card, 4, 0, 0x80 | 0x40) < 0) 400 if (card->driver->update_phy_reg(card, 4, 0, 0x80 | 0x40) < 0)
418 return -EIO; 401 return -EIO;
419 402
420 retval = device_add(&card->card_device);
421 if (retval < 0) {
422 fw_error("Failed to register card device.");
423 return retval;
424 }
425
426 /* The subsystem grabs a reference when the card is added and 403 /* The subsystem grabs a reference when the card is added and
427 * drops it when the driver calls fw_core_remove_card. */ 404 * drops it when the driver calls fw_core_remove_card. */
428 fw_card_get(card); 405 fw_card_get(card);
@@ -520,27 +497,34 @@ fw_core_remove_card(struct fw_card *card)
520 497
521 fw_destroy_nodes(card); 498 fw_destroy_nodes(card);
522 499
523 /* This also drops the subsystem reference. */ 500 fw_card_put(card);
524 device_unregister(&card->card_device);
525} 501}
526EXPORT_SYMBOL(fw_core_remove_card); 502EXPORT_SYMBOL(fw_core_remove_card);
527 503
528struct fw_card * 504struct fw_card *
529fw_card_get(struct fw_card *card) 505fw_card_get(struct fw_card *card)
530{ 506{
531 get_device(&card->card_device); 507 kref_get(&card->kref);
532 508
533 return card; 509 return card;
534} 510}
535EXPORT_SYMBOL(fw_card_get); 511EXPORT_SYMBOL(fw_card_get);
536 512
513static void
514release_card(struct kref *kref)
515{
516 struct fw_card *card = container_of(kref, struct fw_card, kref);
517
518 kfree(card);
519}
520
537/* An assumption for fw_card_put() is that the card driver allocates 521/* An assumption for fw_card_put() is that the card driver allocates
538 * the fw_card struct with kalloc and that it has been shut down 522 * the fw_card struct with kalloc and that it has been shut down
539 * before the last ref is dropped. */ 523 * before the last ref is dropped. */
540void 524void
541fw_card_put(struct fw_card *card) 525fw_card_put(struct fw_card *card)
542{ 526{
543 put_device(&card->card_device); 527 kref_put(&card->kref, release_card);
544} 528}
545EXPORT_SYMBOL(fw_card_put); 529EXPORT_SYMBOL(fw_card_put);
546 530