diff options
author | Kristian Høgsberg <krh@redhat.com> | 2006-12-19 19:58:31 -0500 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2007-03-09 16:02:33 -0500 |
commit | 19a15b937b26638933307bb02f7b1801310d6eb2 (patch) | |
tree | 817efaa8c1d2f4633fa811ba27fa1aee7f00c352 /drivers/firewire | |
parent | 3038e353cfaf548eb94f02b172b9dbe412abd24c (diff) |
firewire: Add device probing and sysfs integration.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/Makefile | 3 | ||||
-rw-r--r-- | drivers/firewire/fw-card.c | 56 | ||||
-rw-r--r-- | drivers/firewire/fw-device-cdev.c | 617 | ||||
-rw-r--r-- | drivers/firewire/fw-device-cdev.h | 146 | ||||
-rw-r--r-- | drivers/firewire/fw-device.c | 613 | ||||
-rw-r--r-- | drivers/firewire/fw-device.h | 127 | ||||
-rw-r--r-- | drivers/firewire/fw-iso.c | 1 | ||||
-rw-r--r-- | drivers/firewire/fw-topology.c | 10 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.c | 5 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.h | 4 |
10 files changed, 1573 insertions, 9 deletions
diff --git a/drivers/firewire/Makefile b/drivers/firewire/Makefile index db7020dd02af..da77bc0501e4 100644 --- a/drivers/firewire/Makefile +++ b/drivers/firewire/Makefile | |||
@@ -2,6 +2,7 @@ | |||
2 | # Makefile for the Linux IEEE 1394 implementation | 2 | # Makefile for the Linux IEEE 1394 implementation |
3 | # | 3 | # |
4 | 4 | ||
5 | fw-core-objs := fw-card.o fw-topology.o fw-transaction.o fw-iso.o | 5 | fw-core-objs := fw-card.o fw-topology.o fw-transaction.o fw-iso.o \ |
6 | fw-device.o fw-device-cdev.o | ||
6 | 7 | ||
7 | obj-$(CONFIG_FW) += fw-core.o | 8 | obj-$(CONFIG_FW) += fw-core.o |
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index d8abd70ce843..79773907e10d 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include "fw-transaction.h" | 25 | #include "fw-transaction.h" |
26 | #include "fw-topology.h" | 26 | #include "fw-topology.h" |
27 | #include "fw-device.h" | ||
27 | 28 | ||
28 | /* The lib/crc16.c implementation uses the standard (0x8005) | 29 | /* The lib/crc16.c implementation uses the standard (0x8005) |
29 | * polynomial, but we need the ITU-T (or CCITT) polynomial (0x1021). | 30 | * polynomial, but we need the ITU-T (or CCITT) polynomial (0x1021). |
@@ -186,6 +187,59 @@ fw_core_remove_descriptor (struct fw_descriptor *desc) | |||
186 | EXPORT_SYMBOL(fw_core_remove_descriptor); | 187 | EXPORT_SYMBOL(fw_core_remove_descriptor); |
187 | 188 | ||
188 | static void | 189 | static void |
190 | fw_card_irm_work(struct work_struct *work) | ||
191 | { | ||
192 | struct fw_card *card = | ||
193 | container_of(work, struct fw_card, work.work); | ||
194 | struct fw_device *root; | ||
195 | unsigned long flags; | ||
196 | int new_irm_id, generation; | ||
197 | |||
198 | /* FIXME: This simple bus management unconditionally picks a | ||
199 | * cycle master if the current root can't do it. We need to | ||
200 | * not do this if there is a bus manager already. Also, some | ||
201 | * hubs set the contender bit, which is bogus, so we should | ||
202 | * probably do a little sanity check on the IRM (like, read | ||
203 | * the bandwidth register) if it's not us. */ | ||
204 | |||
205 | spin_lock_irqsave(&card->lock, flags); | ||
206 | |||
207 | generation = card->generation; | ||
208 | root = card->root_node->data; | ||
209 | |||
210 | if (root == NULL) | ||
211 | /* Either link_on is false, or we failed to read the | ||
212 | * config rom. In either case, pick another root. */ | ||
213 | new_irm_id = card->local_node->node_id; | ||
214 | else if (root->state != FW_DEVICE_RUNNING) | ||
215 | /* If we haven't probed this device yet, bail out now | ||
216 | * and let's try again once that's done. */ | ||
217 | new_irm_id = -1; | ||
218 | else if (root->config_rom[2] & bib_cmc) | ||
219 | /* FIXME: I suppose we should set the cmstr bit in the | ||
220 | * STATE_CLEAR register of this node, as described in | ||
221 | * 1394-1995, 8.4.2.6. Also, send out a force root | ||
222 | * packet for this node. */ | ||
223 | new_irm_id = -1; | ||
224 | else | ||
225 | /* Current root has an active link layer and we | ||
226 | * successfully read the config rom, but it's not | ||
227 | * cycle master capable. */ | ||
228 | new_irm_id = card->local_node->node_id; | ||
229 | |||
230 | if (card->irm_retries++ > 5) | ||
231 | new_irm_id = -1; | ||
232 | |||
233 | spin_unlock_irqrestore(&card->lock, flags); | ||
234 | |||
235 | if (new_irm_id > 0) { | ||
236 | fw_notify("Trying to become root (card %d)\n", card->index); | ||
237 | fw_send_force_root(card, new_irm_id, generation); | ||
238 | fw_core_initiate_bus_reset(card, 1); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | static void | ||
189 | release_card(struct device *device) | 243 | release_card(struct device *device) |
190 | { | 244 | { |
191 | struct fw_card *card = | 245 | struct fw_card *card = |
@@ -222,6 +276,8 @@ fw_card_initialize(struct fw_card *card, struct fw_card_driver *driver, | |||
222 | 276 | ||
223 | card->local_node = NULL; | 277 | card->local_node = NULL; |
224 | 278 | ||
279 | INIT_DELAYED_WORK(&card->work, fw_card_irm_work); | ||
280 | |||
225 | card->card_device.bus = &fw_bus_type; | 281 | card->card_device.bus = &fw_bus_type; |
226 | card->card_device.release = release_card; | 282 | card->card_device.release = release_card; |
227 | card->card_device.parent = card->device; | 283 | card->card_device.parent = card->device; |
diff --git a/drivers/firewire/fw-device-cdev.c b/drivers/firewire/fw-device-cdev.c new file mode 100644 index 000000000000..c10e3326abf3 --- /dev/null +++ b/drivers/firewire/fw-device-cdev.c | |||
@@ -0,0 +1,617 @@ | |||
1 | /* -*- c-basic-offset: 8 -*- | ||
2 | * | ||
3 | * fw-device-cdev.c - Char device for device raw access | ||
4 | * | ||
5 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software Foundation, | ||
19 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/wait.h> | ||
25 | #include <linux/errno.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/vmalloc.h> | ||
28 | #include <linux/poll.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/mm.h> | ||
31 | #include <linux/compat.h> | ||
32 | #include <asm/uaccess.h> | ||
33 | #include "fw-transaction.h" | ||
34 | #include "fw-topology.h" | ||
35 | #include "fw-device.h" | ||
36 | #include "fw-device-cdev.h" | ||
37 | |||
38 | /* | ||
39 | * todo | ||
40 | * | ||
41 | * - bus resets sends a new packet with new generation and node id | ||
42 | * | ||
43 | */ | ||
44 | |||
45 | /* dequeue_event() just kfree()'s the event, so the event has to be | ||
46 | * the first field in the struct. */ | ||
47 | |||
48 | struct event { | ||
49 | struct { void *data; size_t size; } v[2]; | ||
50 | struct list_head link; | ||
51 | }; | ||
52 | |||
53 | struct response { | ||
54 | struct event event; | ||
55 | struct fw_transaction transaction; | ||
56 | struct client *client; | ||
57 | struct fw_cdev_event_response response; | ||
58 | }; | ||
59 | |||
60 | struct iso_interrupt { | ||
61 | struct event event; | ||
62 | struct fw_cdev_event_iso_interrupt interrupt; | ||
63 | }; | ||
64 | |||
65 | struct client { | ||
66 | struct fw_device *device; | ||
67 | spinlock_t lock; | ||
68 | struct list_head handler_list; | ||
69 | struct list_head request_list; | ||
70 | u32 request_serial; | ||
71 | struct list_head event_list; | ||
72 | struct semaphore event_list_sem; | ||
73 | wait_queue_head_t wait; | ||
74 | unsigned long vm_start; | ||
75 | struct fw_iso_context *iso_context; | ||
76 | }; | ||
77 | |||
78 | static inline void __user * | ||
79 | u64_to_uptr(__u64 value) | ||
80 | { | ||
81 | return (void __user *)(unsigned long)value; | ||
82 | } | ||
83 | |||
84 | static inline __u64 | ||
85 | uptr_to_u64(void __user *ptr) | ||
86 | { | ||
87 | return (__u64)(unsigned long)ptr; | ||
88 | } | ||
89 | |||
90 | static int fw_device_op_open(struct inode *inode, struct file *file) | ||
91 | { | ||
92 | struct fw_device *device; | ||
93 | struct client *client; | ||
94 | |||
95 | device = container_of(inode->i_cdev, struct fw_device, cdev); | ||
96 | |||
97 | client = kzalloc(sizeof *client, GFP_KERNEL); | ||
98 | if (client == NULL) | ||
99 | return -ENOMEM; | ||
100 | |||
101 | client->device = fw_device_get(device); | ||
102 | INIT_LIST_HEAD(&client->event_list); | ||
103 | sema_init(&client->event_list_sem, 0); | ||
104 | INIT_LIST_HEAD(&client->handler_list); | ||
105 | INIT_LIST_HEAD(&client->request_list); | ||
106 | spin_lock_init(&client->lock); | ||
107 | init_waitqueue_head(&client->wait); | ||
108 | |||
109 | file->private_data = client; | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static void queue_event(struct client *client, struct event *event, | ||
115 | void *data0, size_t size0, void *data1, size_t size1) | ||
116 | { | ||
117 | unsigned long flags; | ||
118 | |||
119 | event->v[0].data = data0; | ||
120 | event->v[0].size = size0; | ||
121 | event->v[1].data = data1; | ||
122 | event->v[1].size = size1; | ||
123 | |||
124 | spin_lock_irqsave(&client->lock, flags); | ||
125 | |||
126 | list_add_tail(&event->link, &client->event_list); | ||
127 | |||
128 | up(&client->event_list_sem); | ||
129 | wake_up_interruptible(&client->wait); | ||
130 | |||
131 | spin_unlock_irqrestore(&client->lock, flags); | ||
132 | } | ||
133 | |||
134 | static int dequeue_event(struct client *client, char __user *buffer, size_t count) | ||
135 | { | ||
136 | unsigned long flags; | ||
137 | struct event *event; | ||
138 | size_t size, total; | ||
139 | int i, retval = -EFAULT; | ||
140 | |||
141 | if (down_interruptible(&client->event_list_sem) < 0) | ||
142 | return -EINTR; | ||
143 | |||
144 | spin_lock_irqsave(&client->lock, flags); | ||
145 | |||
146 | event = container_of(client->event_list.next, struct event, link); | ||
147 | list_del(&event->link); | ||
148 | |||
149 | spin_unlock_irqrestore(&client->lock, flags); | ||
150 | |||
151 | if (buffer == NULL) | ||
152 | goto out; | ||
153 | |||
154 | total = 0; | ||
155 | for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) { | ||
156 | size = min(event->v[i].size, count - total); | ||
157 | if (copy_to_user(buffer + total, event->v[i].data, size)) | ||
158 | goto out; | ||
159 | total += size; | ||
160 | } | ||
161 | retval = total; | ||
162 | |||
163 | out: | ||
164 | kfree(event); | ||
165 | |||
166 | return retval; | ||
167 | } | ||
168 | |||
169 | static ssize_t | ||
170 | fw_device_op_read(struct file *file, | ||
171 | char __user *buffer, size_t count, loff_t *offset) | ||
172 | { | ||
173 | struct client *client = file->private_data; | ||
174 | |||
175 | return dequeue_event(client, buffer, count); | ||
176 | } | ||
177 | |||
178 | static int ioctl_config_rom(struct client *client, void __user *arg) | ||
179 | { | ||
180 | struct fw_cdev_get_config_rom rom; | ||
181 | |||
182 | rom.length = client->device->config_rom_length; | ||
183 | memcpy(rom.data, client->device->config_rom, rom.length * 4); | ||
184 | if (copy_to_user(arg, &rom, | ||
185 | (char *)&rom.data[rom.length] - (char *)&rom)) | ||
186 | return -EFAULT; | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static void | ||
192 | complete_transaction(struct fw_card *card, int rcode, | ||
193 | void *payload, size_t length, void *data) | ||
194 | { | ||
195 | struct response *response = data; | ||
196 | struct client *client = response->client; | ||
197 | |||
198 | if (length < response->response.length) | ||
199 | response->response.length = length; | ||
200 | if (rcode == RCODE_COMPLETE) | ||
201 | memcpy(response->response.data, payload, | ||
202 | response->response.length); | ||
203 | |||
204 | response->response.type = FW_CDEV_EVENT_RESPONSE; | ||
205 | response->response.rcode = rcode; | ||
206 | queue_event(client, &response->event, | ||
207 | &response->response, sizeof response->response, | ||
208 | response->response.data, response->response.length); | ||
209 | } | ||
210 | |||
211 | static ssize_t ioctl_send_request(struct client *client, void __user *arg) | ||
212 | { | ||
213 | struct fw_device *device = client->device; | ||
214 | struct fw_cdev_send_request request; | ||
215 | struct response *response; | ||
216 | |||
217 | if (copy_from_user(&request, arg, sizeof request)) | ||
218 | return -EFAULT; | ||
219 | |||
220 | /* What is the biggest size we'll accept, really? */ | ||
221 | if (request.length > 4096) | ||
222 | return -EINVAL; | ||
223 | |||
224 | response = kmalloc(sizeof *response + request.length, GFP_KERNEL); | ||
225 | if (response == NULL) | ||
226 | return -ENOMEM; | ||
227 | |||
228 | response->client = client; | ||
229 | response->response.length = request.length; | ||
230 | response->response.closure = request.closure; | ||
231 | |||
232 | if (request.data && | ||
233 | copy_from_user(response->response.data, | ||
234 | u64_to_uptr(request.data), request.length)) { | ||
235 | kfree(response); | ||
236 | return -EFAULT; | ||
237 | } | ||
238 | |||
239 | fw_send_request(device->card, &response->transaction, | ||
240 | request.tcode, | ||
241 | device->node->node_id | LOCAL_BUS, | ||
242 | device->card->generation, | ||
243 | device->node->max_speed, | ||
244 | request.offset, | ||
245 | response->response.data, request.length, | ||
246 | complete_transaction, response); | ||
247 | |||
248 | if (request.data) | ||
249 | return sizeof request + request.length; | ||
250 | else | ||
251 | return sizeof request; | ||
252 | } | ||
253 | |||
254 | struct address_handler { | ||
255 | struct fw_address_handler handler; | ||
256 | __u64 closure; | ||
257 | struct client *client; | ||
258 | struct list_head link; | ||
259 | }; | ||
260 | |||
261 | struct request { | ||
262 | struct fw_request *request; | ||
263 | void *data; | ||
264 | size_t length; | ||
265 | u32 serial; | ||
266 | struct list_head link; | ||
267 | }; | ||
268 | |||
269 | struct request_event { | ||
270 | struct event event; | ||
271 | struct fw_cdev_event_request request; | ||
272 | }; | ||
273 | |||
274 | static void | ||
275 | handle_request(struct fw_card *card, struct fw_request *r, | ||
276 | int tcode, int destination, int source, | ||
277 | int generation, int speed, | ||
278 | unsigned long long offset, | ||
279 | void *payload, size_t length, void *callback_data) | ||
280 | { | ||
281 | struct address_handler *handler = callback_data; | ||
282 | struct request *request; | ||
283 | struct request_event *e; | ||
284 | unsigned long flags; | ||
285 | struct client *client = handler->client; | ||
286 | |||
287 | request = kmalloc(sizeof *request, GFP_ATOMIC); | ||
288 | e = kmalloc(sizeof *e, GFP_ATOMIC); | ||
289 | if (request == NULL || e == NULL) { | ||
290 | kfree(request); | ||
291 | kfree(e); | ||
292 | fw_send_response(card, r, RCODE_CONFLICT_ERROR); | ||
293 | return; | ||
294 | } | ||
295 | |||
296 | request->request = r; | ||
297 | request->data = payload; | ||
298 | request->length = length; | ||
299 | |||
300 | spin_lock_irqsave(&client->lock, flags); | ||
301 | request->serial = client->request_serial++; | ||
302 | list_add_tail(&request->link, &client->request_list); | ||
303 | spin_unlock_irqrestore(&client->lock, flags); | ||
304 | |||
305 | e->request.type = FW_CDEV_EVENT_REQUEST; | ||
306 | e->request.tcode = tcode; | ||
307 | e->request.offset = offset; | ||
308 | e->request.length = length; | ||
309 | e->request.serial = request->serial; | ||
310 | e->request.closure = handler->closure; | ||
311 | |||
312 | queue_event(client, &e->event, | ||
313 | &e->request, sizeof e->request, payload, length); | ||
314 | } | ||
315 | |||
316 | static int ioctl_allocate(struct client *client, void __user *arg) | ||
317 | { | ||
318 | struct fw_cdev_allocate request; | ||
319 | struct address_handler *handler; | ||
320 | unsigned long flags; | ||
321 | struct fw_address_region region; | ||
322 | |||
323 | if (copy_from_user(&request, arg, sizeof request)) | ||
324 | return -EFAULT; | ||
325 | |||
326 | handler = kmalloc(sizeof *handler, GFP_KERNEL); | ||
327 | if (handler == NULL) | ||
328 | return -ENOMEM; | ||
329 | |||
330 | region.start = request.offset; | ||
331 | region.end = request.offset + request.length; | ||
332 | handler->handler.length = request.length; | ||
333 | handler->handler.address_callback = handle_request; | ||
334 | handler->handler.callback_data = handler; | ||
335 | handler->closure = request.closure; | ||
336 | handler->client = client; | ||
337 | |||
338 | if (fw_core_add_address_handler(&handler->handler, ®ion) < 0) { | ||
339 | kfree(handler); | ||
340 | return -EBUSY; | ||
341 | } | ||
342 | |||
343 | spin_lock_irqsave(&client->lock, flags); | ||
344 | list_add_tail(&handler->link, &client->handler_list); | ||
345 | spin_unlock_irqrestore(&client->lock, flags); | ||
346 | |||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | static int ioctl_send_response(struct client *client, void __user *arg) | ||
351 | { | ||
352 | struct fw_cdev_send_response request; | ||
353 | struct request *r; | ||
354 | unsigned long flags; | ||
355 | |||
356 | if (copy_from_user(&request, arg, sizeof request)) | ||
357 | return -EFAULT; | ||
358 | |||
359 | spin_lock_irqsave(&client->lock, flags); | ||
360 | list_for_each_entry(r, &client->request_list, link) { | ||
361 | if (r->serial == request.serial) { | ||
362 | list_del(&r->link); | ||
363 | break; | ||
364 | } | ||
365 | } | ||
366 | spin_unlock_irqrestore(&client->lock, flags); | ||
367 | |||
368 | if (&r->link == &client->request_list) | ||
369 | return -EINVAL; | ||
370 | |||
371 | if (request.length < r->length) | ||
372 | r->length = request.length; | ||
373 | if (copy_from_user(r->data, u64_to_uptr(request.data), r->length)) | ||
374 | return -EFAULT; | ||
375 | |||
376 | fw_send_response(client->device->card, r->request, request.rcode); | ||
377 | |||
378 | kfree(r); | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static void | ||
384 | iso_callback(struct fw_iso_context *context, int status, u32 cycle, void *data) | ||
385 | { | ||
386 | struct client *client = data; | ||
387 | struct iso_interrupt *interrupt; | ||
388 | |||
389 | interrupt = kzalloc(sizeof *interrupt, GFP_ATOMIC); | ||
390 | if (interrupt == NULL) | ||
391 | return; | ||
392 | |||
393 | interrupt->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; | ||
394 | interrupt->interrupt.closure = 0; | ||
395 | interrupt->interrupt.cycle = cycle; | ||
396 | queue_event(client, &interrupt->event, | ||
397 | &interrupt->interrupt, sizeof interrupt->interrupt, NULL, 0); | ||
398 | } | ||
399 | |||
400 | static int ioctl_create_iso_context(struct client *client, void __user *arg) | ||
401 | { | ||
402 | struct fw_cdev_create_iso_context request; | ||
403 | |||
404 | if (copy_from_user(&request, arg, sizeof request)) | ||
405 | return -EFAULT; | ||
406 | |||
407 | client->iso_context = fw_iso_context_create(client->device->card, | ||
408 | FW_ISO_CONTEXT_TRANSMIT, | ||
409 | request.buffer_size, | ||
410 | iso_callback, client); | ||
411 | if (IS_ERR(client->iso_context)) | ||
412 | return PTR_ERR(client->iso_context); | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | static int ioctl_queue_iso(struct client *client, void __user *arg) | ||
418 | { | ||
419 | struct fw_cdev_queue_iso request; | ||
420 | struct fw_cdev_iso_packet __user *p, *end, *next; | ||
421 | void *payload, *payload_end; | ||
422 | unsigned long index; | ||
423 | int count; | ||
424 | struct { | ||
425 | struct fw_iso_packet packet; | ||
426 | u8 header[256]; | ||
427 | } u; | ||
428 | |||
429 | if (client->iso_context == NULL) | ||
430 | return -EINVAL; | ||
431 | if (copy_from_user(&request, arg, sizeof request)) | ||
432 | return -EFAULT; | ||
433 | |||
434 | /* If the user passes a non-NULL data pointer, has mmap()'ed | ||
435 | * the iso buffer, and the pointer points inside the buffer, | ||
436 | * we setup the payload pointers accordingly. Otherwise we | ||
437 | * set them both to NULL, which will still let packets with | ||
438 | * payload_length == 0 through. In other words, if no packets | ||
439 | * use the indirect payload, the iso buffer need not be mapped | ||
440 | * and the request.data pointer is ignored.*/ | ||
441 | |||
442 | index = (unsigned long)request.data - client->vm_start; | ||
443 | if (request.data != 0 && client->vm_start != 0 && | ||
444 | index <= client->iso_context->buffer_size) { | ||
445 | payload = client->iso_context->buffer + index; | ||
446 | payload_end = client->iso_context->buffer + | ||
447 | client->iso_context->buffer_size; | ||
448 | } else { | ||
449 | payload = NULL; | ||
450 | payload_end = NULL; | ||
451 | } | ||
452 | |||
453 | if (!access_ok(VERIFY_READ, request.packets, request.size)) | ||
454 | return -EFAULT; | ||
455 | |||
456 | p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(request.packets); | ||
457 | end = (void __user *)p + request.size; | ||
458 | count = 0; | ||
459 | while (p < end) { | ||
460 | if (__copy_from_user(&u.packet, p, sizeof *p)) | ||
461 | return -EFAULT; | ||
462 | next = (struct fw_cdev_iso_packet __user *) | ||
463 | &p->header[u.packet.header_length / 4]; | ||
464 | if (next > end) | ||
465 | return -EINVAL; | ||
466 | if (__copy_from_user | ||
467 | (u.packet.header, p->header, u.packet.header_length)) | ||
468 | return -EFAULT; | ||
469 | if (u.packet.skip && | ||
470 | u.packet.header_length + u.packet.payload_length > 0) | ||
471 | return -EINVAL; | ||
472 | if (payload + u.packet.payload_length > payload_end) | ||
473 | return -EINVAL; | ||
474 | |||
475 | if (fw_iso_context_queue(client->iso_context, | ||
476 | &u.packet, payload)) | ||
477 | break; | ||
478 | |||
479 | p = next; | ||
480 | payload += u.packet.payload_length; | ||
481 | count++; | ||
482 | } | ||
483 | |||
484 | request.size -= uptr_to_u64(p) - request.packets; | ||
485 | request.packets = uptr_to_u64(p); | ||
486 | request.data = | ||
487 | client->vm_start + (payload - client->iso_context->buffer); | ||
488 | |||
489 | if (copy_to_user(arg, &request, sizeof request)) | ||
490 | return -EFAULT; | ||
491 | |||
492 | return count; | ||
493 | } | ||
494 | |||
495 | static int ioctl_send_iso(struct client *client, void __user *arg) | ||
496 | { | ||
497 | struct fw_cdev_send_iso request; | ||
498 | |||
499 | if (copy_from_user(&request, arg, sizeof request)) | ||
500 | return -EFAULT; | ||
501 | |||
502 | return fw_iso_context_send(client->iso_context, request.channel, | ||
503 | request.speed, request.cycle); | ||
504 | } | ||
505 | |||
506 | static int | ||
507 | dispatch_ioctl(struct client *client, unsigned int cmd, void __user *arg) | ||
508 | { | ||
509 | switch (cmd) { | ||
510 | case FW_CDEV_IOC_GET_CONFIG_ROM: | ||
511 | return ioctl_config_rom(client, arg); | ||
512 | case FW_CDEV_IOC_SEND_REQUEST: | ||
513 | return ioctl_send_request(client, arg); | ||
514 | case FW_CDEV_IOC_ALLOCATE: | ||
515 | return ioctl_allocate(client, arg); | ||
516 | case FW_CDEV_IOC_SEND_RESPONSE: | ||
517 | return ioctl_send_response(client, arg); | ||
518 | case FW_CDEV_IOC_CREATE_ISO_CONTEXT: | ||
519 | return ioctl_create_iso_context(client, arg); | ||
520 | case FW_CDEV_IOC_QUEUE_ISO: | ||
521 | return ioctl_queue_iso(client, arg); | ||
522 | case FW_CDEV_IOC_SEND_ISO: | ||
523 | return ioctl_send_iso(client, arg); | ||
524 | default: | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | } | ||
528 | |||
529 | static long | ||
530 | fw_device_op_ioctl(struct file *file, | ||
531 | unsigned int cmd, unsigned long arg) | ||
532 | { | ||
533 | struct client *client = file->private_data; | ||
534 | |||
535 | return dispatch_ioctl(client, cmd, (void __user *) arg); | ||
536 | } | ||
537 | |||
538 | #ifdef CONFIG_COMPAT | ||
539 | static long | ||
540 | fw_device_op_compat_ioctl(struct file *file, | ||
541 | unsigned int cmd, unsigned long arg) | ||
542 | { | ||
543 | struct client *client = file->private_data; | ||
544 | |||
545 | return dispatch_ioctl(client, cmd, compat_ptr(arg)); | ||
546 | } | ||
547 | #endif | ||
548 | |||
549 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) | ||
550 | { | ||
551 | struct client *client = file->private_data; | ||
552 | |||
553 | if (client->iso_context->buffer == NULL) | ||
554 | return -EINVAL; | ||
555 | |||
556 | client->vm_start = vma->vm_start; | ||
557 | |||
558 | return remap_vmalloc_range(vma, client->iso_context->buffer, 0); | ||
559 | } | ||
560 | |||
561 | static int fw_device_op_release(struct inode *inode, struct file *file) | ||
562 | { | ||
563 | struct client *client = file->private_data; | ||
564 | struct address_handler *h, *next; | ||
565 | struct request *r, *next_r; | ||
566 | |||
567 | if (client->iso_context) | ||
568 | fw_iso_context_destroy(client->iso_context); | ||
569 | |||
570 | list_for_each_entry_safe(h, next, &client->handler_list, link) { | ||
571 | fw_core_remove_address_handler(&h->handler); | ||
572 | kfree(h); | ||
573 | } | ||
574 | |||
575 | list_for_each_entry_safe(r, next_r, &client->request_list, link) { | ||
576 | fw_send_response(client->device->card, r->request, | ||
577 | RCODE_CONFLICT_ERROR); | ||
578 | kfree(r); | ||
579 | } | ||
580 | |||
581 | /* TODO: wait for all transactions to finish so | ||
582 | * complete_transaction doesn't try to queue up responses | ||
583 | * after we free client. */ | ||
584 | while (!list_empty(&client->event_list)) | ||
585 | dequeue_event(client, NULL, 0); | ||
586 | |||
587 | fw_device_put(client->device); | ||
588 | kfree(client); | ||
589 | |||
590 | return 0; | ||
591 | } | ||
592 | |||
593 | static unsigned int fw_device_op_poll(struct file *file, poll_table * pt) | ||
594 | { | ||
595 | struct client *client = file->private_data; | ||
596 | |||
597 | poll_wait(file, &client->wait, pt); | ||
598 | |||
599 | if (!list_empty(&client->event_list)) | ||
600 | return POLLIN | POLLRDNORM; | ||
601 | else | ||
602 | return 0; | ||
603 | } | ||
604 | |||
605 | struct file_operations fw_device_ops = { | ||
606 | .owner = THIS_MODULE, | ||
607 | .open = fw_device_op_open, | ||
608 | .read = fw_device_op_read, | ||
609 | .unlocked_ioctl = fw_device_op_ioctl, | ||
610 | .poll = fw_device_op_poll, | ||
611 | .release = fw_device_op_release, | ||
612 | .mmap = fw_device_op_mmap, | ||
613 | |||
614 | #ifdef CONFIG_COMPAT | ||
615 | .compat_ioctl = fw_device_op_compat_ioctl | ||
616 | #endif | ||
617 | }; | ||
diff --git a/drivers/firewire/fw-device-cdev.h b/drivers/firewire/fw-device-cdev.h new file mode 100644 index 000000000000..18b20c28a406 --- /dev/null +++ b/drivers/firewire/fw-device-cdev.h | |||
@@ -0,0 +1,146 @@ | |||
1 | /* -*- c-basic-offset: 8 -*- | ||
2 | * | ||
3 | * fw-device-cdev.h -- Char device interface. | ||
4 | * | ||
5 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software Foundation, | ||
19 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef __fw_cdev_h | ||
23 | #define __fw_cdev_h | ||
24 | |||
25 | #include <asm/ioctl.h> | ||
26 | #include <asm/types.h> | ||
27 | |||
28 | #define TCODE_WRITE_QUADLET_REQUEST 0 | ||
29 | #define TCODE_WRITE_BLOCK_REQUEST 1 | ||
30 | #define TCODE_WRITE_RESPONSE 2 | ||
31 | #define TCODE_READ_QUADLET_REQUEST 4 | ||
32 | #define TCODE_READ_BLOCK_REQUEST 5 | ||
33 | #define TCODE_READ_QUADLET_RESPONSE 6 | ||
34 | #define TCODE_READ_BLOCK_RESPONSE 7 | ||
35 | #define TCODE_CYCLE_START 8 | ||
36 | #define TCODE_LOCK_REQUEST 9 | ||
37 | #define TCODE_STREAM_DATA 10 | ||
38 | #define TCODE_LOCK_RESPONSE 11 | ||
39 | |||
40 | #define RCODE_COMPLETE 0x0 | ||
41 | #define RCODE_CONFLICT_ERROR 0x4 | ||
42 | #define RCODE_DATA_ERROR 0x5 | ||
43 | #define RCODE_TYPE_ERROR 0x6 | ||
44 | #define RCODE_ADDRESS_ERROR 0x7 | ||
45 | |||
46 | #define SCODE_100 0x0 | ||
47 | #define SCODE_200 0x1 | ||
48 | #define SCODE_400 0x2 | ||
49 | #define SCODE_800 0x3 | ||
50 | #define SCODE_1600 0x4 | ||
51 | #define SCODE_3200 0x5 | ||
52 | |||
53 | #define FW_CDEV_EVENT_RESPONSE 0x00 | ||
54 | #define FW_CDEV_EVENT_REQUEST 0x01 | ||
55 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x02 | ||
56 | |||
57 | /* The 'closure' fields are for user space to use. Data passed in the | ||
58 | * 'closure' field for a request will be returned in the corresponding | ||
59 | * event. It's a 64-bit type so that it's a fixed size type big | ||
60 | * enough to hold a pointer on all platforms. */ | ||
61 | |||
62 | struct fw_cdev_event_response { | ||
63 | __u32 type; | ||
64 | __u32 rcode; | ||
65 | __u64 closure; | ||
66 | __u32 length; | ||
67 | __u32 data[0]; | ||
68 | }; | ||
69 | |||
70 | struct fw_cdev_event_request { | ||
71 | __u32 type; | ||
72 | __u32 tcode; | ||
73 | __u64 offset; | ||
74 | __u64 closure; | ||
75 | __u32 serial; | ||
76 | __u32 length; | ||
77 | __u32 data[0]; | ||
78 | }; | ||
79 | |||
80 | struct fw_cdev_event_iso_interrupt { | ||
81 | __u32 type; | ||
82 | __u32 cycle; | ||
83 | __u64 closure; | ||
84 | }; | ||
85 | |||
86 | #define FW_CDEV_IOC_GET_CONFIG_ROM _IOR('#', 0x00, struct fw_cdev_get_config_rom) | ||
87 | #define FW_CDEV_IOC_SEND_REQUEST _IO('#', 0x01) | ||
88 | #define FW_CDEV_IOC_ALLOCATE _IO('#', 0x02) | ||
89 | #define FW_CDEV_IOC_SEND_RESPONSE _IO('#', 0x03) | ||
90 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IO('#', 0x04) | ||
91 | #define FW_CDEV_IOC_QUEUE_ISO _IO('#', 0x05) | ||
92 | #define FW_CDEV_IOC_SEND_ISO _IO('#', 0x06) | ||
93 | |||
94 | struct fw_cdev_get_config_rom { | ||
95 | __u32 length; | ||
96 | __u32 data[256]; | ||
97 | }; | ||
98 | |||
99 | struct fw_cdev_send_request { | ||
100 | __u32 tcode; | ||
101 | __u32 length; | ||
102 | __u64 offset; | ||
103 | __u64 closure; | ||
104 | __u64 data; | ||
105 | }; | ||
106 | |||
107 | struct fw_cdev_send_response { | ||
108 | __u32 rcode; | ||
109 | __u32 length; | ||
110 | __u64 data; | ||
111 | __u32 serial; | ||
112 | }; | ||
113 | |||
114 | struct fw_cdev_allocate { | ||
115 | __u64 offset; | ||
116 | __u64 closure; | ||
117 | __u32 length; | ||
118 | }; | ||
119 | |||
120 | struct fw_cdev_create_iso_context { | ||
121 | __u32 buffer_size; | ||
122 | }; | ||
123 | |||
124 | struct fw_cdev_iso_packet { | ||
125 | __u16 payload_length; /* Length of indirect payload. */ | ||
126 | __u32 interrupt : 1; /* Generate interrupt on this packet */ | ||
127 | __u32 skip : 1; /* Set to not send packet at all. */ | ||
128 | __u32 tag : 2; | ||
129 | __u32 sy : 4; | ||
130 | __u32 header_length : 8; /* Length of immediate header. */ | ||
131 | __u32 header[0]; | ||
132 | }; | ||
133 | |||
134 | struct fw_cdev_queue_iso { | ||
135 | __u32 size; | ||
136 | __u64 packets; | ||
137 | __u64 data; | ||
138 | }; | ||
139 | |||
140 | struct fw_cdev_send_iso { | ||
141 | __u32 channel; | ||
142 | __u32 speed; | ||
143 | __s32 cycle; | ||
144 | }; | ||
145 | |||
146 | #endif | ||
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c new file mode 100644 index 000000000000..ec1cb7fc8e96 --- /dev/null +++ b/drivers/firewire/fw-device.c | |||
@@ -0,0 +1,613 @@ | |||
1 | /* -*- c-basic-offset: 8 -*- | ||
2 | * | ||
3 | * fw-device.c - Device probing and sysfs code. | ||
4 | * | ||
5 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software Foundation, | ||
19 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/wait.h> | ||
24 | #include <linux/errno.h> | ||
25 | #include <linux/kthread.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/delay.h> | ||
28 | #include "fw-transaction.h" | ||
29 | #include "fw-topology.h" | ||
30 | #include "fw-device.h" | ||
31 | |||
32 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 * p) | ||
33 | { | ||
34 | ci->p = p + 1; | ||
35 | ci->end = ci->p + (p[0] >> 16); | ||
36 | } | ||
37 | |||
38 | EXPORT_SYMBOL(fw_csr_iterator_init); | ||
39 | |||
40 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value) | ||
41 | { | ||
42 | *key = *ci->p >> 24; | ||
43 | *value = *ci->p & 0xffffff; | ||
44 | |||
45 | return ci->p++ < ci->end; | ||
46 | } | ||
47 | |||
48 | EXPORT_SYMBOL(fw_csr_iterator_next); | ||
49 | |||
50 | static int is_fw_unit(struct device *dev); | ||
51 | |||
52 | static int match_unit_directory(u32 * directory, struct fw_device_id *id) | ||
53 | { | ||
54 | struct fw_csr_iterator ci; | ||
55 | int key, value, match; | ||
56 | |||
57 | match = 0; | ||
58 | fw_csr_iterator_init(&ci, directory); | ||
59 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
60 | if (key == CSR_VENDOR && value == id->vendor) | ||
61 | match |= FW_MATCH_VENDOR; | ||
62 | if (key == CSR_MODEL && value == id->model) | ||
63 | match |= FW_MATCH_MODEL; | ||
64 | if (key == CSR_SPECIFIER_ID && value == id->specifier_id) | ||
65 | match |= FW_MATCH_SPECIFIER_ID; | ||
66 | if (key == CSR_VERSION && value == id->version) | ||
67 | match |= FW_MATCH_VERSION; | ||
68 | } | ||
69 | |||
70 | return (match & id->match_flags) == id->match_flags; | ||
71 | } | ||
72 | |||
73 | static int fw_unit_match(struct device *dev, struct device_driver *drv) | ||
74 | { | ||
75 | struct fw_unit *unit = fw_unit(dev); | ||
76 | struct fw_driver *driver = fw_driver(drv); | ||
77 | int i; | ||
78 | |||
79 | /* We only allow binding to fw_units. */ | ||
80 | if (!is_fw_unit(dev)) | ||
81 | return 0; | ||
82 | |||
83 | for (i = 0; driver->id_table[i].match_flags != 0; i++) { | ||
84 | if (match_unit_directory(unit->directory, &driver->id_table[i])) | ||
85 | return 1; | ||
86 | } | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) | ||
92 | { | ||
93 | struct fw_device *device = fw_device(unit->device.parent); | ||
94 | struct fw_csr_iterator ci; | ||
95 | |||
96 | int key, value; | ||
97 | int vendor = 0; | ||
98 | int model = 0; | ||
99 | int specifier_id = 0; | ||
100 | int version = 0; | ||
101 | |||
102 | fw_csr_iterator_init(&ci, &device->config_rom[5]); | ||
103 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
104 | switch (key) { | ||
105 | case CSR_VENDOR: | ||
106 | vendor = value; | ||
107 | break; | ||
108 | case CSR_MODEL: | ||
109 | model = value; | ||
110 | break; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | fw_csr_iterator_init(&ci, unit->directory); | ||
115 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
116 | switch (key) { | ||
117 | case CSR_SPECIFIER_ID: | ||
118 | specifier_id = value; | ||
119 | break; | ||
120 | case CSR_VERSION: | ||
121 | version = value; | ||
122 | break; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | return snprintf(buffer, buffer_size, | ||
127 | "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", | ||
128 | vendor, model, specifier_id, version); | ||
129 | } | ||
130 | |||
131 | static int | ||
132 | fw_unit_uevent(struct device *dev, char **envp, int num_envp, | ||
133 | char *buffer, int buffer_size) | ||
134 | { | ||
135 | struct fw_unit *unit = fw_unit(dev); | ||
136 | char modalias[64]; | ||
137 | int length = 0; | ||
138 | int i = 0; | ||
139 | |||
140 | if (!is_fw_unit(dev)) | ||
141 | goto out; | ||
142 | |||
143 | get_modalias(unit, modalias, sizeof modalias); | ||
144 | |||
145 | if (add_uevent_var(envp, num_envp, &i, | ||
146 | buffer, buffer_size, &length, | ||
147 | "MODALIAS=%s", modalias)) | ||
148 | return -ENOMEM; | ||
149 | |||
150 | out: | ||
151 | envp[i] = NULL; | ||
152 | |||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | struct bus_type fw_bus_type = { | ||
157 | .name = "fw", | ||
158 | .match = fw_unit_match, | ||
159 | .uevent = fw_unit_uevent | ||
160 | }; | ||
161 | |||
162 | EXPORT_SYMBOL(fw_bus_type); | ||
163 | |||
164 | extern struct fw_device *fw_device_get(struct fw_device *device) | ||
165 | { | ||
166 | get_device(&device->device); | ||
167 | |||
168 | return device; | ||
169 | } | ||
170 | |||
171 | extern void fw_device_put(struct fw_device *device) | ||
172 | { | ||
173 | put_device(&device->device); | ||
174 | } | ||
175 | |||
176 | static void fw_device_release(struct device *dev) | ||
177 | { | ||
178 | struct fw_device *device = fw_device(dev); | ||
179 | unsigned long flags; | ||
180 | |||
181 | /* Take the card lock so we don't set this to NULL while a | ||
182 | * FW_NODE_UPDATED callback is being handled. */ | ||
183 | spin_lock_irqsave(&device->card->lock, flags); | ||
184 | device->node->data = NULL; | ||
185 | spin_unlock_irqrestore(&device->card->lock, flags); | ||
186 | |||
187 | fw_node_put(device->node); | ||
188 | fw_card_put(device->card); | ||
189 | kfree(device->config_rom); | ||
190 | kfree(device); | ||
191 | } | ||
192 | |||
193 | int fw_device_enable_phys_dma(struct fw_device *device) | ||
194 | { | ||
195 | return device->card->driver->enable_phys_dma(device->card, | ||
196 | device->node_id, | ||
197 | device->generation); | ||
198 | } | ||
199 | |||
200 | EXPORT_SYMBOL(fw_device_enable_phys_dma); | ||
201 | |||
202 | static ssize_t | ||
203 | show_modalias_attribute(struct device *dev, | ||
204 | struct device_attribute *attr, char *buf) | ||
205 | { | ||
206 | struct fw_unit *unit = fw_unit(dev); | ||
207 | int length; | ||
208 | |||
209 | length = get_modalias(unit, buf, PAGE_SIZE); | ||
210 | strcpy(buf + length, "\n"); | ||
211 | |||
212 | return length + 1; | ||
213 | } | ||
214 | |||
215 | static struct device_attribute modalias_attribute = { | ||
216 | .attr = {.name = "modalias",.mode = S_IRUGO}, | ||
217 | .show = show_modalias_attribute | ||
218 | }; | ||
219 | |||
220 | static ssize_t | ||
221 | show_config_rom_attribute(struct device *dev, | ||
222 | struct device_attribute *attr, char *buf) | ||
223 | { | ||
224 | struct fw_device *device = fw_device(dev); | ||
225 | |||
226 | memcpy(buf, device->config_rom, device->config_rom_length * 4); | ||
227 | |||
228 | return device->config_rom_length * 4; | ||
229 | } | ||
230 | |||
231 | static struct device_attribute config_rom_attribute = { | ||
232 | .attr = {.name = "config_rom",.mode = S_IRUGO}, | ||
233 | .show = show_config_rom_attribute, | ||
234 | }; | ||
235 | |||
236 | struct read_quadlet_callback_data { | ||
237 | struct completion done; | ||
238 | int rcode; | ||
239 | u32 data; | ||
240 | }; | ||
241 | |||
242 | static void | ||
243 | complete_transaction(struct fw_card *card, int rcode, | ||
244 | void *payload, size_t length, void *data) | ||
245 | { | ||
246 | struct read_quadlet_callback_data *callback_data = data; | ||
247 | |||
248 | if (rcode == RCODE_COMPLETE) | ||
249 | callback_data->data = be32_to_cpu(*(__be32 *)payload); | ||
250 | callback_data->rcode = rcode; | ||
251 | complete(&callback_data->done); | ||
252 | } | ||
253 | |||
254 | static int read_rom(struct fw_device *device, int index, u32 * data) | ||
255 | { | ||
256 | struct read_quadlet_callback_data callback_data; | ||
257 | struct fw_transaction t; | ||
258 | u64 offset; | ||
259 | |||
260 | init_completion(&callback_data.done); | ||
261 | |||
262 | offset = 0xfffff0000400ULL + index * 4; | ||
263 | fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST, | ||
264 | device->node_id | LOCAL_BUS, | ||
265 | device->generation, SCODE_100, | ||
266 | offset, NULL, 4, complete_transaction, &callback_data); | ||
267 | |||
268 | wait_for_completion(&callback_data.done); | ||
269 | |||
270 | *data = callback_data.data; | ||
271 | |||
272 | return callback_data.rcode; | ||
273 | } | ||
274 | |||
275 | static int read_bus_info_block(struct fw_device *device) | ||
276 | { | ||
277 | static u32 rom[256]; | ||
278 | u32 stack[16], sp, key; | ||
279 | int i, end, length; | ||
280 | |||
281 | /* First read the bus info block. */ | ||
282 | for (i = 0; i < 5; i++) { | ||
283 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
284 | return -1; | ||
285 | /* As per IEEE1212 7.2, during power-up, devices can | ||
286 | * reply with a 0 for the first quadlet of the config | ||
287 | * rom to indicate that they are booting (for example, | ||
288 | * if the firmware is on the disk of a external | ||
289 | * harddisk). In that case we just fail, and the | ||
290 | * retry mechanism will try again later. */ | ||
291 | if (i == 0 && rom[i] == 0) | ||
292 | return -1; | ||
293 | } | ||
294 | |||
295 | /* Now parse the config rom. The config rom is a recursive | ||
296 | * directory structure so we parse it using a stack of | ||
297 | * references to the blocks that make up the structure. We | ||
298 | * push a reference to the root directory on the stack to | ||
299 | * start things off. */ | ||
300 | length = i; | ||
301 | sp = 0; | ||
302 | stack[sp++] = 0xc0000005; | ||
303 | while (sp > 0) { | ||
304 | /* Pop the next block reference of the stack. The | ||
305 | * lower 24 bits is the offset into the config rom, | ||
306 | * the upper 8 bits are the type of the reference the | ||
307 | * block. */ | ||
308 | key = stack[--sp]; | ||
309 | i = key & 0xffffff; | ||
310 | if (i >= ARRAY_SIZE(rom)) | ||
311 | /* The reference points outside the standard | ||
312 | * config rom area, something's fishy. */ | ||
313 | return -1; | ||
314 | |||
315 | /* Read header quadlet for the block to get the length. */ | ||
316 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
317 | return -1; | ||
318 | end = i + (rom[i] >> 16) + 1; | ||
319 | i++; | ||
320 | if (end > ARRAY_SIZE(rom)) | ||
321 | /* This block extends outside standard config | ||
322 | * area (and the array we're reading it | ||
323 | * into). That's broken, so ignore this | ||
324 | * device. */ | ||
325 | return -1; | ||
326 | |||
327 | /* Now read in the block. If this is a directory | ||
328 | * block, check the entries as we read them to see if | ||
329 | * it references another block, and push it in that case. */ | ||
330 | while (i < end) { | ||
331 | if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE) | ||
332 | return -1; | ||
333 | if ((key >> 30) == 3 && (rom[i] >> 30) > 1 && | ||
334 | sp < ARRAY_SIZE(stack)) | ||
335 | stack[sp++] = i + rom[i]; | ||
336 | i++; | ||
337 | } | ||
338 | if (length < i) | ||
339 | length = i; | ||
340 | } | ||
341 | |||
342 | device->config_rom = kmalloc(length * 4, GFP_KERNEL); | ||
343 | if (device->config_rom == NULL) | ||
344 | return -1; | ||
345 | memcpy(device->config_rom, rom, length * 4); | ||
346 | device->config_rom_length = length; | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static void fw_unit_release(struct device *dev) | ||
352 | { | ||
353 | struct fw_unit *unit = fw_unit(dev); | ||
354 | |||
355 | kfree(unit); | ||
356 | } | ||
357 | |||
358 | static int is_fw_unit(struct device *dev) | ||
359 | { | ||
360 | return dev->release == fw_unit_release; | ||
361 | } | ||
362 | |||
363 | static void create_units(struct fw_device *device) | ||
364 | { | ||
365 | struct fw_csr_iterator ci; | ||
366 | struct fw_unit *unit; | ||
367 | int key, value, i; | ||
368 | |||
369 | i = 0; | ||
370 | fw_csr_iterator_init(&ci, &device->config_rom[5]); | ||
371 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
372 | if (key != (CSR_UNIT | CSR_DIRECTORY)) | ||
373 | continue; | ||
374 | |||
375 | /* Get the address of the unit directory and try to | ||
376 | * match the drivers id_tables against it. */ | ||
377 | unit = kzalloc(sizeof *unit, GFP_KERNEL); | ||
378 | if (unit == NULL) { | ||
379 | fw_error("failed to allocate memory for unit\n"); | ||
380 | continue; | ||
381 | } | ||
382 | |||
383 | unit->directory = ci.p + value - 1; | ||
384 | unit->device.bus = &fw_bus_type; | ||
385 | unit->device.release = fw_unit_release; | ||
386 | unit->device.parent = &device->device; | ||
387 | snprintf(unit->device.bus_id, sizeof unit->device.bus_id, | ||
388 | "%s.%d", device->device.bus_id, i++); | ||
389 | |||
390 | if (device_register(&unit->device) < 0) { | ||
391 | kfree(unit); | ||
392 | continue; | ||
393 | } | ||
394 | |||
395 | if (device_create_file(&unit->device, &modalias_attribute) < 0) { | ||
396 | device_unregister(&unit->device); | ||
397 | kfree(unit); | ||
398 | } | ||
399 | } | ||
400 | } | ||
401 | |||
402 | static int shutdown_unit(struct device *device, void *data) | ||
403 | { | ||
404 | struct fw_unit *unit = fw_unit(device); | ||
405 | |||
406 | if (is_fw_unit(device)) { | ||
407 | device_remove_file(&unit->device, &modalias_attribute); | ||
408 | device_unregister(&unit->device); | ||
409 | } | ||
410 | |||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static void fw_device_shutdown(struct work_struct *work) | ||
415 | { | ||
416 | struct fw_device *device = | ||
417 | container_of(work, struct fw_device, work.work); | ||
418 | |||
419 | device_remove_file(&device->device, &config_rom_attribute); | ||
420 | cdev_del(&device->cdev); | ||
421 | unregister_chrdev_region(device->device.devt, 1); | ||
422 | device_for_each_child(&device->device, NULL, shutdown_unit); | ||
423 | device_unregister(&device->device); | ||
424 | } | ||
425 | |||
426 | /* These defines control the retry behavior for reading the config | ||
427 | * rom. It shouldn't be necessary to tweak these; if the device | ||
428 | * doesn't respond to a config rom read within 10 seconds, it's not | ||
429 | * going to respond at all. As for the initial delay, a lot of | ||
430 | * devices will be able to respond within half a second after bus | ||
431 | * reset. On the other hand, it's not really worth being more | ||
432 | * aggressive than that, since it scales pretty well; if 10 devices | ||
433 | * are plugged in, they're all getting read within one second. */ | ||
434 | |||
435 | #define MAX_RETRIES 5 | ||
436 | #define RETRY_DELAY (2 * HZ) | ||
437 | #define INITIAL_DELAY (HZ / 2) | ||
438 | |||
439 | static void fw_device_init(struct work_struct *work) | ||
440 | { | ||
441 | static int serial; | ||
442 | struct fw_device *device = | ||
443 | container_of(work, struct fw_device, work.work); | ||
444 | |||
445 | /* All failure paths here set node->data to NULL, so that we | ||
446 | * don't try to do device_for_each_child() on a kfree()'d | ||
447 | * device. */ | ||
448 | |||
449 | if (read_bus_info_block(device) < 0) { | ||
450 | if (device->config_rom_retries < MAX_RETRIES) { | ||
451 | device->config_rom_retries++; | ||
452 | schedule_delayed_work(&device->work, RETRY_DELAY); | ||
453 | } else { | ||
454 | fw_notify("giving up on config rom for node id %d\n", | ||
455 | device->node_id); | ||
456 | fw_device_release(&device->device); | ||
457 | } | ||
458 | return; | ||
459 | } | ||
460 | |||
461 | device->device.bus = &fw_bus_type; | ||
462 | device->device.release = fw_device_release; | ||
463 | device->device.parent = device->card->device; | ||
464 | snprintf(device->device.bus_id, sizeof device->device.bus_id, | ||
465 | "fw%d", serial++); | ||
466 | |||
467 | if (alloc_chrdev_region(&device->device.devt, 0, 1, "fw")) { | ||
468 | fw_error("Failed to register char device region.\n"); | ||
469 | goto error; | ||
470 | } | ||
471 | |||
472 | cdev_init(&device->cdev, &fw_device_ops); | ||
473 | device->cdev.owner = THIS_MODULE; | ||
474 | kobject_set_name(&device->cdev.kobj, device->device.bus_id); | ||
475 | if (cdev_add(&device->cdev, device->device.devt, 1)) { | ||
476 | fw_error("Failed to register char device.\n"); | ||
477 | goto error; | ||
478 | } | ||
479 | |||
480 | if (device_add(&device->device)) { | ||
481 | fw_error("Failed to add device.\n"); | ||
482 | goto error; | ||
483 | } | ||
484 | |||
485 | if (device_create_file(&device->device, &config_rom_attribute) < 0) { | ||
486 | fw_error("Failed to create config rom file.\n"); | ||
487 | goto error_with_device; | ||
488 | } | ||
489 | |||
490 | create_units(device); | ||
491 | |||
492 | /* Transition the device to running state. If it got pulled | ||
493 | * out from under us while we did the intialization work, we | ||
494 | * have to shut down the device again here. Normally, though, | ||
495 | * fw_node_event will be responsible for shutting it down when | ||
496 | * necessary. We have to use the atomic cmpxchg here to avoid | ||
497 | * racing with the FW_NODE_DESTROYED case in | ||
498 | * fw_node_event(). */ | ||
499 | if (cmpxchg(&device->state, | ||
500 | FW_DEVICE_INITIALIZING, | ||
501 | FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) | ||
502 | fw_device_shutdown(&device->work.work); | ||
503 | else | ||
504 | fw_notify("created new fw device %s (%d config rom retries)\n", | ||
505 | device->device.bus_id, device->config_rom_retries); | ||
506 | |||
507 | /* Reschedule the IRM work if we just finished reading the | ||
508 | * root node config rom. If this races with a bus reset we | ||
509 | * just end up running the IRM work a couple of extra times - | ||
510 | * pretty harmless. */ | ||
511 | if (device->node == device->card->root_node) | ||
512 | schedule_delayed_work(&device->card->work, 0); | ||
513 | |||
514 | return; | ||
515 | |||
516 | error_with_device: | ||
517 | device_del(&device->device); | ||
518 | error: | ||
519 | cdev_del(&device->cdev); | ||
520 | unregister_chrdev_region(device->device.devt, 1); | ||
521 | put_device(&device->device); | ||
522 | } | ||
523 | |||
524 | static int update_unit(struct device *dev, void *data) | ||
525 | { | ||
526 | struct fw_unit *unit = fw_unit(dev); | ||
527 | struct fw_driver *driver = (struct fw_driver *)dev->driver; | ||
528 | |||
529 | if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) | ||
530 | driver->update(unit); | ||
531 | |||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | ||
536 | { | ||
537 | struct fw_device *device; | ||
538 | |||
539 | /* Ignore events for the local node (i.e. the node that | ||
540 | * corresponds to the ieee1394 controller in this linux box). */ | ||
541 | if (node == card->local_node) | ||
542 | return; | ||
543 | |||
544 | switch (event) { | ||
545 | case FW_NODE_CREATED: | ||
546 | case FW_NODE_LINK_ON: | ||
547 | if (!node->link_on) | ||
548 | break; | ||
549 | |||
550 | device = kzalloc(sizeof(*device), GFP_ATOMIC); | ||
551 | if (device == NULL) | ||
552 | break; | ||
553 | |||
554 | /* Do minimal intialization of the device here, the | ||
555 | * rest will happen in fw_device_init(). We need the | ||
556 | * card and node so we can read the config rom and we | ||
557 | * need to do device_initialize() now so | ||
558 | * device_for_each_child() in FW_NODE_UPDATED is | ||
559 | * doesn't freak out. */ | ||
560 | device_initialize(&device->device); | ||
561 | device->state = FW_DEVICE_INITIALIZING; | ||
562 | device->card = fw_card_get(card); | ||
563 | device->node = fw_node_get(node); | ||
564 | device->node_id = node->node_id; | ||
565 | device->generation = card->generation; | ||
566 | |||
567 | /* Set the node data to point back to this device so | ||
568 | * FW_NODE_UPDATED callbacks can update the node_id | ||
569 | * and generation for the device. */ | ||
570 | node->data = device; | ||
571 | |||
572 | /* Many devices are slow to respond after bus resets, | ||
573 | * especially if they are bus powered and go through | ||
574 | * power-up after getting plugged in. We schedule the | ||
575 | * first config rom scan half a second after bus reset. */ | ||
576 | INIT_DELAYED_WORK(&device->work, fw_device_init); | ||
577 | schedule_delayed_work(&device->work, INITIAL_DELAY); | ||
578 | break; | ||
579 | |||
580 | case FW_NODE_UPDATED: | ||
581 | if (!node->link_on || node->data == NULL) | ||
582 | break; | ||
583 | |||
584 | device = node->data; | ||
585 | device->node_id = node->node_id; | ||
586 | device->generation = card->generation; | ||
587 | device_for_each_child(&device->device, NULL, update_unit); | ||
588 | break; | ||
589 | |||
590 | case FW_NODE_DESTROYED: | ||
591 | case FW_NODE_LINK_OFF: | ||
592 | if (!node->data) | ||
593 | break; | ||
594 | |||
595 | /* Destroy the device associated with the node. There | ||
596 | * are two cases here: either the device is fully | ||
597 | * initialized (FW_DEVICE_RUNNING) or we're in the | ||
598 | * process of reading its config rom | ||
599 | * (FW_DEVICE_INITIALIZING). If it is fully | ||
600 | * initialized we can reuse device->work to schedule a | ||
601 | * full fw_device_shutdown(). If not, there's work | ||
602 | * scheduled to read it's config rom, and we just put | ||
603 | * the device in shutdown state to have that code fail | ||
604 | * to create the device. */ | ||
605 | device = node->data; | ||
606 | if (xchg(&device->state, | ||
607 | FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { | ||
608 | INIT_DELAYED_WORK(&device->work, fw_device_shutdown); | ||
609 | schedule_delayed_work(&device->work, 0); | ||
610 | } | ||
611 | break; | ||
612 | } | ||
613 | } | ||
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h new file mode 100644 index 000000000000..84cd5e7e2fce --- /dev/null +++ b/drivers/firewire/fw-device.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* -*- c-basic-offset: 8 -*- | ||
2 | * | ||
3 | * fw-device.h - Device probing and sysfs code. | ||
4 | * | ||
5 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software Foundation, | ||
19 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef __fw_device_h | ||
23 | #define __fw_device_h | ||
24 | |||
25 | #include <linux/fs.h> | ||
26 | #include <linux/cdev.h> | ||
27 | |||
28 | enum fw_device_state { | ||
29 | FW_DEVICE_INITIALIZING, | ||
30 | FW_DEVICE_RUNNING, | ||
31 | FW_DEVICE_SHUTDOWN | ||
32 | }; | ||
33 | |||
34 | struct fw_device { | ||
35 | int state; | ||
36 | struct fw_node *node; | ||
37 | int node_id; | ||
38 | int generation; | ||
39 | struct fw_card *card; | ||
40 | struct device device; | ||
41 | struct cdev cdev; | ||
42 | __be32 *config_rom; | ||
43 | size_t config_rom_length; | ||
44 | int config_rom_retries; | ||
45 | struct delayed_work work; | ||
46 | }; | ||
47 | |||
48 | static inline struct fw_device * | ||
49 | fw_device(struct device *dev) | ||
50 | { | ||
51 | return container_of(dev, struct fw_device, device); | ||
52 | } | ||
53 | |||
54 | struct fw_device *fw_device_get(struct fw_device *device); | ||
55 | void fw_device_put(struct fw_device *device); | ||
56 | int fw_device_enable_phys_dma(struct fw_device *device); | ||
57 | |||
58 | struct fw_unit { | ||
59 | struct device device; | ||
60 | u32 *directory; | ||
61 | }; | ||
62 | |||
63 | static inline struct fw_unit * | ||
64 | fw_unit(struct device *dev) | ||
65 | { | ||
66 | return container_of(dev, struct fw_unit, device); | ||
67 | } | ||
68 | |||
69 | #define CSR_OFFSET 0x40 | ||
70 | #define CSR_LEAF 0x80 | ||
71 | #define CSR_DIRECTORY 0xc0 | ||
72 | |||
73 | #define CSR_DESCRIPTOR 0x01 | ||
74 | #define CSR_VENDOR 0x03 | ||
75 | #define CSR_HARDWARE_VERSION 0x04 | ||
76 | #define CSR_NODE_CAPABILITIES 0x0c | ||
77 | #define CSR_UNIT 0x11 | ||
78 | #define CSR_SPECIFIER_ID 0x12 | ||
79 | #define CSR_VERSION 0x13 | ||
80 | #define CSR_DEPENDENT_INFO 0x14 | ||
81 | #define CSR_MODEL 0x17 | ||
82 | #define CSR_INSTANCE 0x18 | ||
83 | |||
84 | #define SBP2_COMMAND_SET_SPECIFIER 0x38 | ||
85 | #define SBP2_COMMAND_SET 0x39 | ||
86 | #define SBP2_COMMAND_SET_REVISION 0x3b | ||
87 | #define SBP2_FIRMWARE_REVISION 0x3c | ||
88 | |||
89 | struct fw_csr_iterator { | ||
90 | u32 *p; | ||
91 | u32 *end; | ||
92 | }; | ||
93 | |||
94 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 *p); | ||
95 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, | ||
96 | int *key, int *value); | ||
97 | |||
98 | #define FW_MATCH_VENDOR 0x0001 | ||
99 | #define FW_MATCH_MODEL 0x0002 | ||
100 | #define FW_MATCH_SPECIFIER_ID 0x0004 | ||
101 | #define FW_MATCH_VERSION 0x0008 | ||
102 | |||
103 | struct fw_device_id { | ||
104 | u32 match_flags; | ||
105 | u32 vendor; | ||
106 | u32 model; | ||
107 | u32 specifier_id; | ||
108 | u32 version; | ||
109 | void *driver_data; | ||
110 | }; | ||
111 | |||
112 | struct fw_driver { | ||
113 | struct device_driver driver; | ||
114 | /* Called when the parent device sits through a bus reset. */ | ||
115 | void (*update) (struct fw_unit *unit); | ||
116 | struct fw_device_id *id_table; | ||
117 | }; | ||
118 | |||
119 | static inline struct fw_driver * | ||
120 | fw_driver(struct device_driver *drv) | ||
121 | { | ||
122 | return container_of(drv, struct fw_driver, driver); | ||
123 | } | ||
124 | |||
125 | extern struct file_operations fw_device_ops; | ||
126 | |||
127 | #endif | ||
diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c index 61548c4d18ec..6b638568c2c9 100644 --- a/drivers/firewire/fw-iso.c +++ b/drivers/firewire/fw-iso.c | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "fw-transaction.h" | 27 | #include "fw-transaction.h" |
28 | #include "fw-topology.h" | 28 | #include "fw-topology.h" |
29 | #include "fw-device.h" | ||
29 | 30 | ||
30 | static int | 31 | static int |
31 | setup_iso_buffer(struct fw_iso_context *ctx, size_t size, | 32 | setup_iso_buffer(struct fw_iso_context *ctx, size_t size, |
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c index 2778aa3da8e4..e475025aae91 100644 --- a/drivers/firewire/fw-topology.c +++ b/drivers/firewire/fw-topology.c | |||
@@ -434,13 +434,15 @@ fw_core_handle_bus_reset(struct fw_card *card, | |||
434 | for_each_fw_node(card, local_node, report_found_node); | 434 | for_each_fw_node(card, local_node, report_found_node); |
435 | } else { | 435 | } else { |
436 | update_tree(card, local_node, &changed); | 436 | update_tree(card, local_node, &changed); |
437 | if (changed) | ||
438 | card->irm_retries = 0; | ||
437 | } | 439 | } |
438 | 440 | ||
441 | /* If we're not the root node, we may have to do some IRM work. */ | ||
442 | if (card->local_node != card->root_node) | ||
443 | schedule_delayed_work(&card->work, 0); | ||
444 | |||
439 | spin_unlock_irqrestore(&card->lock, flags); | 445 | spin_unlock_irqrestore(&card->lock, flags); |
440 | } | 446 | } |
441 | 447 | ||
442 | EXPORT_SYMBOL(fw_core_handle_bus_reset); | 448 | EXPORT_SYMBOL(fw_core_handle_bus_reset); |
443 | |||
444 | void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | ||
445 | { | ||
446 | } | ||
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index c3acf7431279..affd42014a67 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include "fw-transaction.h" | 34 | #include "fw-transaction.h" |
35 | #include "fw-topology.h" | 35 | #include "fw-topology.h" |
36 | #include "fw-device.h" | ||
36 | 37 | ||
37 | #define header_pri(pri) ((pri) << 0) | 38 | #define header_pri(pri) ((pri) << 0) |
38 | #define header_tcode(tcode) ((tcode) << 4) | 39 | #define header_tcode(tcode) ((tcode) << 4) |
@@ -702,10 +703,6 @@ static struct fw_descriptor vendor_textual_descriptor = { | |||
702 | .data = vendor_textual_descriptor_data | 703 | .data = vendor_textual_descriptor_data |
703 | }; | 704 | }; |
704 | 705 | ||
705 | struct bus_type fw_bus_type = { | ||
706 | .name = "fw", | ||
707 | }; | ||
708 | |||
709 | static int __init fw_core_init(void) | 706 | static int __init fw_core_init(void) |
710 | { | 707 | { |
711 | int retval; | 708 | int retval; |
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 149ef1652acf..7f618f2373a5 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h | |||
@@ -265,6 +265,10 @@ struct fw_card { | |||
265 | struct device card_device; | 265 | struct device card_device; |
266 | 266 | ||
267 | struct list_head link; | 267 | struct list_head link; |
268 | |||
269 | /* Work struct for IRM duties. */ | ||
270 | struct delayed_work work; | ||
271 | int irm_retries; | ||
268 | }; | 272 | }; |
269 | 273 | ||
270 | struct fw_card *fw_card_get(struct fw_card *card); | 274 | struct fw_card *fw_card_get(struct fw_card *card); |