summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firewire/fw-card.c40
-rw-r--r--drivers/firewire/fw-transaction.h3
2 files changed, 13 insertions, 30 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)
}
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)
{
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,
{
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);
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 552e9af081e9..b0d057533fb0 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -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. */
OpenPOWER on IntegriCloud