Commit a38a00fdef98a8eda23a25e54490b32865bc7c33
1 parent
18e9b10fcd
Exists in
master
and in
7 other branches
firewire: core: drop unused call parameters of close_transaction
All callers inserted NULL and 0 here. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Showing 1 changed file with 8 additions and 9 deletions Inline Diff
drivers/firewire/fw-transaction.c
1 | /* | 1 | /* |
2 | * Core IEEE1394 transaction logic | 2 | * Core IEEE1394 transaction logic |
3 | * | 3 | * |
4 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> | 4 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software Foundation, | 17 | * along with this program; if not, write to the Free Software Foundation, |
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/completion.h> | 21 | #include <linux/completion.h> |
22 | #include <linux/idr.h> | 22 | #include <linux/idr.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/kref.h> | 24 | #include <linux/kref.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/poll.h> | 31 | #include <linux/poll.h> |
32 | #include <linux/list.h> | 32 | #include <linux/list.h> |
33 | #include <linux/kthread.h> | 33 | #include <linux/kthread.h> |
34 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
35 | 35 | ||
36 | #include "fw-transaction.h" | 36 | #include "fw-transaction.h" |
37 | #include "fw-topology.h" | 37 | #include "fw-topology.h" |
38 | #include "fw-device.h" | 38 | #include "fw-device.h" |
39 | 39 | ||
40 | #define HEADER_PRI(pri) ((pri) << 0) | 40 | #define HEADER_PRI(pri) ((pri) << 0) |
41 | #define HEADER_TCODE(tcode) ((tcode) << 4) | 41 | #define HEADER_TCODE(tcode) ((tcode) << 4) |
42 | #define HEADER_RETRY(retry) ((retry) << 8) | 42 | #define HEADER_RETRY(retry) ((retry) << 8) |
43 | #define HEADER_TLABEL(tlabel) ((tlabel) << 10) | 43 | #define HEADER_TLABEL(tlabel) ((tlabel) << 10) |
44 | #define HEADER_DESTINATION(destination) ((destination) << 16) | 44 | #define HEADER_DESTINATION(destination) ((destination) << 16) |
45 | #define HEADER_SOURCE(source) ((source) << 16) | 45 | #define HEADER_SOURCE(source) ((source) << 16) |
46 | #define HEADER_RCODE(rcode) ((rcode) << 12) | 46 | #define HEADER_RCODE(rcode) ((rcode) << 12) |
47 | #define HEADER_OFFSET_HIGH(offset_high) ((offset_high) << 0) | 47 | #define HEADER_OFFSET_HIGH(offset_high) ((offset_high) << 0) |
48 | #define HEADER_DATA_LENGTH(length) ((length) << 16) | 48 | #define HEADER_DATA_LENGTH(length) ((length) << 16) |
49 | #define HEADER_EXTENDED_TCODE(tcode) ((tcode) << 0) | 49 | #define HEADER_EXTENDED_TCODE(tcode) ((tcode) << 0) |
50 | 50 | ||
51 | #define HEADER_GET_TCODE(q) (((q) >> 4) & 0x0f) | 51 | #define HEADER_GET_TCODE(q) (((q) >> 4) & 0x0f) |
52 | #define HEADER_GET_TLABEL(q) (((q) >> 10) & 0x3f) | 52 | #define HEADER_GET_TLABEL(q) (((q) >> 10) & 0x3f) |
53 | #define HEADER_GET_RCODE(q) (((q) >> 12) & 0x0f) | 53 | #define HEADER_GET_RCODE(q) (((q) >> 12) & 0x0f) |
54 | #define HEADER_GET_DESTINATION(q) (((q) >> 16) & 0xffff) | 54 | #define HEADER_GET_DESTINATION(q) (((q) >> 16) & 0xffff) |
55 | #define HEADER_GET_SOURCE(q) (((q) >> 16) & 0xffff) | 55 | #define HEADER_GET_SOURCE(q) (((q) >> 16) & 0xffff) |
56 | #define HEADER_GET_OFFSET_HIGH(q) (((q) >> 0) & 0xffff) | 56 | #define HEADER_GET_OFFSET_HIGH(q) (((q) >> 0) & 0xffff) |
57 | #define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff) | 57 | #define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff) |
58 | #define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff) | 58 | #define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff) |
59 | 59 | ||
60 | #define HEADER_DESTINATION_IS_BROADCAST(q) \ | 60 | #define HEADER_DESTINATION_IS_BROADCAST(q) \ |
61 | (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f)) | 61 | (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f)) |
62 | 62 | ||
63 | #define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22)) | 63 | #define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22)) |
64 | #define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23)) | 64 | #define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23)) |
65 | #define PHY_IDENTIFIER(id) ((id) << 30) | 65 | #define PHY_IDENTIFIER(id) ((id) << 30) |
66 | 66 | ||
67 | static int close_transaction(struct fw_transaction *transaction, | 67 | static int close_transaction(struct fw_transaction *transaction, |
68 | struct fw_card *card, int rcode, | 68 | struct fw_card *card, int rcode) |
69 | u32 *payload, size_t length) | ||
70 | { | 69 | { |
71 | struct fw_transaction *t; | 70 | struct fw_transaction *t; |
72 | unsigned long flags; | 71 | unsigned long flags; |
73 | 72 | ||
74 | spin_lock_irqsave(&card->lock, flags); | 73 | spin_lock_irqsave(&card->lock, flags); |
75 | list_for_each_entry(t, &card->transaction_list, link) { | 74 | list_for_each_entry(t, &card->transaction_list, link) { |
76 | if (t == transaction) { | 75 | if (t == transaction) { |
77 | list_del(&t->link); | 76 | list_del(&t->link); |
78 | card->tlabel_mask &= ~(1 << t->tlabel); | 77 | card->tlabel_mask &= ~(1 << t->tlabel); |
79 | break; | 78 | break; |
80 | } | 79 | } |
81 | } | 80 | } |
82 | spin_unlock_irqrestore(&card->lock, flags); | 81 | spin_unlock_irqrestore(&card->lock, flags); |
83 | 82 | ||
84 | if (&t->link != &card->transaction_list) { | 83 | if (&t->link != &card->transaction_list) { |
85 | t->callback(card, rcode, payload, length, t->callback_data); | 84 | t->callback(card, rcode, NULL, 0, t->callback_data); |
86 | return 0; | 85 | return 0; |
87 | } | 86 | } |
88 | 87 | ||
89 | return -ENOENT; | 88 | return -ENOENT; |
90 | } | 89 | } |
91 | 90 | ||
92 | /* | 91 | /* |
93 | * Only valid for transactions that are potentially pending (ie have | 92 | * Only valid for transactions that are potentially pending (ie have |
94 | * been sent). | 93 | * been sent). |
95 | */ | 94 | */ |
96 | int fw_cancel_transaction(struct fw_card *card, | 95 | int fw_cancel_transaction(struct fw_card *card, |
97 | struct fw_transaction *transaction) | 96 | struct fw_transaction *transaction) |
98 | { | 97 | { |
99 | /* | 98 | /* |
100 | * Cancel the packet transmission if it's still queued. That | 99 | * Cancel the packet transmission if it's still queued. That |
101 | * will call the packet transmission callback which cancels | 100 | * will call the packet transmission callback which cancels |
102 | * the transaction. | 101 | * the transaction. |
103 | */ | 102 | */ |
104 | 103 | ||
105 | if (card->driver->cancel_packet(card, &transaction->packet) == 0) | 104 | if (card->driver->cancel_packet(card, &transaction->packet) == 0) |
106 | return 0; | 105 | return 0; |
107 | 106 | ||
108 | /* | 107 | /* |
109 | * If the request packet has already been sent, we need to see | 108 | * If the request packet has already been sent, we need to see |
110 | * if the transaction is still pending and remove it in that case. | 109 | * if the transaction is still pending and remove it in that case. |
111 | */ | 110 | */ |
112 | 111 | ||
113 | return close_transaction(transaction, card, RCODE_CANCELLED, NULL, 0); | 112 | return close_transaction(transaction, card, RCODE_CANCELLED); |
114 | } | 113 | } |
115 | EXPORT_SYMBOL(fw_cancel_transaction); | 114 | EXPORT_SYMBOL(fw_cancel_transaction); |
116 | 115 | ||
117 | static void transmit_complete_callback(struct fw_packet *packet, | 116 | static void transmit_complete_callback(struct fw_packet *packet, |
118 | struct fw_card *card, int status) | 117 | struct fw_card *card, int status) |
119 | { | 118 | { |
120 | struct fw_transaction *t = | 119 | struct fw_transaction *t = |
121 | container_of(packet, struct fw_transaction, packet); | 120 | container_of(packet, struct fw_transaction, packet); |
122 | 121 | ||
123 | switch (status) { | 122 | switch (status) { |
124 | case ACK_COMPLETE: | 123 | case ACK_COMPLETE: |
125 | close_transaction(t, card, RCODE_COMPLETE, NULL, 0); | 124 | close_transaction(t, card, RCODE_COMPLETE); |
126 | break; | 125 | break; |
127 | case ACK_PENDING: | 126 | case ACK_PENDING: |
128 | t->timestamp = packet->timestamp; | 127 | t->timestamp = packet->timestamp; |
129 | break; | 128 | break; |
130 | case ACK_BUSY_X: | 129 | case ACK_BUSY_X: |
131 | case ACK_BUSY_A: | 130 | case ACK_BUSY_A: |
132 | case ACK_BUSY_B: | 131 | case ACK_BUSY_B: |
133 | close_transaction(t, card, RCODE_BUSY, NULL, 0); | 132 | close_transaction(t, card, RCODE_BUSY); |
134 | break; | 133 | break; |
135 | case ACK_DATA_ERROR: | 134 | case ACK_DATA_ERROR: |
136 | close_transaction(t, card, RCODE_DATA_ERROR, NULL, 0); | 135 | close_transaction(t, card, RCODE_DATA_ERROR); |
137 | break; | 136 | break; |
138 | case ACK_TYPE_ERROR: | 137 | case ACK_TYPE_ERROR: |
139 | close_transaction(t, card, RCODE_TYPE_ERROR, NULL, 0); | 138 | close_transaction(t, card, RCODE_TYPE_ERROR); |
140 | break; | 139 | break; |
141 | default: | 140 | default: |
142 | /* | 141 | /* |
143 | * In this case the ack is really a juju specific | 142 | * In this case the ack is really a juju specific |
144 | * rcode, so just forward that to the callback. | 143 | * rcode, so just forward that to the callback. |
145 | */ | 144 | */ |
146 | close_transaction(t, card, status, NULL, 0); | 145 | close_transaction(t, card, status); |
147 | break; | 146 | break; |
148 | } | 147 | } |
149 | } | 148 | } |
150 | 149 | ||
151 | static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, | 150 | static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, |
152 | int destination_id, int source_id, int generation, int speed, | 151 | int destination_id, int source_id, int generation, int speed, |
153 | unsigned long long offset, void *payload, size_t length) | 152 | unsigned long long offset, void *payload, size_t length) |
154 | { | 153 | { |
155 | int ext_tcode; | 154 | int ext_tcode; |
156 | 155 | ||
157 | if (tcode == TCODE_STREAM_DATA) { | 156 | if (tcode == TCODE_STREAM_DATA) { |
158 | packet->header[0] = | 157 | packet->header[0] = |
159 | HEADER_DATA_LENGTH(length) | | 158 | HEADER_DATA_LENGTH(length) | |
160 | destination_id | | 159 | destination_id | |
161 | HEADER_TCODE(TCODE_STREAM_DATA); | 160 | HEADER_TCODE(TCODE_STREAM_DATA); |
162 | packet->header_length = 4; | 161 | packet->header_length = 4; |
163 | packet->payload = payload; | 162 | packet->payload = payload; |
164 | packet->payload_length = length; | 163 | packet->payload_length = length; |
165 | 164 | ||
166 | goto common; | 165 | goto common; |
167 | } | 166 | } |
168 | 167 | ||
169 | if (tcode > 0x10) { | 168 | if (tcode > 0x10) { |
170 | ext_tcode = tcode & ~0x10; | 169 | ext_tcode = tcode & ~0x10; |
171 | tcode = TCODE_LOCK_REQUEST; | 170 | tcode = TCODE_LOCK_REQUEST; |
172 | } else | 171 | } else |
173 | ext_tcode = 0; | 172 | ext_tcode = 0; |
174 | 173 | ||
175 | packet->header[0] = | 174 | packet->header[0] = |
176 | HEADER_RETRY(RETRY_X) | | 175 | HEADER_RETRY(RETRY_X) | |
177 | HEADER_TLABEL(tlabel) | | 176 | HEADER_TLABEL(tlabel) | |
178 | HEADER_TCODE(tcode) | | 177 | HEADER_TCODE(tcode) | |
179 | HEADER_DESTINATION(destination_id); | 178 | HEADER_DESTINATION(destination_id); |
180 | packet->header[1] = | 179 | packet->header[1] = |
181 | HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id); | 180 | HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id); |
182 | packet->header[2] = | 181 | packet->header[2] = |
183 | offset; | 182 | offset; |
184 | 183 | ||
185 | switch (tcode) { | 184 | switch (tcode) { |
186 | case TCODE_WRITE_QUADLET_REQUEST: | 185 | case TCODE_WRITE_QUADLET_REQUEST: |
187 | packet->header[3] = *(u32 *)payload; | 186 | packet->header[3] = *(u32 *)payload; |
188 | packet->header_length = 16; | 187 | packet->header_length = 16; |
189 | packet->payload_length = 0; | 188 | packet->payload_length = 0; |
190 | break; | 189 | break; |
191 | 190 | ||
192 | case TCODE_LOCK_REQUEST: | 191 | case TCODE_LOCK_REQUEST: |
193 | case TCODE_WRITE_BLOCK_REQUEST: | 192 | case TCODE_WRITE_BLOCK_REQUEST: |
194 | packet->header[3] = | 193 | packet->header[3] = |
195 | HEADER_DATA_LENGTH(length) | | 194 | HEADER_DATA_LENGTH(length) | |
196 | HEADER_EXTENDED_TCODE(ext_tcode); | 195 | HEADER_EXTENDED_TCODE(ext_tcode); |
197 | packet->header_length = 16; | 196 | packet->header_length = 16; |
198 | packet->payload = payload; | 197 | packet->payload = payload; |
199 | packet->payload_length = length; | 198 | packet->payload_length = length; |
200 | break; | 199 | break; |
201 | 200 | ||
202 | case TCODE_READ_QUADLET_REQUEST: | 201 | case TCODE_READ_QUADLET_REQUEST: |
203 | packet->header_length = 12; | 202 | packet->header_length = 12; |
204 | packet->payload_length = 0; | 203 | packet->payload_length = 0; |
205 | break; | 204 | break; |
206 | 205 | ||
207 | case TCODE_READ_BLOCK_REQUEST: | 206 | case TCODE_READ_BLOCK_REQUEST: |
208 | packet->header[3] = | 207 | packet->header[3] = |
209 | HEADER_DATA_LENGTH(length) | | 208 | HEADER_DATA_LENGTH(length) | |
210 | HEADER_EXTENDED_TCODE(ext_tcode); | 209 | HEADER_EXTENDED_TCODE(ext_tcode); |
211 | packet->header_length = 16; | 210 | packet->header_length = 16; |
212 | packet->payload_length = 0; | 211 | packet->payload_length = 0; |
213 | break; | 212 | break; |
214 | } | 213 | } |
215 | common: | 214 | common: |
216 | packet->speed = speed; | 215 | packet->speed = speed; |
217 | packet->generation = generation; | 216 | packet->generation = generation; |
218 | packet->ack = 0; | 217 | packet->ack = 0; |
219 | packet->payload_bus = 0; | 218 | packet->payload_bus = 0; |
220 | } | 219 | } |
221 | 220 | ||
222 | /** | 221 | /** |
223 | * This function provides low-level access to the IEEE1394 transaction | 222 | * This function provides low-level access to the IEEE1394 transaction |
224 | * logic. Most C programs would use either fw_read(), fw_write() or | 223 | * logic. Most C programs would use either fw_read(), fw_write() or |
225 | * fw_lock() instead - those function are convenience wrappers for | 224 | * fw_lock() instead - those function are convenience wrappers for |
226 | * this function. The fw_send_request() function is primarily | 225 | * this function. The fw_send_request() function is primarily |
227 | * provided as a flexible, one-stop entry point for languages bindings | 226 | * provided as a flexible, one-stop entry point for languages bindings |
228 | * and protocol bindings. | 227 | * and protocol bindings. |
229 | * | 228 | * |
230 | * FIXME: Document this function further, in particular the possible | 229 | * FIXME: Document this function further, in particular the possible |
231 | * values for rcode in the callback. In short, we map ACK_COMPLETE to | 230 | * values for rcode in the callback. In short, we map ACK_COMPLETE to |
232 | * RCODE_COMPLETE, internal errors set errno and set rcode to | 231 | * RCODE_COMPLETE, internal errors set errno and set rcode to |
233 | * RCODE_SEND_ERROR (which is out of range for standard ieee1394 | 232 | * RCODE_SEND_ERROR (which is out of range for standard ieee1394 |
234 | * rcodes). All other rcodes are forwarded unchanged. For all | 233 | * rcodes). All other rcodes are forwarded unchanged. For all |
235 | * errors, payload is NULL, length is 0. | 234 | * errors, payload is NULL, length is 0. |
236 | * | 235 | * |
237 | * Can not expect the callback to be called before the function | 236 | * Can not expect the callback to be called before the function |
238 | * returns, though this does happen in some cases (ACK_COMPLETE and | 237 | * returns, though this does happen in some cases (ACK_COMPLETE and |
239 | * errors). | 238 | * errors). |
240 | * | 239 | * |
241 | * The payload is only used for write requests and must not be freed | 240 | * The payload is only used for write requests and must not be freed |
242 | * until the callback has been called. | 241 | * until the callback has been called. |
243 | * | 242 | * |
244 | * @param card the card from which to send the request | 243 | * @param card the card from which to send the request |
245 | * @param tcode the tcode for this transaction. Do not use | 244 | * @param tcode the tcode for this transaction. Do not use |
246 | * TCODE_LOCK_REQUEST directly, instead use TCODE_LOCK_MASK_SWAP | 245 | * TCODE_LOCK_REQUEST directly, instead use TCODE_LOCK_MASK_SWAP |
247 | * etc. to specify tcode and ext_tcode. | 246 | * etc. to specify tcode and ext_tcode. |
248 | * @param node_id the destination node ID (bus ID and PHY ID concatenated) | 247 | * @param node_id the destination node ID (bus ID and PHY ID concatenated) |
249 | * @param generation the generation for which node_id is valid | 248 | * @param generation the generation for which node_id is valid |
250 | * @param speed the speed to use for sending the request | 249 | * @param speed the speed to use for sending the request |
251 | * @param offset the 48 bit offset on the destination node | 250 | * @param offset the 48 bit offset on the destination node |
252 | * @param payload the data payload for the request subaction | 251 | * @param payload the data payload for the request subaction |
253 | * @param length the length in bytes of the data to read | 252 | * @param length the length in bytes of the data to read |
254 | * @param callback function to be called when the transaction is completed | 253 | * @param callback function to be called when the transaction is completed |
255 | * @param callback_data pointer to arbitrary data, which will be | 254 | * @param callback_data pointer to arbitrary data, which will be |
256 | * passed to the callback | 255 | * passed to the callback |
257 | * | 256 | * |
258 | * In case of asynchronous stream packets i.e. TCODE_STREAM_DATA, the caller | 257 | * In case of asynchronous stream packets i.e. TCODE_STREAM_DATA, the caller |
259 | * needs to synthesize @destination_id with fw_stream_packet_destination_id(). | 258 | * needs to synthesize @destination_id with fw_stream_packet_destination_id(). |
260 | */ | 259 | */ |
261 | void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, | 260 | void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, |
262 | int destination_id, int generation, int speed, | 261 | int destination_id, int generation, int speed, |
263 | unsigned long long offset, void *payload, size_t length, | 262 | unsigned long long offset, void *payload, size_t length, |
264 | fw_transaction_callback_t callback, void *callback_data) | 263 | fw_transaction_callback_t callback, void *callback_data) |
265 | { | 264 | { |
266 | unsigned long flags; | 265 | unsigned long flags; |
267 | int tlabel; | 266 | int tlabel; |
268 | 267 | ||
269 | /* | 268 | /* |
270 | * Bump the flush timer up 100ms first of all so we | 269 | * Bump the flush timer up 100ms first of all so we |
271 | * don't race with a flush timer callback. | 270 | * don't race with a flush timer callback. |
272 | */ | 271 | */ |
273 | 272 | ||
274 | mod_timer(&card->flush_timer, jiffies + DIV_ROUND_UP(HZ, 10)); | 273 | mod_timer(&card->flush_timer, jiffies + DIV_ROUND_UP(HZ, 10)); |
275 | 274 | ||
276 | /* | 275 | /* |
277 | * Allocate tlabel from the bitmap and put the transaction on | 276 | * Allocate tlabel from the bitmap and put the transaction on |
278 | * the list while holding the card spinlock. | 277 | * the list while holding the card spinlock. |
279 | */ | 278 | */ |
280 | 279 | ||
281 | spin_lock_irqsave(&card->lock, flags); | 280 | spin_lock_irqsave(&card->lock, flags); |
282 | 281 | ||
283 | tlabel = card->current_tlabel; | 282 | tlabel = card->current_tlabel; |
284 | if (card->tlabel_mask & (1 << tlabel)) { | 283 | if (card->tlabel_mask & (1 << tlabel)) { |
285 | spin_unlock_irqrestore(&card->lock, flags); | 284 | spin_unlock_irqrestore(&card->lock, flags); |
286 | callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data); | 285 | callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data); |
287 | return; | 286 | return; |
288 | } | 287 | } |
289 | 288 | ||
290 | card->current_tlabel = (card->current_tlabel + 1) & 0x1f; | 289 | card->current_tlabel = (card->current_tlabel + 1) & 0x1f; |
291 | card->tlabel_mask |= (1 << tlabel); | 290 | card->tlabel_mask |= (1 << tlabel); |
292 | 291 | ||
293 | t->node_id = destination_id; | 292 | t->node_id = destination_id; |
294 | t->tlabel = tlabel; | 293 | t->tlabel = tlabel; |
295 | t->callback = callback; | 294 | t->callback = callback; |
296 | t->callback_data = callback_data; | 295 | t->callback_data = callback_data; |
297 | 296 | ||
298 | fw_fill_request(&t->packet, tcode, t->tlabel, | 297 | fw_fill_request(&t->packet, tcode, t->tlabel, |
299 | destination_id, card->node_id, generation, | 298 | destination_id, card->node_id, generation, |
300 | speed, offset, payload, length); | 299 | speed, offset, payload, length); |
301 | t->packet.callback = transmit_complete_callback; | 300 | t->packet.callback = transmit_complete_callback; |
302 | 301 | ||
303 | list_add_tail(&t->link, &card->transaction_list); | 302 | list_add_tail(&t->link, &card->transaction_list); |
304 | 303 | ||
305 | spin_unlock_irqrestore(&card->lock, flags); | 304 | spin_unlock_irqrestore(&card->lock, flags); |
306 | 305 | ||
307 | card->driver->send_request(card, &t->packet); | 306 | card->driver->send_request(card, &t->packet); |
308 | } | 307 | } |
309 | EXPORT_SYMBOL(fw_send_request); | 308 | EXPORT_SYMBOL(fw_send_request); |
310 | 309 | ||
311 | struct transaction_callback_data { | 310 | struct transaction_callback_data { |
312 | struct completion done; | 311 | struct completion done; |
313 | void *payload; | 312 | void *payload; |
314 | int rcode; | 313 | int rcode; |
315 | }; | 314 | }; |
316 | 315 | ||
317 | static void transaction_callback(struct fw_card *card, int rcode, | 316 | static void transaction_callback(struct fw_card *card, int rcode, |
318 | void *payload, size_t length, void *data) | 317 | void *payload, size_t length, void *data) |
319 | { | 318 | { |
320 | struct transaction_callback_data *d = data; | 319 | struct transaction_callback_data *d = data; |
321 | 320 | ||
322 | if (rcode == RCODE_COMPLETE) | 321 | if (rcode == RCODE_COMPLETE) |
323 | memcpy(d->payload, payload, length); | 322 | memcpy(d->payload, payload, length); |
324 | d->rcode = rcode; | 323 | d->rcode = rcode; |
325 | complete(&d->done); | 324 | complete(&d->done); |
326 | } | 325 | } |
327 | 326 | ||
328 | /** | 327 | /** |
329 | * fw_run_transaction - send request and sleep until transaction is completed | 328 | * fw_run_transaction - send request and sleep until transaction is completed |
330 | * | 329 | * |
331 | * Returns the RCODE. | 330 | * Returns the RCODE. |
332 | */ | 331 | */ |
333 | int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, | 332 | int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, |
334 | int generation, int speed, unsigned long long offset, | 333 | int generation, int speed, unsigned long long offset, |
335 | void *payload, size_t length) | 334 | void *payload, size_t length) |
336 | { | 335 | { |
337 | struct transaction_callback_data d; | 336 | struct transaction_callback_data d; |
338 | struct fw_transaction t; | 337 | struct fw_transaction t; |
339 | 338 | ||
340 | init_completion(&d.done); | 339 | init_completion(&d.done); |
341 | d.payload = payload; | 340 | d.payload = payload; |
342 | fw_send_request(card, &t, tcode, destination_id, generation, speed, | 341 | fw_send_request(card, &t, tcode, destination_id, generation, speed, |
343 | offset, payload, length, transaction_callback, &d); | 342 | offset, payload, length, transaction_callback, &d); |
344 | wait_for_completion(&d.done); | 343 | wait_for_completion(&d.done); |
345 | 344 | ||
346 | return d.rcode; | 345 | return d.rcode; |
347 | } | 346 | } |
348 | EXPORT_SYMBOL(fw_run_transaction); | 347 | EXPORT_SYMBOL(fw_run_transaction); |
349 | 348 | ||
350 | static DEFINE_MUTEX(phy_config_mutex); | 349 | static DEFINE_MUTEX(phy_config_mutex); |
351 | static DECLARE_COMPLETION(phy_config_done); | 350 | static DECLARE_COMPLETION(phy_config_done); |
352 | 351 | ||
353 | static void transmit_phy_packet_callback(struct fw_packet *packet, | 352 | static void transmit_phy_packet_callback(struct fw_packet *packet, |
354 | struct fw_card *card, int status) | 353 | struct fw_card *card, int status) |
355 | { | 354 | { |
356 | complete(&phy_config_done); | 355 | complete(&phy_config_done); |
357 | } | 356 | } |
358 | 357 | ||
359 | static struct fw_packet phy_config_packet = { | 358 | static struct fw_packet phy_config_packet = { |
360 | .header_length = 8, | 359 | .header_length = 8, |
361 | .payload_length = 0, | 360 | .payload_length = 0, |
362 | .speed = SCODE_100, | 361 | .speed = SCODE_100, |
363 | .callback = transmit_phy_packet_callback, | 362 | .callback = transmit_phy_packet_callback, |
364 | }; | 363 | }; |
365 | 364 | ||
366 | void fw_send_phy_config(struct fw_card *card, | 365 | void fw_send_phy_config(struct fw_card *card, |
367 | int node_id, int generation, int gap_count) | 366 | int node_id, int generation, int gap_count) |
368 | { | 367 | { |
369 | long timeout = DIV_ROUND_UP(HZ, 10); | 368 | long timeout = DIV_ROUND_UP(HZ, 10); |
370 | u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | | 369 | u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | |
371 | PHY_CONFIG_ROOT_ID(node_id) | | 370 | PHY_CONFIG_ROOT_ID(node_id) | |
372 | PHY_CONFIG_GAP_COUNT(gap_count); | 371 | PHY_CONFIG_GAP_COUNT(gap_count); |
373 | 372 | ||
374 | mutex_lock(&phy_config_mutex); | 373 | mutex_lock(&phy_config_mutex); |
375 | 374 | ||
376 | phy_config_packet.header[0] = data; | 375 | phy_config_packet.header[0] = data; |
377 | phy_config_packet.header[1] = ~data; | 376 | phy_config_packet.header[1] = ~data; |
378 | phy_config_packet.generation = generation; | 377 | phy_config_packet.generation = generation; |
379 | INIT_COMPLETION(phy_config_done); | 378 | INIT_COMPLETION(phy_config_done); |
380 | 379 | ||
381 | card->driver->send_request(card, &phy_config_packet); | 380 | card->driver->send_request(card, &phy_config_packet); |
382 | wait_for_completion_timeout(&phy_config_done, timeout); | 381 | wait_for_completion_timeout(&phy_config_done, timeout); |
383 | 382 | ||
384 | mutex_unlock(&phy_config_mutex); | 383 | mutex_unlock(&phy_config_mutex); |
385 | } | 384 | } |
386 | 385 | ||
387 | void fw_flush_transactions(struct fw_card *card) | 386 | void fw_flush_transactions(struct fw_card *card) |
388 | { | 387 | { |
389 | struct fw_transaction *t, *next; | 388 | struct fw_transaction *t, *next; |
390 | struct list_head list; | 389 | struct list_head list; |
391 | unsigned long flags; | 390 | unsigned long flags; |
392 | 391 | ||
393 | INIT_LIST_HEAD(&list); | 392 | INIT_LIST_HEAD(&list); |
394 | spin_lock_irqsave(&card->lock, flags); | 393 | spin_lock_irqsave(&card->lock, flags); |
395 | list_splice_init(&card->transaction_list, &list); | 394 | list_splice_init(&card->transaction_list, &list); |
396 | card->tlabel_mask = 0; | 395 | card->tlabel_mask = 0; |
397 | spin_unlock_irqrestore(&card->lock, flags); | 396 | spin_unlock_irqrestore(&card->lock, flags); |
398 | 397 | ||
399 | list_for_each_entry_safe(t, next, &list, link) { | 398 | list_for_each_entry_safe(t, next, &list, link) { |
400 | card->driver->cancel_packet(card, &t->packet); | 399 | card->driver->cancel_packet(card, &t->packet); |
401 | 400 | ||
402 | /* | 401 | /* |
403 | * At this point cancel_packet will never call the | 402 | * At this point cancel_packet will never call the |
404 | * transaction callback, since we just took all the | 403 | * transaction callback, since we just took all the |
405 | * transactions out of the list. So do it here. | 404 | * transactions out of the list. So do it here. |
406 | */ | 405 | */ |
407 | t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data); | 406 | t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data); |
408 | } | 407 | } |
409 | } | 408 | } |
410 | 409 | ||
411 | static struct fw_address_handler *lookup_overlapping_address_handler( | 410 | static struct fw_address_handler *lookup_overlapping_address_handler( |
412 | struct list_head *list, unsigned long long offset, size_t length) | 411 | struct list_head *list, unsigned long long offset, size_t length) |
413 | { | 412 | { |
414 | struct fw_address_handler *handler; | 413 | struct fw_address_handler *handler; |
415 | 414 | ||
416 | list_for_each_entry(handler, list, link) { | 415 | list_for_each_entry(handler, list, link) { |
417 | if (handler->offset < offset + length && | 416 | if (handler->offset < offset + length && |
418 | offset < handler->offset + handler->length) | 417 | offset < handler->offset + handler->length) |
419 | return handler; | 418 | return handler; |
420 | } | 419 | } |
421 | 420 | ||
422 | return NULL; | 421 | return NULL; |
423 | } | 422 | } |
424 | 423 | ||
425 | static struct fw_address_handler *lookup_enclosing_address_handler( | 424 | static struct fw_address_handler *lookup_enclosing_address_handler( |
426 | struct list_head *list, unsigned long long offset, size_t length) | 425 | struct list_head *list, unsigned long long offset, size_t length) |
427 | { | 426 | { |
428 | struct fw_address_handler *handler; | 427 | struct fw_address_handler *handler; |
429 | 428 | ||
430 | list_for_each_entry(handler, list, link) { | 429 | list_for_each_entry(handler, list, link) { |
431 | if (handler->offset <= offset && | 430 | if (handler->offset <= offset && |
432 | offset + length <= handler->offset + handler->length) | 431 | offset + length <= handler->offset + handler->length) |
433 | return handler; | 432 | return handler; |
434 | } | 433 | } |
435 | 434 | ||
436 | return NULL; | 435 | return NULL; |
437 | } | 436 | } |
438 | 437 | ||
439 | static DEFINE_SPINLOCK(address_handler_lock); | 438 | static DEFINE_SPINLOCK(address_handler_lock); |
440 | static LIST_HEAD(address_handler_list); | 439 | static LIST_HEAD(address_handler_list); |
441 | 440 | ||
442 | const struct fw_address_region fw_high_memory_region = | 441 | const struct fw_address_region fw_high_memory_region = |
443 | { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }; | 442 | { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }; |
444 | EXPORT_SYMBOL(fw_high_memory_region); | 443 | EXPORT_SYMBOL(fw_high_memory_region); |
445 | 444 | ||
446 | #if 0 | 445 | #if 0 |
447 | const struct fw_address_region fw_low_memory_region = | 446 | const struct fw_address_region fw_low_memory_region = |
448 | { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; | 447 | { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; |
449 | const struct fw_address_region fw_private_region = | 448 | const struct fw_address_region fw_private_region = |
450 | { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, }; | 449 | { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, }; |
451 | const struct fw_address_region fw_csr_region = | 450 | const struct fw_address_region fw_csr_region = |
452 | { .start = CSR_REGISTER_BASE, | 451 | { .start = CSR_REGISTER_BASE, |
453 | .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM_END, }; | 452 | .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM_END, }; |
454 | const struct fw_address_region fw_unit_space_region = | 453 | const struct fw_address_region fw_unit_space_region = |
455 | { .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, }; | 454 | { .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, }; |
456 | #endif /* 0 */ | 455 | #endif /* 0 */ |
457 | 456 | ||
458 | /** | 457 | /** |
459 | * fw_core_add_address_handler - register for incoming requests | 458 | * fw_core_add_address_handler - register for incoming requests |
460 | * @handler: callback | 459 | * @handler: callback |
461 | * @region: region in the IEEE 1212 node space address range | 460 | * @region: region in the IEEE 1212 node space address range |
462 | * | 461 | * |
463 | * region->start, ->end, and handler->length have to be quadlet-aligned. | 462 | * region->start, ->end, and handler->length have to be quadlet-aligned. |
464 | * | 463 | * |
465 | * When a request is received that falls within the specified address range, | 464 | * When a request is received that falls within the specified address range, |
466 | * the specified callback is invoked. The parameters passed to the callback | 465 | * the specified callback is invoked. The parameters passed to the callback |
467 | * give the details of the particular request. | 466 | * give the details of the particular request. |
468 | * | 467 | * |
469 | * Return value: 0 on success, non-zero otherwise. | 468 | * Return value: 0 on success, non-zero otherwise. |
470 | * The start offset of the handler's address region is determined by | 469 | * The start offset of the handler's address region is determined by |
471 | * fw_core_add_address_handler() and is returned in handler->offset. | 470 | * fw_core_add_address_handler() and is returned in handler->offset. |
472 | */ | 471 | */ |
473 | int fw_core_add_address_handler(struct fw_address_handler *handler, | 472 | int fw_core_add_address_handler(struct fw_address_handler *handler, |
474 | const struct fw_address_region *region) | 473 | const struct fw_address_region *region) |
475 | { | 474 | { |
476 | struct fw_address_handler *other; | 475 | struct fw_address_handler *other; |
477 | unsigned long flags; | 476 | unsigned long flags; |
478 | int ret = -EBUSY; | 477 | int ret = -EBUSY; |
479 | 478 | ||
480 | if (region->start & 0xffff000000000003ULL || | 479 | if (region->start & 0xffff000000000003ULL || |
481 | region->end & 0xffff000000000003ULL || | 480 | region->end & 0xffff000000000003ULL || |
482 | region->start >= region->end || | 481 | region->start >= region->end || |
483 | handler->length & 3 || | 482 | handler->length & 3 || |
484 | handler->length == 0) | 483 | handler->length == 0) |
485 | return -EINVAL; | 484 | return -EINVAL; |
486 | 485 | ||
487 | spin_lock_irqsave(&address_handler_lock, flags); | 486 | spin_lock_irqsave(&address_handler_lock, flags); |
488 | 487 | ||
489 | handler->offset = region->start; | 488 | handler->offset = region->start; |
490 | while (handler->offset + handler->length <= region->end) { | 489 | while (handler->offset + handler->length <= region->end) { |
491 | other = | 490 | other = |
492 | lookup_overlapping_address_handler(&address_handler_list, | 491 | lookup_overlapping_address_handler(&address_handler_list, |
493 | handler->offset, | 492 | handler->offset, |
494 | handler->length); | 493 | handler->length); |
495 | if (other != NULL) { | 494 | if (other != NULL) { |
496 | handler->offset += other->length; | 495 | handler->offset += other->length; |
497 | } else { | 496 | } else { |
498 | list_add_tail(&handler->link, &address_handler_list); | 497 | list_add_tail(&handler->link, &address_handler_list); |
499 | ret = 0; | 498 | ret = 0; |
500 | break; | 499 | break; |
501 | } | 500 | } |
502 | } | 501 | } |
503 | 502 | ||
504 | spin_unlock_irqrestore(&address_handler_lock, flags); | 503 | spin_unlock_irqrestore(&address_handler_lock, flags); |
505 | 504 | ||
506 | return ret; | 505 | return ret; |
507 | } | 506 | } |
508 | EXPORT_SYMBOL(fw_core_add_address_handler); | 507 | EXPORT_SYMBOL(fw_core_add_address_handler); |
509 | 508 | ||
510 | /** | 509 | /** |
511 | * fw_core_remove_address_handler - unregister an address handler | 510 | * fw_core_remove_address_handler - unregister an address handler |
512 | */ | 511 | */ |
513 | void fw_core_remove_address_handler(struct fw_address_handler *handler) | 512 | void fw_core_remove_address_handler(struct fw_address_handler *handler) |
514 | { | 513 | { |
515 | unsigned long flags; | 514 | unsigned long flags; |
516 | 515 | ||
517 | spin_lock_irqsave(&address_handler_lock, flags); | 516 | spin_lock_irqsave(&address_handler_lock, flags); |
518 | list_del(&handler->link); | 517 | list_del(&handler->link); |
519 | spin_unlock_irqrestore(&address_handler_lock, flags); | 518 | spin_unlock_irqrestore(&address_handler_lock, flags); |
520 | } | 519 | } |
521 | EXPORT_SYMBOL(fw_core_remove_address_handler); | 520 | EXPORT_SYMBOL(fw_core_remove_address_handler); |
522 | 521 | ||
523 | struct fw_request { | 522 | struct fw_request { |
524 | struct fw_packet response; | 523 | struct fw_packet response; |
525 | u32 request_header[4]; | 524 | u32 request_header[4]; |
526 | int ack; | 525 | int ack; |
527 | u32 length; | 526 | u32 length; |
528 | u32 data[0]; | 527 | u32 data[0]; |
529 | }; | 528 | }; |
530 | 529 | ||
531 | static void free_response_callback(struct fw_packet *packet, | 530 | static void free_response_callback(struct fw_packet *packet, |
532 | struct fw_card *card, int status) | 531 | struct fw_card *card, int status) |
533 | { | 532 | { |
534 | struct fw_request *request; | 533 | struct fw_request *request; |
535 | 534 | ||
536 | request = container_of(packet, struct fw_request, response); | 535 | request = container_of(packet, struct fw_request, response); |
537 | kfree(request); | 536 | kfree(request); |
538 | } | 537 | } |
539 | 538 | ||
540 | void fw_fill_response(struct fw_packet *response, u32 *request_header, | 539 | void fw_fill_response(struct fw_packet *response, u32 *request_header, |
541 | int rcode, void *payload, size_t length) | 540 | int rcode, void *payload, size_t length) |
542 | { | 541 | { |
543 | int tcode, tlabel, extended_tcode, source, destination; | 542 | int tcode, tlabel, extended_tcode, source, destination; |
544 | 543 | ||
545 | tcode = HEADER_GET_TCODE(request_header[0]); | 544 | tcode = HEADER_GET_TCODE(request_header[0]); |
546 | tlabel = HEADER_GET_TLABEL(request_header[0]); | 545 | tlabel = HEADER_GET_TLABEL(request_header[0]); |
547 | source = HEADER_GET_DESTINATION(request_header[0]); | 546 | source = HEADER_GET_DESTINATION(request_header[0]); |
548 | destination = HEADER_GET_SOURCE(request_header[1]); | 547 | destination = HEADER_GET_SOURCE(request_header[1]); |
549 | extended_tcode = HEADER_GET_EXTENDED_TCODE(request_header[3]); | 548 | extended_tcode = HEADER_GET_EXTENDED_TCODE(request_header[3]); |
550 | 549 | ||
551 | response->header[0] = | 550 | response->header[0] = |
552 | HEADER_RETRY(RETRY_1) | | 551 | HEADER_RETRY(RETRY_1) | |
553 | HEADER_TLABEL(tlabel) | | 552 | HEADER_TLABEL(tlabel) | |
554 | HEADER_DESTINATION(destination); | 553 | HEADER_DESTINATION(destination); |
555 | response->header[1] = | 554 | response->header[1] = |
556 | HEADER_SOURCE(source) | | 555 | HEADER_SOURCE(source) | |
557 | HEADER_RCODE(rcode); | 556 | HEADER_RCODE(rcode); |
558 | response->header[2] = 0; | 557 | response->header[2] = 0; |
559 | 558 | ||
560 | switch (tcode) { | 559 | switch (tcode) { |
561 | case TCODE_WRITE_QUADLET_REQUEST: | 560 | case TCODE_WRITE_QUADLET_REQUEST: |
562 | case TCODE_WRITE_BLOCK_REQUEST: | 561 | case TCODE_WRITE_BLOCK_REQUEST: |
563 | response->header[0] |= HEADER_TCODE(TCODE_WRITE_RESPONSE); | 562 | response->header[0] |= HEADER_TCODE(TCODE_WRITE_RESPONSE); |
564 | response->header_length = 12; | 563 | response->header_length = 12; |
565 | response->payload_length = 0; | 564 | response->payload_length = 0; |
566 | break; | 565 | break; |
567 | 566 | ||
568 | case TCODE_READ_QUADLET_REQUEST: | 567 | case TCODE_READ_QUADLET_REQUEST: |
569 | response->header[0] |= | 568 | response->header[0] |= |
570 | HEADER_TCODE(TCODE_READ_QUADLET_RESPONSE); | 569 | HEADER_TCODE(TCODE_READ_QUADLET_RESPONSE); |
571 | if (payload != NULL) | 570 | if (payload != NULL) |
572 | response->header[3] = *(u32 *)payload; | 571 | response->header[3] = *(u32 *)payload; |
573 | else | 572 | else |
574 | response->header[3] = 0; | 573 | response->header[3] = 0; |
575 | response->header_length = 16; | 574 | response->header_length = 16; |
576 | response->payload_length = 0; | 575 | response->payload_length = 0; |
577 | break; | 576 | break; |
578 | 577 | ||
579 | case TCODE_READ_BLOCK_REQUEST: | 578 | case TCODE_READ_BLOCK_REQUEST: |
580 | case TCODE_LOCK_REQUEST: | 579 | case TCODE_LOCK_REQUEST: |
581 | response->header[0] |= HEADER_TCODE(tcode + 2); | 580 | response->header[0] |= HEADER_TCODE(tcode + 2); |
582 | response->header[3] = | 581 | response->header[3] = |
583 | HEADER_DATA_LENGTH(length) | | 582 | HEADER_DATA_LENGTH(length) | |
584 | HEADER_EXTENDED_TCODE(extended_tcode); | 583 | HEADER_EXTENDED_TCODE(extended_tcode); |
585 | response->header_length = 16; | 584 | response->header_length = 16; |
586 | response->payload = payload; | 585 | response->payload = payload; |
587 | response->payload_length = length; | 586 | response->payload_length = length; |
588 | break; | 587 | break; |
589 | 588 | ||
590 | default: | 589 | default: |
591 | BUG(); | 590 | BUG(); |
592 | return; | 591 | return; |
593 | } | 592 | } |
594 | 593 | ||
595 | response->payload_bus = 0; | 594 | response->payload_bus = 0; |
596 | } | 595 | } |
597 | EXPORT_SYMBOL(fw_fill_response); | 596 | EXPORT_SYMBOL(fw_fill_response); |
598 | 597 | ||
599 | static struct fw_request *allocate_request(struct fw_packet *p) | 598 | static struct fw_request *allocate_request(struct fw_packet *p) |
600 | { | 599 | { |
601 | struct fw_request *request; | 600 | struct fw_request *request; |
602 | u32 *data, length; | 601 | u32 *data, length; |
603 | int request_tcode, t; | 602 | int request_tcode, t; |
604 | 603 | ||
605 | request_tcode = HEADER_GET_TCODE(p->header[0]); | 604 | request_tcode = HEADER_GET_TCODE(p->header[0]); |
606 | switch (request_tcode) { | 605 | switch (request_tcode) { |
607 | case TCODE_WRITE_QUADLET_REQUEST: | 606 | case TCODE_WRITE_QUADLET_REQUEST: |
608 | data = &p->header[3]; | 607 | data = &p->header[3]; |
609 | length = 4; | 608 | length = 4; |
610 | break; | 609 | break; |
611 | 610 | ||
612 | case TCODE_WRITE_BLOCK_REQUEST: | 611 | case TCODE_WRITE_BLOCK_REQUEST: |
613 | case TCODE_LOCK_REQUEST: | 612 | case TCODE_LOCK_REQUEST: |
614 | data = p->payload; | 613 | data = p->payload; |
615 | length = HEADER_GET_DATA_LENGTH(p->header[3]); | 614 | length = HEADER_GET_DATA_LENGTH(p->header[3]); |
616 | break; | 615 | break; |
617 | 616 | ||
618 | case TCODE_READ_QUADLET_REQUEST: | 617 | case TCODE_READ_QUADLET_REQUEST: |
619 | data = NULL; | 618 | data = NULL; |
620 | length = 4; | 619 | length = 4; |
621 | break; | 620 | break; |
622 | 621 | ||
623 | case TCODE_READ_BLOCK_REQUEST: | 622 | case TCODE_READ_BLOCK_REQUEST: |
624 | data = NULL; | 623 | data = NULL; |
625 | length = HEADER_GET_DATA_LENGTH(p->header[3]); | 624 | length = HEADER_GET_DATA_LENGTH(p->header[3]); |
626 | break; | 625 | break; |
627 | 626 | ||
628 | default: | 627 | default: |
629 | fw_error("ERROR - corrupt request received - %08x %08x %08x\n", | 628 | fw_error("ERROR - corrupt request received - %08x %08x %08x\n", |
630 | p->header[0], p->header[1], p->header[2]); | 629 | p->header[0], p->header[1], p->header[2]); |
631 | return NULL; | 630 | return NULL; |
632 | } | 631 | } |
633 | 632 | ||
634 | request = kmalloc(sizeof(*request) + length, GFP_ATOMIC); | 633 | request = kmalloc(sizeof(*request) + length, GFP_ATOMIC); |
635 | if (request == NULL) | 634 | if (request == NULL) |
636 | return NULL; | 635 | return NULL; |
637 | 636 | ||
638 | t = (p->timestamp & 0x1fff) + 4000; | 637 | t = (p->timestamp & 0x1fff) + 4000; |
639 | if (t >= 8000) | 638 | if (t >= 8000) |
640 | t = (p->timestamp & ~0x1fff) + 0x2000 + t - 8000; | 639 | t = (p->timestamp & ~0x1fff) + 0x2000 + t - 8000; |
641 | else | 640 | else |
642 | t = (p->timestamp & ~0x1fff) + t; | 641 | t = (p->timestamp & ~0x1fff) + t; |
643 | 642 | ||
644 | request->response.speed = p->speed; | 643 | request->response.speed = p->speed; |
645 | request->response.timestamp = t; | 644 | request->response.timestamp = t; |
646 | request->response.generation = p->generation; | 645 | request->response.generation = p->generation; |
647 | request->response.ack = 0; | 646 | request->response.ack = 0; |
648 | request->response.callback = free_response_callback; | 647 | request->response.callback = free_response_callback; |
649 | request->ack = p->ack; | 648 | request->ack = p->ack; |
650 | request->length = length; | 649 | request->length = length; |
651 | if (data) | 650 | if (data) |
652 | memcpy(request->data, data, length); | 651 | memcpy(request->data, data, length); |
653 | 652 | ||
654 | memcpy(request->request_header, p->header, sizeof(p->header)); | 653 | memcpy(request->request_header, p->header, sizeof(p->header)); |
655 | 654 | ||
656 | return request; | 655 | return request; |
657 | } | 656 | } |
658 | 657 | ||
659 | void fw_send_response(struct fw_card *card, | 658 | void fw_send_response(struct fw_card *card, |
660 | struct fw_request *request, int rcode) | 659 | struct fw_request *request, int rcode) |
661 | { | 660 | { |
662 | /* unified transaction or broadcast transaction: don't respond */ | 661 | /* unified transaction or broadcast transaction: don't respond */ |
663 | if (request->ack != ACK_PENDING || | 662 | if (request->ack != ACK_PENDING || |
664 | HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) { | 663 | HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) { |
665 | kfree(request); | 664 | kfree(request); |
666 | return; | 665 | return; |
667 | } | 666 | } |
668 | 667 | ||
669 | if (rcode == RCODE_COMPLETE) | 668 | if (rcode == RCODE_COMPLETE) |
670 | fw_fill_response(&request->response, request->request_header, | 669 | fw_fill_response(&request->response, request->request_header, |
671 | rcode, request->data, request->length); | 670 | rcode, request->data, request->length); |
672 | else | 671 | else |
673 | fw_fill_response(&request->response, request->request_header, | 672 | fw_fill_response(&request->response, request->request_header, |
674 | rcode, NULL, 0); | 673 | rcode, NULL, 0); |
675 | 674 | ||
676 | card->driver->send_response(card, &request->response); | 675 | card->driver->send_response(card, &request->response); |
677 | } | 676 | } |
678 | EXPORT_SYMBOL(fw_send_response); | 677 | EXPORT_SYMBOL(fw_send_response); |
679 | 678 | ||
680 | void fw_core_handle_request(struct fw_card *card, struct fw_packet *p) | 679 | void fw_core_handle_request(struct fw_card *card, struct fw_packet *p) |
681 | { | 680 | { |
682 | struct fw_address_handler *handler; | 681 | struct fw_address_handler *handler; |
683 | struct fw_request *request; | 682 | struct fw_request *request; |
684 | unsigned long long offset; | 683 | unsigned long long offset; |
685 | unsigned long flags; | 684 | unsigned long flags; |
686 | int tcode, destination, source; | 685 | int tcode, destination, source; |
687 | 686 | ||
688 | if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) | 687 | if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) |
689 | return; | 688 | return; |
690 | 689 | ||
691 | request = allocate_request(p); | 690 | request = allocate_request(p); |
692 | if (request == NULL) { | 691 | if (request == NULL) { |
693 | /* FIXME: send statically allocated busy packet. */ | 692 | /* FIXME: send statically allocated busy packet. */ |
694 | return; | 693 | return; |
695 | } | 694 | } |
696 | 695 | ||
697 | offset = | 696 | offset = |
698 | ((unsigned long long) | 697 | ((unsigned long long) |
699 | HEADER_GET_OFFSET_HIGH(p->header[1]) << 32) | p->header[2]; | 698 | HEADER_GET_OFFSET_HIGH(p->header[1]) << 32) | p->header[2]; |
700 | tcode = HEADER_GET_TCODE(p->header[0]); | 699 | tcode = HEADER_GET_TCODE(p->header[0]); |
701 | destination = HEADER_GET_DESTINATION(p->header[0]); | 700 | destination = HEADER_GET_DESTINATION(p->header[0]); |
702 | source = HEADER_GET_SOURCE(p->header[1]); | 701 | source = HEADER_GET_SOURCE(p->header[1]); |
703 | 702 | ||
704 | spin_lock_irqsave(&address_handler_lock, flags); | 703 | spin_lock_irqsave(&address_handler_lock, flags); |
705 | handler = lookup_enclosing_address_handler(&address_handler_list, | 704 | handler = lookup_enclosing_address_handler(&address_handler_list, |
706 | offset, request->length); | 705 | offset, request->length); |
707 | spin_unlock_irqrestore(&address_handler_lock, flags); | 706 | spin_unlock_irqrestore(&address_handler_lock, flags); |
708 | 707 | ||
709 | /* | 708 | /* |
710 | * FIXME: lookup the fw_node corresponding to the sender of | 709 | * FIXME: lookup the fw_node corresponding to the sender of |
711 | * this request and pass that to the address handler instead | 710 | * this request and pass that to the address handler instead |
712 | * of the node ID. We may also want to move the address | 711 | * of the node ID. We may also want to move the address |
713 | * allocations to fw_node so we only do this callback if the | 712 | * allocations to fw_node so we only do this callback if the |
714 | * upper layers registered it for this node. | 713 | * upper layers registered it for this node. |
715 | */ | 714 | */ |
716 | 715 | ||
717 | if (handler == NULL) | 716 | if (handler == NULL) |
718 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | 717 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); |
719 | else | 718 | else |
720 | handler->address_callback(card, request, | 719 | handler->address_callback(card, request, |
721 | tcode, destination, source, | 720 | tcode, destination, source, |
722 | p->generation, p->speed, offset, | 721 | p->generation, p->speed, offset, |
723 | request->data, request->length, | 722 | request->data, request->length, |
724 | handler->callback_data); | 723 | handler->callback_data); |
725 | } | 724 | } |
726 | EXPORT_SYMBOL(fw_core_handle_request); | 725 | EXPORT_SYMBOL(fw_core_handle_request); |
727 | 726 | ||
728 | void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) | 727 | void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) |
729 | { | 728 | { |
730 | struct fw_transaction *t; | 729 | struct fw_transaction *t; |
731 | unsigned long flags; | 730 | unsigned long flags; |
732 | u32 *data; | 731 | u32 *data; |
733 | size_t data_length; | 732 | size_t data_length; |
734 | int tcode, tlabel, destination, source, rcode; | 733 | int tcode, tlabel, destination, source, rcode; |
735 | 734 | ||
736 | tcode = HEADER_GET_TCODE(p->header[0]); | 735 | tcode = HEADER_GET_TCODE(p->header[0]); |
737 | tlabel = HEADER_GET_TLABEL(p->header[0]); | 736 | tlabel = HEADER_GET_TLABEL(p->header[0]); |
738 | destination = HEADER_GET_DESTINATION(p->header[0]); | 737 | destination = HEADER_GET_DESTINATION(p->header[0]); |
739 | source = HEADER_GET_SOURCE(p->header[1]); | 738 | source = HEADER_GET_SOURCE(p->header[1]); |
740 | rcode = HEADER_GET_RCODE(p->header[1]); | 739 | rcode = HEADER_GET_RCODE(p->header[1]); |
741 | 740 | ||
742 | spin_lock_irqsave(&card->lock, flags); | 741 | spin_lock_irqsave(&card->lock, flags); |
743 | list_for_each_entry(t, &card->transaction_list, link) { | 742 | list_for_each_entry(t, &card->transaction_list, link) { |
744 | if (t->node_id == source && t->tlabel == tlabel) { | 743 | if (t->node_id == source && t->tlabel == tlabel) { |
745 | list_del(&t->link); | 744 | list_del(&t->link); |
746 | card->tlabel_mask &= ~(1 << t->tlabel); | 745 | card->tlabel_mask &= ~(1 << t->tlabel); |
747 | break; | 746 | break; |
748 | } | 747 | } |
749 | } | 748 | } |
750 | spin_unlock_irqrestore(&card->lock, flags); | 749 | spin_unlock_irqrestore(&card->lock, flags); |
751 | 750 | ||
752 | if (&t->link == &card->transaction_list) { | 751 | if (&t->link == &card->transaction_list) { |
753 | fw_notify("Unsolicited response (source %x, tlabel %x)\n", | 752 | fw_notify("Unsolicited response (source %x, tlabel %x)\n", |
754 | source, tlabel); | 753 | source, tlabel); |
755 | return; | 754 | return; |
756 | } | 755 | } |
757 | 756 | ||
758 | /* | 757 | /* |
759 | * FIXME: sanity check packet, is length correct, does tcodes | 758 | * FIXME: sanity check packet, is length correct, does tcodes |
760 | * and addresses match. | 759 | * and addresses match. |
761 | */ | 760 | */ |
762 | 761 | ||
763 | switch (tcode) { | 762 | switch (tcode) { |
764 | case TCODE_READ_QUADLET_RESPONSE: | 763 | case TCODE_READ_QUADLET_RESPONSE: |
765 | data = (u32 *) &p->header[3]; | 764 | data = (u32 *) &p->header[3]; |
766 | data_length = 4; | 765 | data_length = 4; |
767 | break; | 766 | break; |
768 | 767 | ||
769 | case TCODE_WRITE_RESPONSE: | 768 | case TCODE_WRITE_RESPONSE: |
770 | data = NULL; | 769 | data = NULL; |
771 | data_length = 0; | 770 | data_length = 0; |
772 | break; | 771 | break; |
773 | 772 | ||
774 | case TCODE_READ_BLOCK_RESPONSE: | 773 | case TCODE_READ_BLOCK_RESPONSE: |
775 | case TCODE_LOCK_RESPONSE: | 774 | case TCODE_LOCK_RESPONSE: |
776 | data = p->payload; | 775 | data = p->payload; |
777 | data_length = HEADER_GET_DATA_LENGTH(p->header[3]); | 776 | data_length = HEADER_GET_DATA_LENGTH(p->header[3]); |
778 | break; | 777 | break; |
779 | 778 | ||
780 | default: | 779 | default: |
781 | /* Should never happen, this is just to shut up gcc. */ | 780 | /* Should never happen, this is just to shut up gcc. */ |
782 | data = NULL; | 781 | data = NULL; |
783 | data_length = 0; | 782 | data_length = 0; |
784 | break; | 783 | break; |
785 | } | 784 | } |
786 | 785 | ||
787 | /* | 786 | /* |
788 | * The response handler may be executed while the request handler | 787 | * The response handler may be executed while the request handler |
789 | * is still pending. Cancel the request handler. | 788 | * is still pending. Cancel the request handler. |
790 | */ | 789 | */ |
791 | card->driver->cancel_packet(card, &t->packet); | 790 | card->driver->cancel_packet(card, &t->packet); |
792 | 791 | ||
793 | t->callback(card, rcode, data, data_length, t->callback_data); | 792 | t->callback(card, rcode, data, data_length, t->callback_data); |
794 | } | 793 | } |
795 | EXPORT_SYMBOL(fw_core_handle_response); | 794 | EXPORT_SYMBOL(fw_core_handle_response); |
796 | 795 | ||
797 | static const struct fw_address_region topology_map_region = | 796 | static const struct fw_address_region topology_map_region = |
798 | { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP, | 797 | { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP, |
799 | .end = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, }; | 798 | .end = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, }; |
800 | 799 | ||
801 | static void handle_topology_map(struct fw_card *card, struct fw_request *request, | 800 | static void handle_topology_map(struct fw_card *card, struct fw_request *request, |
802 | int tcode, int destination, int source, int generation, | 801 | int tcode, int destination, int source, int generation, |
803 | int speed, unsigned long long offset, | 802 | int speed, unsigned long long offset, |
804 | void *payload, size_t length, void *callback_data) | 803 | void *payload, size_t length, void *callback_data) |
805 | { | 804 | { |
806 | int i, start, end; | 805 | int i, start, end; |
807 | __be32 *map; | 806 | __be32 *map; |
808 | 807 | ||
809 | if (!TCODE_IS_READ_REQUEST(tcode)) { | 808 | if (!TCODE_IS_READ_REQUEST(tcode)) { |
810 | fw_send_response(card, request, RCODE_TYPE_ERROR); | 809 | fw_send_response(card, request, RCODE_TYPE_ERROR); |
811 | return; | 810 | return; |
812 | } | 811 | } |
813 | 812 | ||
814 | if ((offset & 3) > 0 || (length & 3) > 0) { | 813 | if ((offset & 3) > 0 || (length & 3) > 0) { |
815 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | 814 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); |
816 | return; | 815 | return; |
817 | } | 816 | } |
818 | 817 | ||
819 | start = (offset - topology_map_region.start) / 4; | 818 | start = (offset - topology_map_region.start) / 4; |
820 | end = start + length / 4; | 819 | end = start + length / 4; |
821 | map = payload; | 820 | map = payload; |
822 | 821 | ||
823 | for (i = 0; i < length / 4; i++) | 822 | for (i = 0; i < length / 4; i++) |
824 | map[i] = cpu_to_be32(card->topology_map[start + i]); | 823 | map[i] = cpu_to_be32(card->topology_map[start + i]); |
825 | 824 | ||
826 | fw_send_response(card, request, RCODE_COMPLETE); | 825 | fw_send_response(card, request, RCODE_COMPLETE); |
827 | } | 826 | } |
828 | 827 | ||
829 | static struct fw_address_handler topology_map = { | 828 | static struct fw_address_handler topology_map = { |
830 | .length = 0x200, | 829 | .length = 0x200, |
831 | .address_callback = handle_topology_map, | 830 | .address_callback = handle_topology_map, |
832 | }; | 831 | }; |
833 | 832 | ||
834 | static const struct fw_address_region registers_region = | 833 | static const struct fw_address_region registers_region = |
835 | { .start = CSR_REGISTER_BASE, | 834 | { .start = CSR_REGISTER_BASE, |
836 | .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM, }; | 835 | .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM, }; |
837 | 836 | ||
838 | static void handle_registers(struct fw_card *card, struct fw_request *request, | 837 | static void handle_registers(struct fw_card *card, struct fw_request *request, |
839 | int tcode, int destination, int source, int generation, | 838 | int tcode, int destination, int source, int generation, |
840 | int speed, unsigned long long offset, | 839 | int speed, unsigned long long offset, |
841 | void *payload, size_t length, void *callback_data) | 840 | void *payload, size_t length, void *callback_data) |
842 | { | 841 | { |
843 | int reg = offset & ~CSR_REGISTER_BASE; | 842 | int reg = offset & ~CSR_REGISTER_BASE; |
844 | unsigned long long bus_time; | 843 | unsigned long long bus_time; |
845 | __be32 *data = payload; | 844 | __be32 *data = payload; |
846 | int rcode = RCODE_COMPLETE; | 845 | int rcode = RCODE_COMPLETE; |
847 | 846 | ||
848 | switch (reg) { | 847 | switch (reg) { |
849 | case CSR_CYCLE_TIME: | 848 | case CSR_CYCLE_TIME: |
850 | case CSR_BUS_TIME: | 849 | case CSR_BUS_TIME: |
851 | if (!TCODE_IS_READ_REQUEST(tcode) || length != 4) { | 850 | if (!TCODE_IS_READ_REQUEST(tcode) || length != 4) { |
852 | rcode = RCODE_TYPE_ERROR; | 851 | rcode = RCODE_TYPE_ERROR; |
853 | break; | 852 | break; |
854 | } | 853 | } |
855 | 854 | ||
856 | bus_time = card->driver->get_bus_time(card); | 855 | bus_time = card->driver->get_bus_time(card); |
857 | if (reg == CSR_CYCLE_TIME) | 856 | if (reg == CSR_CYCLE_TIME) |
858 | *data = cpu_to_be32(bus_time); | 857 | *data = cpu_to_be32(bus_time); |
859 | else | 858 | else |
860 | *data = cpu_to_be32(bus_time >> 25); | 859 | *data = cpu_to_be32(bus_time >> 25); |
861 | break; | 860 | break; |
862 | 861 | ||
863 | case CSR_BROADCAST_CHANNEL: | 862 | case CSR_BROADCAST_CHANNEL: |
864 | if (tcode == TCODE_READ_QUADLET_REQUEST) | 863 | if (tcode == TCODE_READ_QUADLET_REQUEST) |
865 | *data = cpu_to_be32(card->broadcast_channel); | 864 | *data = cpu_to_be32(card->broadcast_channel); |
866 | else if (tcode == TCODE_WRITE_QUADLET_REQUEST) | 865 | else if (tcode == TCODE_WRITE_QUADLET_REQUEST) |
867 | card->broadcast_channel = | 866 | card->broadcast_channel = |
868 | (be32_to_cpu(*data) & BROADCAST_CHANNEL_VALID) | | 867 | (be32_to_cpu(*data) & BROADCAST_CHANNEL_VALID) | |
869 | BROADCAST_CHANNEL_INITIAL; | 868 | BROADCAST_CHANNEL_INITIAL; |
870 | else | 869 | else |
871 | rcode = RCODE_TYPE_ERROR; | 870 | rcode = RCODE_TYPE_ERROR; |
872 | break; | 871 | break; |
873 | 872 | ||
874 | case CSR_BUS_MANAGER_ID: | 873 | case CSR_BUS_MANAGER_ID: |
875 | case CSR_BANDWIDTH_AVAILABLE: | 874 | case CSR_BANDWIDTH_AVAILABLE: |
876 | case CSR_CHANNELS_AVAILABLE_HI: | 875 | case CSR_CHANNELS_AVAILABLE_HI: |
877 | case CSR_CHANNELS_AVAILABLE_LO: | 876 | case CSR_CHANNELS_AVAILABLE_LO: |
878 | /* | 877 | /* |
879 | * FIXME: these are handled by the OHCI hardware and | 878 | * FIXME: these are handled by the OHCI hardware and |
880 | * the stack never sees these request. If we add | 879 | * the stack never sees these request. If we add |
881 | * support for a new type of controller that doesn't | 880 | * support for a new type of controller that doesn't |
882 | * handle this in hardware we need to deal with these | 881 | * handle this in hardware we need to deal with these |
883 | * transactions. | 882 | * transactions. |
884 | */ | 883 | */ |
885 | BUG(); | 884 | BUG(); |
886 | break; | 885 | break; |
887 | 886 | ||
888 | case CSR_BUSY_TIMEOUT: | 887 | case CSR_BUSY_TIMEOUT: |
889 | /* FIXME: Implement this. */ | 888 | /* FIXME: Implement this. */ |
890 | 889 | ||
891 | default: | 890 | default: |
892 | rcode = RCODE_ADDRESS_ERROR; | 891 | rcode = RCODE_ADDRESS_ERROR; |
893 | break; | 892 | break; |
894 | } | 893 | } |
895 | 894 | ||
896 | fw_send_response(card, request, rcode); | 895 | fw_send_response(card, request, rcode); |
897 | } | 896 | } |
898 | 897 | ||
899 | static struct fw_address_handler registers = { | 898 | static struct fw_address_handler registers = { |
900 | .length = 0x400, | 899 | .length = 0x400, |
901 | .address_callback = handle_registers, | 900 | .address_callback = handle_registers, |
902 | }; | 901 | }; |
903 | 902 | ||
904 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | 903 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |
905 | MODULE_DESCRIPTION("Core IEEE1394 transaction logic"); | 904 | MODULE_DESCRIPTION("Core IEEE1394 transaction logic"); |
906 | MODULE_LICENSE("GPL"); | 905 | MODULE_LICENSE("GPL"); |
907 | 906 | ||
908 | static const u32 vendor_textual_descriptor[] = { | 907 | static const u32 vendor_textual_descriptor[] = { |
909 | /* textual descriptor leaf () */ | 908 | /* textual descriptor leaf () */ |
910 | 0x00060000, | 909 | 0x00060000, |
911 | 0x00000000, | 910 | 0x00000000, |
912 | 0x00000000, | 911 | 0x00000000, |
913 | 0x4c696e75, /* L i n u */ | 912 | 0x4c696e75, /* L i n u */ |
914 | 0x78204669, /* x F i */ | 913 | 0x78204669, /* x F i */ |
915 | 0x72657769, /* r e w i */ | 914 | 0x72657769, /* r e w i */ |
916 | 0x72650000, /* r e */ | 915 | 0x72650000, /* r e */ |
917 | }; | 916 | }; |
918 | 917 | ||
919 | static const u32 model_textual_descriptor[] = { | 918 | static const u32 model_textual_descriptor[] = { |
920 | /* model descriptor leaf () */ | 919 | /* model descriptor leaf () */ |
921 | 0x00030000, | 920 | 0x00030000, |
922 | 0x00000000, | 921 | 0x00000000, |
923 | 0x00000000, | 922 | 0x00000000, |
924 | 0x4a756a75, /* J u j u */ | 923 | 0x4a756a75, /* J u j u */ |
925 | }; | 924 | }; |
926 | 925 | ||
927 | static struct fw_descriptor vendor_id_descriptor = { | 926 | static struct fw_descriptor vendor_id_descriptor = { |
928 | .length = ARRAY_SIZE(vendor_textual_descriptor), | 927 | .length = ARRAY_SIZE(vendor_textual_descriptor), |
929 | .immediate = 0x03d00d1e, | 928 | .immediate = 0x03d00d1e, |
930 | .key = 0x81000000, | 929 | .key = 0x81000000, |
931 | .data = vendor_textual_descriptor, | 930 | .data = vendor_textual_descriptor, |
932 | }; | 931 | }; |
933 | 932 | ||
934 | static struct fw_descriptor model_id_descriptor = { | 933 | static struct fw_descriptor model_id_descriptor = { |
935 | .length = ARRAY_SIZE(model_textual_descriptor), | 934 | .length = ARRAY_SIZE(model_textual_descriptor), |
936 | .immediate = 0x17000001, | 935 | .immediate = 0x17000001, |
937 | .key = 0x81000000, | 936 | .key = 0x81000000, |
938 | .data = model_textual_descriptor, | 937 | .data = model_textual_descriptor, |
939 | }; | 938 | }; |
940 | 939 | ||
941 | static int __init fw_core_init(void) | 940 | static int __init fw_core_init(void) |
942 | { | 941 | { |
943 | int ret; | 942 | int ret; |
944 | 943 | ||
945 | ret = bus_register(&fw_bus_type); | 944 | ret = bus_register(&fw_bus_type); |
946 | if (ret < 0) | 945 | if (ret < 0) |
947 | return ret; | 946 | return ret; |
948 | 947 | ||
949 | fw_cdev_major = register_chrdev(0, "firewire", &fw_device_ops); | 948 | fw_cdev_major = register_chrdev(0, "firewire", &fw_device_ops); |
950 | if (fw_cdev_major < 0) { | 949 | if (fw_cdev_major < 0) { |
951 | bus_unregister(&fw_bus_type); | 950 | bus_unregister(&fw_bus_type); |
952 | return fw_cdev_major; | 951 | return fw_cdev_major; |
953 | } | 952 | } |
954 | 953 | ||
955 | fw_core_add_address_handler(&topology_map, &topology_map_region); | 954 | fw_core_add_address_handler(&topology_map, &topology_map_region); |
956 | fw_core_add_address_handler(®isters, ®isters_region); | 955 | fw_core_add_address_handler(®isters, ®isters_region); |
957 | fw_core_add_descriptor(&vendor_id_descriptor); | 956 | fw_core_add_descriptor(&vendor_id_descriptor); |
958 | fw_core_add_descriptor(&model_id_descriptor); | 957 | fw_core_add_descriptor(&model_id_descriptor); |
959 | 958 | ||
960 | return 0; | 959 | return 0; |
961 | } | 960 | } |
962 | 961 | ||
963 | static void __exit fw_core_cleanup(void) | 962 | static void __exit fw_core_cleanup(void) |
964 | { | 963 | { |
965 | unregister_chrdev(fw_cdev_major, "firewire"); | 964 | unregister_chrdev(fw_cdev_major, "firewire"); |
966 | bus_unregister(&fw_bus_type); | 965 | bus_unregister(&fw_bus_type); |
967 | idr_destroy(&fw_device_idr); | 966 | idr_destroy(&fw_device_idr); |
968 | } | 967 | } |
969 | 968 | ||
970 | module_init(fw_core_init); | 969 | module_init(fw_core_init); |
971 | module_exit(fw_core_cleanup); | 970 | module_exit(fw_core_cleanup); |
972 | 971 |