diff options
Diffstat (limited to 'drivers/firewire/fw-device.h')
-rw-r--r-- | drivers/firewire/fw-device.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index 78ecd3991b7f..5f131f5129da 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/cdev.h> | 23 | #include <linux/cdev.h> |
24 | #include <linux/rwsem.h> | ||
24 | #include <asm/atomic.h> | 25 | #include <asm/atomic.h> |
25 | 26 | ||
26 | enum fw_device_state { | 27 | enum fw_device_state { |
@@ -46,6 +47,11 @@ struct fw_attribute_group { | |||
46 | * fw_device.node_id is guaranteed to be current too. | 47 | * fw_device.node_id is guaranteed to be current too. |
47 | * | 48 | * |
48 | * The same applies to fw_device.card->node_id vs. fw_device.generation. | 49 | * The same applies to fw_device.card->node_id vs. fw_device.generation. |
50 | * | ||
51 | * fw_device.config_rom and fw_device.config_rom_length may be accessed during | ||
52 | * the lifetime of any fw_unit belonging to the fw_device, before device_del() | ||
53 | * was called on the last fw_unit. Alternatively, they may be accessed while | ||
54 | * holding fw_device_rwsem. | ||
49 | */ | 55 | */ |
50 | struct fw_device { | 56 | struct fw_device { |
51 | atomic_t state; | 57 | atomic_t state; |
@@ -53,6 +59,7 @@ struct fw_device { | |||
53 | int node_id; | 59 | int node_id; |
54 | int generation; | 60 | int generation; |
55 | unsigned max_speed; | 61 | unsigned max_speed; |
62 | bool cmc; | ||
56 | struct fw_card *card; | 63 | struct fw_card *card; |
57 | struct device device; | 64 | struct device device; |
58 | struct list_head link; | 65 | struct list_head link; |
@@ -64,28 +71,24 @@ struct fw_device { | |||
64 | struct fw_attribute_group attribute_group; | 71 | struct fw_attribute_group attribute_group; |
65 | }; | 72 | }; |
66 | 73 | ||
67 | static inline struct fw_device * | 74 | static inline struct fw_device *fw_device(struct device *dev) |
68 | fw_device(struct device *dev) | ||
69 | { | 75 | { |
70 | return container_of(dev, struct fw_device, device); | 76 | return container_of(dev, struct fw_device, device); |
71 | } | 77 | } |
72 | 78 | ||
73 | static inline int | 79 | static inline int fw_device_is_shutdown(struct fw_device *device) |
74 | fw_device_is_shutdown(struct fw_device *device) | ||
75 | { | 80 | { |
76 | return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; | 81 | return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; |
77 | } | 82 | } |
78 | 83 | ||
79 | static inline struct fw_device * | 84 | static inline struct fw_device *fw_device_get(struct fw_device *device) |
80 | fw_device_get(struct fw_device *device) | ||
81 | { | 85 | { |
82 | get_device(&device->device); | 86 | get_device(&device->device); |
83 | 87 | ||
84 | return device; | 88 | return device; |
85 | } | 89 | } |
86 | 90 | ||
87 | static inline void | 91 | static inline void fw_device_put(struct fw_device *device) |
88 | fw_device_put(struct fw_device *device) | ||
89 | { | 92 | { |
90 | put_device(&device->device); | 93 | put_device(&device->device); |
91 | } | 94 | } |
@@ -96,20 +99,35 @@ int fw_device_enable_phys_dma(struct fw_device *device); | |||
96 | void fw_device_cdev_update(struct fw_device *device); | 99 | void fw_device_cdev_update(struct fw_device *device); |
97 | void fw_device_cdev_remove(struct fw_device *device); | 100 | void fw_device_cdev_remove(struct fw_device *device); |
98 | 101 | ||
102 | extern struct rw_semaphore fw_device_rwsem; | ||
99 | extern int fw_cdev_major; | 103 | extern int fw_cdev_major; |
100 | 104 | ||
105 | /* | ||
106 | * fw_unit.directory must not be accessed after device_del(&fw_unit.device). | ||
107 | */ | ||
101 | struct fw_unit { | 108 | struct fw_unit { |
102 | struct device device; | 109 | struct device device; |
103 | u32 *directory; | 110 | u32 *directory; |
104 | struct fw_attribute_group attribute_group; | 111 | struct fw_attribute_group attribute_group; |
105 | }; | 112 | }; |
106 | 113 | ||
107 | static inline struct fw_unit * | 114 | static inline struct fw_unit *fw_unit(struct device *dev) |
108 | fw_unit(struct device *dev) | ||
109 | { | 115 | { |
110 | return container_of(dev, struct fw_unit, device); | 116 | return container_of(dev, struct fw_unit, device); |
111 | } | 117 | } |
112 | 118 | ||
119 | static inline struct fw_unit *fw_unit_get(struct fw_unit *unit) | ||
120 | { | ||
121 | get_device(&unit->device); | ||
122 | |||
123 | return unit; | ||
124 | } | ||
125 | |||
126 | static inline void fw_unit_put(struct fw_unit *unit) | ||
127 | { | ||
128 | put_device(&unit->device); | ||
129 | } | ||
130 | |||
113 | #define CSR_OFFSET 0x40 | 131 | #define CSR_OFFSET 0x40 |
114 | #define CSR_LEAF 0x80 | 132 | #define CSR_LEAF 0x80 |
115 | #define CSR_DIRECTORY 0xc0 | 133 | #define CSR_DIRECTORY 0xc0 |