aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-transaction.h
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-05-24 10:50:22 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-07-14 07:06:03 -0400
commit459f79235d8faa0050180c7e0c7bb4b2b52cbdfd (patch)
tree97847b1b06ded6c136cdba73bc961a46a3e39a30 /drivers/firewire/fw-transaction.h
parent2147ef204f57191e0fff6d5d3d1a0336afa6cfae (diff)
firewire: clean up fw_card reference counting
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 <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/fw-transaction.h')
-rw-r--r--drivers/firewire/fw-transaction.h20
1 files changed, 18 insertions, 2 deletions
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 @@
19#ifndef __fw_transaction_h 19#ifndef __fw_transaction_h
20#define __fw_transaction_h 20#define __fw_transaction_h
21 21
22#include <linux/completion.h>
22#include <linux/device.h> 23#include <linux/device.h>
23#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
24#include <linux/firewire-constants.h> 25#include <linux/firewire-constants.h>
26#include <linux/kref.h>
25#include <linux/list.h> 27#include <linux/list.h>
26#include <linux/spinlock_types.h> 28#include <linux/spinlock_types.h>
27#include <linux/timer.h> 29#include <linux/timer.h>
28#include <linux/workqueue.h> 30#include <linux/workqueue.h>
29#include <asm/atomic.h>
30 31
31#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) 32#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
32#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) 33#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0)
@@ -219,7 +220,8 @@ extern struct bus_type fw_bus_type;
219struct fw_card { 220struct fw_card {
220 const struct fw_card_driver *driver; 221 const struct fw_card_driver *driver;
221 struct device *device; 222 struct device *device;
222 atomic_t device_count; 223 struct kref kref;
224 struct completion done;
223 225
224 int node_id; 226 int node_id;
225 int generation; 227 int generation;
@@ -260,6 +262,20 @@ struct fw_card {
260 int bm_generation; 262 int bm_generation;
261}; 263};
262 264
265static inline struct fw_card *fw_card_get(struct fw_card *card)
266{
267 kref_get(&card->kref);
268
269 return card;
270}
271
272void fw_card_release(struct kref *kref);
273
274static inline void fw_card_put(struct fw_card *card)
275{
276 kref_put(&card->kref, fw_card_release);
277}
278
263/* 279/*
264 * The iso packet format allows for an immediate header/payload part 280 * The iso packet format allows for an immediate header/payload part
265 * stored in 'header' immediately after the packet info plus an 281 * stored in 'header' immediately after the packet info plus an