From e534fe16b987780744da351acece2a4699783096 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 24 May 2008 16:41:09 +0200 Subject: firewire: implement broadcast_channel CSR for 1394a compliance See IEEE 1394a clause 8.3.2.3.11. Signed-off-by: Stefan Richter --- drivers/firewire/fw-transaction.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/firewire/fw-transaction.h') diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 04d3854f6560..f3a493d596cc 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h @@ -80,6 +80,9 @@ #define CSR_SPEED_MAP 0x2000 #define CSR_SPEED_MAP_END 0x3000 +#define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31) +#define BROADCAST_CHANNEL_VALID (1 << 30) + #define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) #define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) @@ -236,6 +239,7 @@ struct fw_card { */ int self_id_count; u32 topology_map[252 + 3]; + u32 broadcast_channel; spinlock_t lock; /* Take this lock when handling the lists in * this struct. */ -- cgit v1.2.3 From bbf094cf3dbd9a969dd17cf52325e9fab8dfbe91 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 24 May 2008 16:46:10 +0200 Subject: firewire: remove unused struct members Signed-off-by: Stefan Richter --- drivers/firewire/fw-card.c | 1 - drivers/firewire/fw-device.h | 1 - drivers/firewire/fw-ohci.c | 1 - drivers/firewire/fw-transaction.h | 2 -- 4 files changed, 5 deletions(-) (limited to 'drivers/firewire/fw-transaction.h') diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index 96340ce690d4..1332b66ae0b3 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c @@ -497,7 +497,6 @@ dummy_enable_phys_dma(struct fw_card *card, } static struct fw_card_driver dummy_driver = { - .name = "dummy", .enable = dummy_enable, .update_phy_reg = dummy_update_phy_reg, .set_config_rom = dummy_set_config_rom, diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index 5f131f5129da..42305bbac72f 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h @@ -62,7 +62,6 @@ struct fw_device { bool cmc; struct fw_card *card; struct device device; - struct list_head link; struct list_head client_list; u32 *config_rom; size_t config_rom_length; diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index 0b66306af479..333b12544dd1 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c @@ -2292,7 +2292,6 @@ ohci_queue_iso(struct fw_iso_context *base, } static const struct fw_card_driver ohci_driver = { - .name = ohci_driver_name, .enable = ohci_enable, .update_phy_reg = ohci_update_phy_reg, .set_config_rom = ohci_set_config_rom, diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index f3a493d596cc..7e928e86022f 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h @@ -352,8 +352,6 @@ int fw_iso_context_stop(struct fw_iso_context *ctx); struct fw_card_driver { - const char *name; - /* * Enable the given card with the given initial config rom. * This function is expected to activate the card, and either -- cgit v1.2.3 From 2147ef204f57191e0fff6d5d3d1a0336afa6cfae Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 24 May 2008 16:48:05 +0200 Subject: firewire: clean up some includes Signed-off-by: Stefan Richter --- drivers/firewire/fw-transaction.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/firewire/fw-transaction.h') diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 7e928e86022f..219094e38542 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h @@ -20,12 +20,12 @@ #define __fw_transaction_h #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) -- cgit v1.2.3 From 459f79235d8faa0050180c7e0c7bb4b2b52cbdfd Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 24 May 2008 16:50:22 +0200 Subject: firewire: clean up fw_card reference counting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a functionally equivalent replacement of the current reference counting of struct fw_card instances. It only converts it to common idioms as suggested by Kristian Høgsberg: - struct kref replaces atomic_t as the counter. - wait_for_completion is used to wait for all card users to complete. BTW, it may make sense to count card->flush_timer and card->work as card users too. Signed-off-by: Stefan Richter --- drivers/firewire/fw-card.c | 30 ++++++++++++++++++++---------- drivers/firewire/fw-device.c | 5 ++--- drivers/firewire/fw-transaction.h | 20 ++++++++++++++++++-- 3 files changed, 40 insertions(+), 15 deletions(-) (limited to 'drivers/firewire/fw-transaction.h') diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index 1332b66ae0b3..da873d795aad 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c @@ -16,12 +16,15 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include +#include +#include #include #include +#include +#include +#include #include -#include + #include "fw-transaction.h" #include "fw-topology.h" #include "fw-device.h" @@ -396,7 +399,6 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, { static atomic_t index = ATOMIC_INIT(-1); - atomic_set(&card->device_count, 0); card->index = atomic_inc_return(&index); card->driver = driver; card->device = device; @@ -405,6 +407,8 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, card->color = 0; card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; + kref_init(&card->kref); + init_completion(&card->done); INIT_LIST_HEAD(&card->transaction_list); spin_lock_init(&card->lock); setup_timer(&card->flush_timer, @@ -506,6 +510,14 @@ static struct fw_card_driver dummy_driver = { .enable_phys_dma = dummy_enable_phys_dma, }; +void +fw_card_release(struct kref *kref) +{ + struct fw_card *card = container_of(kref, struct fw_card, kref); + + complete(&card->done); +} + void fw_core_remove_card(struct fw_card *card) { @@ -521,12 +533,10 @@ fw_core_remove_card(struct fw_card *card) card->driver = &dummy_driver; fw_destroy_nodes(card); - /* - * Wait for all device workqueue jobs to finish. Otherwise the - * firewire-core module could be unloaded before the jobs ran. - */ - while (atomic_read(&card->device_count) > 0) - msleep(100); + + /* Wait for all users, especially device workqueue jobs, to finish. */ + fw_card_put(card); + wait_for_completion(&card->done); cancel_delayed_work_sync(&card->work); fw_flush_transactions(card); diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index d9c8daf7ae7d..0855fb5568e8 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c @@ -168,7 +168,7 @@ static void fw_device_release(struct device *dev) fw_node_put(device->node); kfree(device->config_rom); kfree(device); - atomic_dec(&card->device_count); + fw_card_put(card); } int fw_device_enable_phys_dma(struct fw_device *device) @@ -946,8 +946,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) */ device_initialize(&device->device); atomic_set(&device->state, FW_DEVICE_INITIALIZING); - atomic_inc(&card->device_count); - device->card = card; + device->card = fw_card_get(card); device->node = fw_node_get(node); device->node_id = node->node_id; device->generation = card->generation; diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 219094e38542..2ae1b0d6cb7b 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h @@ -19,14 +19,15 @@ #ifndef __fw_transaction_h #define __fw_transaction_h +#include #include #include #include +#include #include #include #include #include -#include #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) #define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) @@ -219,7 +220,8 @@ extern struct bus_type fw_bus_type; struct fw_card { const struct fw_card_driver *driver; struct device *device; - atomic_t device_count; + struct kref kref; + struct completion done; int node_id; int generation; @@ -260,6 +262,20 @@ struct fw_card { int bm_generation; }; +static inline struct fw_card *fw_card_get(struct fw_card *card) +{ + kref_get(&card->kref); + + return card; +} + +void fw_card_release(struct kref *kref); + +static inline void fw_card_put(struct fw_card *card) +{ + kref_put(&card->kref, fw_card_release); +} + /* * The iso packet format allows for an immediate header/payload part * stored in 'header' immediately after the packet info plus an -- cgit v1.2.3