firewire: Drop the unused fw_card device.
authorKristian Høgsberg <krh@redhat.com>
Wed, 7 Mar 2007 17:12:37 +0000 (12:12 -0500)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Fri, 9 Mar 2007 21:03:06 +0000 (22:03 +0100)
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
drivers/firewire/fw-card.c
drivers/firewire/fw-transaction.h

index 8d7c12164bb34fb7c3168a82101409fb190f20e5..b1deb5214bd4c95a90734f539e2a20df73ac4e4e 100644 (file)
@@ -351,15 +351,6 @@ fw_card_bm_work(struct work_struct *work)
        }
 }
 
-static void
-release_card(struct device *device)
-{
-       struct fw_card *card =
-               container_of(device, struct fw_card, card_device);
-
-       kfree(card);
-}
-
 static void
 flush_timer_callback(unsigned long data)
 {
@@ -374,6 +365,7 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
 {
        static atomic_t index = ATOMIC_INIT(-1);
 
+       kref_init(&card->kref);
        card->index = atomic_inc_return(&index);
        card->driver = driver;
        card->device = device;
@@ -389,14 +381,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
        card->local_node = NULL;
 
        INIT_DELAYED_WORK(&card->work, fw_card_bm_work);
-
-       card->card_device.bus     = &fw_bus_type;
-       card->card_device.release = release_card;
-       card->card_device.parent  = card->device;
-       snprintf(card->card_device.bus_id, sizeof card->card_device.bus_id,
-                "fwcard%d", card->index);
-
-       device_initialize(&card->card_device);
 }
 EXPORT_SYMBOL(fw_card_initialize);
 
@@ -404,7 +388,6 @@ int
 fw_card_add(struct fw_card *card,
            u32 max_receive, u32 link_speed, u64 guid)
 {
-       int retval;
        u32 *config_rom;
        size_t length;
 
@@ -417,12 +400,6 @@ fw_card_add(struct fw_card *card,
        if (card->driver->update_phy_reg(card, 4, 0, 0x80 | 0x40) < 0)
                return -EIO;
 
-       retval = device_add(&card->card_device);
-       if (retval < 0) {
-               fw_error("Failed to register card device.");
-               return retval;
-       }
-
        /* The subsystem grabs a reference when the card is added and
         * drops it when the driver calls fw_core_remove_card. */
        fw_card_get(card);
@@ -520,27 +497,34 @@ fw_core_remove_card(struct fw_card *card)
 
        fw_destroy_nodes(card);
 
-       /* This also drops the subsystem reference. */
-       device_unregister(&card->card_device);
+       fw_card_put(card);
 }
 EXPORT_SYMBOL(fw_core_remove_card);
 
 struct fw_card *
 fw_card_get(struct fw_card *card)
 {
-       get_device(&card->card_device);
+       kref_get(&card->kref);
 
        return card;
 }
 EXPORT_SYMBOL(fw_card_get);
 
+static void
+release_card(struct kref *kref)
+{
+       struct fw_card *card = container_of(kref, struct fw_card, kref);
+
+       kfree(card);
+}
+
 /* An assumption for fw_card_put() is that the card driver allocates
  * the fw_card struct with kalloc and that it has been shut down
  * before the last ref is dropped. */
 void
 fw_card_put(struct fw_card *card)
 {
-       put_device(&card->card_device);
+       kref_put(&card->kref, release_card);
 }
 EXPORT_SYMBOL(fw_card_put);
 
index 552e9af081e91f83391341fefdfbbef137d79c17..b0d057533fb0e69b77c40bf46a25e87647bf28db 100644 (file)
@@ -270,6 +270,7 @@ extern struct bus_type fw_bus_type;
 struct fw_card {
        const struct fw_card_driver *driver;
        struct device *device;
+       struct kref kref;
 
        int node_id;
        int generation;
@@ -300,8 +301,6 @@ struct fw_card {
 
        int index;
 
-       struct device card_device;
-
        struct list_head link;
 
        /* Work struct for BM duties. */