Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Char device for device raw access |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 3 | * |
Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 4 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 5 | * |
| 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 |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 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, |
| 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/wait.h> |
| 24 | #include <linux/errno.h> |
| 25 | #include <linux/device.h> |
| 26 | #include <linux/vmalloc.h> |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 27 | #include <linux/mutex.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 28 | #include <linux/poll.h> |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 29 | #include <linux/preempt.h> |
| 30 | #include <linux/time.h> |
Jay Fenlason | cf417e54 | 2008-10-03 11:19:09 -0400 | [diff] [blame] | 31 | #include <linux/spinlock.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 32 | #include <linux/delay.h> |
| 33 | #include <linux/mm.h> |
Kristian Høgsberg | a3aca3d | 2007-03-07 12:12:44 -0500 | [diff] [blame] | 34 | #include <linux/idr.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 35 | #include <linux/compat.h> |
Kristian Høgsberg | 9640d3d | 2007-04-30 15:03:15 -0400 | [diff] [blame] | 36 | #include <linux/firewire-cdev.h> |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 37 | #include <asm/system.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 38 | #include <asm/uaccess.h> |
| 39 | #include "fw-transaction.h" |
| 40 | #include "fw-topology.h" |
| 41 | #include "fw-device.h" |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 42 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 43 | struct client; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 44 | struct client_resource; |
| 45 | typedef void (*client_resource_release_fn_t)(struct client *, |
| 46 | struct client_resource *); |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 47 | struct client_resource { |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 48 | client_resource_release_fn_t release; |
| 49 | int handle; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 50 | }; |
| 51 | |
Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 52 | /* |
| 53 | * dequeue_event() just kfree()'s the event, so the event has to be |
| 54 | * the first field in the struct. |
| 55 | */ |
| 56 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 57 | struct event { |
| 58 | struct { void *data; size_t size; } v[2]; |
| 59 | struct list_head link; |
| 60 | }; |
| 61 | |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 62 | struct bus_reset { |
| 63 | struct event event; |
| 64 | struct fw_cdev_event_bus_reset reset; |
| 65 | }; |
| 66 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 67 | struct response { |
| 68 | struct event event; |
| 69 | struct fw_transaction transaction; |
| 70 | struct client *client; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 71 | struct client_resource resource; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 72 | struct fw_cdev_event_response response; |
| 73 | }; |
| 74 | |
| 75 | struct iso_interrupt { |
| 76 | struct event event; |
| 77 | struct fw_cdev_event_iso_interrupt interrupt; |
| 78 | }; |
| 79 | |
| 80 | struct client { |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 81 | u32 version; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 82 | struct fw_device *device; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 83 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 84 | spinlock_t lock; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 85 | bool in_shutdown; |
| 86 | struct idr resource_idr; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 87 | struct list_head event_list; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 88 | wait_queue_head_t wait; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 89 | u64 bus_reset_closure; |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 90 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 91 | struct fw_iso_context *iso_context; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 92 | u64 iso_closure; |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 93 | struct fw_iso_buffer buffer; |
| 94 | unsigned long vm_start; |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 95 | |
| 96 | struct list_head link; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 97 | }; |
| 98 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 99 | static inline void __user *u64_to_uptr(__u64 value) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 100 | { |
| 101 | return (void __user *)(unsigned long)value; |
| 102 | } |
| 103 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 104 | static inline __u64 uptr_to_u64(void __user *ptr) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 105 | { |
| 106 | return (__u64)(unsigned long)ptr; |
| 107 | } |
| 108 | |
| 109 | static int fw_device_op_open(struct inode *inode, struct file *file) |
| 110 | { |
| 111 | struct fw_device *device; |
| 112 | struct client *client; |
| 113 | |
Stefan Richter | 96b1906 | 2008-02-02 15:01:09 +0100 | [diff] [blame] | 114 | device = fw_device_get_by_devt(inode->i_rdev); |
Kristian Høgsberg | a3aca3d | 2007-03-07 12:12:44 -0500 | [diff] [blame] | 115 | if (device == NULL) |
| 116 | return -ENODEV; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 117 | |
Jay Fenlason | 551f4cb | 2008-05-16 11:15:23 -0400 | [diff] [blame] | 118 | if (fw_device_is_shutdown(device)) { |
| 119 | fw_device_put(device); |
| 120 | return -ENODEV; |
| 121 | } |
| 122 | |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 123 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
Stefan Richter | 96b1906 | 2008-02-02 15:01:09 +0100 | [diff] [blame] | 124 | if (client == NULL) { |
| 125 | fw_device_put(device); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 126 | return -ENOMEM; |
Stefan Richter | 96b1906 | 2008-02-02 15:01:09 +0100 | [diff] [blame] | 127 | } |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 128 | |
Stefan Richter | 96b1906 | 2008-02-02 15:01:09 +0100 | [diff] [blame] | 129 | client->device = device; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 130 | spin_lock_init(&client->lock); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 131 | idr_init(&client->resource_idr); |
| 132 | INIT_LIST_HEAD(&client->event_list); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 133 | init_waitqueue_head(&client->wait); |
| 134 | |
| 135 | file->private_data = client; |
| 136 | |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 137 | mutex_lock(&device->client_list_mutex); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 138 | list_add_tail(&client->link, &device->client_list); |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 139 | mutex_unlock(&device->client_list_mutex); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 140 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | static void queue_event(struct client *client, struct event *event, |
| 145 | void *data0, size_t size0, void *data1, size_t size1) |
| 146 | { |
| 147 | unsigned long flags; |
| 148 | |
| 149 | event->v[0].data = data0; |
| 150 | event->v[0].size = size0; |
| 151 | event->v[1].data = data1; |
| 152 | event->v[1].size = size1; |
| 153 | |
| 154 | spin_lock_irqsave(&client->lock, flags); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 155 | if (client->in_shutdown) |
| 156 | kfree(event); |
| 157 | else |
| 158 | list_add_tail(&event->link, &client->event_list); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 159 | spin_unlock_irqrestore(&client->lock, flags); |
Jay Fenlason | 83431cb | 2007-10-08 17:00:29 -0400 | [diff] [blame] | 160 | |
| 161 | wake_up_interruptible(&client->wait); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 162 | } |
| 163 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 164 | static int dequeue_event(struct client *client, |
| 165 | char __user *buffer, size_t count) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 166 | { |
| 167 | unsigned long flags; |
| 168 | struct event *event; |
| 169 | size_t size, total; |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 170 | int i, ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 171 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 172 | ret = wait_event_interruptible(client->wait, |
| 173 | !list_empty(&client->event_list) || |
| 174 | fw_device_is_shutdown(client->device)); |
| 175 | if (ret < 0) |
| 176 | return ret; |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 177 | |
| 178 | if (list_empty(&client->event_list) && |
| 179 | fw_device_is_shutdown(client->device)) |
| 180 | return -ENODEV; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 181 | |
| 182 | spin_lock_irqsave(&client->lock, flags); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 183 | event = container_of(client->event_list.next, struct event, link); |
| 184 | list_del(&event->link); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 185 | spin_unlock_irqrestore(&client->lock, flags); |
| 186 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 187 | total = 0; |
| 188 | for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) { |
| 189 | size = min(event->v[i].size, count - total); |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 190 | if (copy_to_user(buffer + total, event->v[i].data, size)) { |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 191 | ret = -EFAULT; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 192 | goto out; |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 193 | } |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 194 | total += size; |
| 195 | } |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 196 | ret = total; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 197 | |
| 198 | out: |
| 199 | kfree(event); |
| 200 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 201 | return ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 202 | } |
| 203 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 204 | static ssize_t fw_device_op_read(struct file *file, char __user *buffer, |
| 205 | size_t count, loff_t *offset) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 206 | { |
| 207 | struct client *client = file->private_data; |
| 208 | |
| 209 | return dequeue_event(client, buffer, count); |
| 210 | } |
| 211 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 212 | static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event, |
| 213 | struct client *client) |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 214 | { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 215 | struct fw_card *card = client->device->card; |
Jay Fenlason | cf417e54 | 2008-10-03 11:19:09 -0400 | [diff] [blame] | 216 | unsigned long flags; |
| 217 | |
| 218 | spin_lock_irqsave(&card->lock, flags); |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 219 | |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 220 | event->closure = client->bus_reset_closure; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 221 | event->type = FW_CDEV_EVENT_BUS_RESET; |
Stefan Richter | cf5a56a | 2008-01-24 01:53:51 +0100 | [diff] [blame] | 222 | event->generation = client->device->generation; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 223 | event->node_id = client->device->node_id; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 224 | event->local_node_id = card->local_node->node_id; |
| 225 | event->bm_node_id = 0; /* FIXME: We don't track the BM. */ |
| 226 | event->irm_node_id = card->irm_node->node_id; |
| 227 | event->root_node_id = card->root_node->node_id; |
Jay Fenlason | cf417e54 | 2008-10-03 11:19:09 -0400 | [diff] [blame] | 228 | |
| 229 | spin_unlock_irqrestore(&card->lock, flags); |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 230 | } |
| 231 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 232 | static void for_each_client(struct fw_device *device, |
| 233 | void (*callback)(struct client *client)) |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 234 | { |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 235 | struct client *c; |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 236 | |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 237 | mutex_lock(&device->client_list_mutex); |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 238 | list_for_each_entry(c, &device->client_list, link) |
| 239 | callback(c); |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 240 | mutex_unlock(&device->client_list_mutex); |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 241 | } |
| 242 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 243 | static void queue_bus_reset_event(struct client *client) |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 244 | { |
| 245 | struct bus_reset *bus_reset; |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 246 | |
Stefan Richter | d67cfb9 | 2008-10-05 10:37:11 +0200 | [diff] [blame] | 247 | bus_reset = kzalloc(sizeof(*bus_reset), GFP_KERNEL); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 248 | if (bus_reset == NULL) { |
| 249 | fw_notify("Out of memory when allocating bus reset event\n"); |
| 250 | return; |
| 251 | } |
| 252 | |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 253 | fill_bus_reset_event(&bus_reset->reset, client); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 254 | |
| 255 | queue_event(client, &bus_reset->event, |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 256 | &bus_reset->reset, sizeof(bus_reset->reset), NULL, 0); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | void fw_device_cdev_update(struct fw_device *device) |
| 260 | { |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 261 | for_each_client(device, queue_bus_reset_event); |
| 262 | } |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 263 | |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 264 | static void wake_up_client(struct client *client) |
| 265 | { |
| 266 | wake_up_interruptible(&client->wait); |
| 267 | } |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 268 | |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 269 | void fw_device_cdev_remove(struct fw_device *device) |
| 270 | { |
| 271 | for_each_client(device, wake_up_client); |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 272 | } |
| 273 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 274 | static int ioctl_get_info(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 275 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 276 | struct fw_cdev_get_info *get_info = buffer; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 277 | struct fw_cdev_event_bus_reset bus_reset; |
Stefan Richter | c9755e1 | 2008-03-24 20:54:28 +0100 | [diff] [blame] | 278 | unsigned long ret = 0; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 279 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 280 | client->version = get_info->version; |
| 281 | get_info->version = FW_CDEV_VERSION; |
Jay Fenlason | cf417e54 | 2008-10-03 11:19:09 -0400 | [diff] [blame] | 282 | get_info->card = client->device->card->index; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 283 | |
Stefan Richter | c9755e1 | 2008-03-24 20:54:28 +0100 | [diff] [blame] | 284 | down_read(&fw_device_rwsem); |
| 285 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 286 | if (get_info->rom != 0) { |
| 287 | void __user *uptr = u64_to_uptr(get_info->rom); |
| 288 | size_t want = get_info->rom_length; |
Stefan Richter | d84702a | 2007-03-20 19:42:15 +0100 | [diff] [blame] | 289 | size_t have = client->device->config_rom_length * 4; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 290 | |
Stefan Richter | c9755e1 | 2008-03-24 20:54:28 +0100 | [diff] [blame] | 291 | ret = copy_to_user(uptr, client->device->config_rom, |
| 292 | min(want, have)); |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 293 | } |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 294 | get_info->rom_length = client->device->config_rom_length * 4; |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 295 | |
Stefan Richter | c9755e1 | 2008-03-24 20:54:28 +0100 | [diff] [blame] | 296 | up_read(&fw_device_rwsem); |
| 297 | |
| 298 | if (ret != 0) |
| 299 | return -EFAULT; |
| 300 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 301 | client->bus_reset_closure = get_info->bus_reset_closure; |
| 302 | if (get_info->bus_reset != 0) { |
| 303 | void __user *uptr = u64_to_uptr(get_info->bus_reset); |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 304 | |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 305 | fill_bus_reset_event(&bus_reset, client); |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 306 | if (copy_to_user(uptr, &bus_reset, sizeof(bus_reset))) |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 307 | return -EFAULT; |
| 308 | } |
| 309 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 310 | return 0; |
| 311 | } |
| 312 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 313 | static int add_client_resource(struct client *client, |
| 314 | struct client_resource *resource, gfp_t gfp_mask) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 315 | { |
| 316 | unsigned long flags; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 317 | int ret; |
| 318 | |
| 319 | retry: |
| 320 | if (idr_pre_get(&client->resource_idr, gfp_mask) == 0) |
| 321 | return -ENOMEM; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 322 | |
| 323 | spin_lock_irqsave(&client->lock, flags); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 324 | if (client->in_shutdown) |
| 325 | ret = -ECANCELED; |
| 326 | else |
| 327 | ret = idr_get_new(&client->resource_idr, resource, |
| 328 | &resource->handle); |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 329 | spin_unlock_irqrestore(&client->lock, flags); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 330 | |
| 331 | if (ret == -EAGAIN) |
| 332 | goto retry; |
| 333 | |
| 334 | return ret < 0 ? ret : 0; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 335 | } |
| 336 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 337 | static int release_client_resource(struct client *client, u32 handle, |
| 338 | client_resource_release_fn_t release, |
| 339 | struct client_resource **resource) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 340 | { |
| 341 | struct client_resource *r; |
| 342 | unsigned long flags; |
| 343 | |
| 344 | spin_lock_irqsave(&client->lock, flags); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 345 | if (client->in_shutdown) |
| 346 | r = NULL; |
| 347 | else |
| 348 | r = idr_find(&client->resource_idr, handle); |
| 349 | if (r && r->release == release) |
| 350 | idr_remove(&client->resource_idr, handle); |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 351 | spin_unlock_irqrestore(&client->lock, flags); |
| 352 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 353 | if (!(r && r->release == release)) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 354 | return -EINVAL; |
| 355 | |
| 356 | if (resource) |
| 357 | *resource = r; |
| 358 | else |
| 359 | r->release(client, r); |
| 360 | |
| 361 | return 0; |
| 362 | } |
| 363 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 364 | static void release_transaction(struct client *client, |
| 365 | struct client_resource *resource) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 366 | { |
| 367 | struct response *response = |
| 368 | container_of(resource, struct response, resource); |
| 369 | |
| 370 | fw_cancel_transaction(client->device->card, &response->transaction); |
| 371 | } |
| 372 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 373 | static void complete_transaction(struct fw_card *card, int rcode, |
| 374 | void *payload, size_t length, void *data) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 375 | { |
| 376 | struct response *response = data; |
| 377 | struct client *client = response->client; |
Kristian Høgsberg | 28cf6a0 | 2007-03-07 12:12:50 -0500 | [diff] [blame] | 378 | unsigned long flags; |
David Moore | 8401d92 | 2008-07-29 23:46:25 -0700 | [diff] [blame] | 379 | struct fw_cdev_event_response *r = &response->response; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 380 | |
David Moore | 8401d92 | 2008-07-29 23:46:25 -0700 | [diff] [blame] | 381 | if (length < r->length) |
| 382 | r->length = length; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 383 | if (rcode == RCODE_COMPLETE) |
David Moore | 8401d92 | 2008-07-29 23:46:25 -0700 | [diff] [blame] | 384 | memcpy(r->data, payload, r->length); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 385 | |
Kristian Høgsberg | 28cf6a0 | 2007-03-07 12:12:50 -0500 | [diff] [blame] | 386 | spin_lock_irqsave(&client->lock, flags); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 387 | /* |
| 388 | * If called while in shutdown, the idr tree must be left untouched. |
| 389 | * The idr handle will be removed later. |
| 390 | */ |
| 391 | if (!client->in_shutdown) |
| 392 | idr_remove(&client->resource_idr, response->resource.handle); |
Kristian Høgsberg | 28cf6a0 | 2007-03-07 12:12:50 -0500 | [diff] [blame] | 393 | spin_unlock_irqrestore(&client->lock, flags); |
| 394 | |
David Moore | 8401d92 | 2008-07-29 23:46:25 -0700 | [diff] [blame] | 395 | r->type = FW_CDEV_EVENT_RESPONSE; |
| 396 | r->rcode = rcode; |
| 397 | |
| 398 | /* |
| 399 | * In the case that sizeof(*r) doesn't align with the position of the |
| 400 | * data, and the read is short, preserve an extra copy of the data |
| 401 | * to stay compatible with a pre-2.6.27 bug. Since the bug is harmless |
| 402 | * for short reads and some apps depended on it, this is both safe |
| 403 | * and prudent for compatibility. |
| 404 | */ |
| 405 | if (r->length <= sizeof(*r) - offsetof(typeof(*r), data)) |
| 406 | queue_event(client, &response->event, r, sizeof(*r), |
| 407 | r->data, r->length); |
| 408 | else |
| 409 | queue_event(client, &response->event, r, sizeof(*r) + r->length, |
| 410 | NULL, 0); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 411 | } |
| 412 | |
Jeff Garzik | 350958f | 2007-05-27 07:09:18 -0400 | [diff] [blame] | 413 | static int ioctl_send_request(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 414 | { |
| 415 | struct fw_device *device = client->device; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 416 | struct fw_cdev_send_request *request = buffer; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 417 | struct response *response; |
Stefan Richter | 1f3125a | 2008-12-05 22:44:42 +0100 | [diff] [blame] | 418 | int ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 419 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 420 | /* What is the biggest size we'll accept, really? */ |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 421 | if (request->length > 4096) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 422 | return -EINVAL; |
| 423 | |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 424 | response = kmalloc(sizeof(*response) + request->length, GFP_KERNEL); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 425 | if (response == NULL) |
| 426 | return -ENOMEM; |
| 427 | |
| 428 | response->client = client; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 429 | response->response.length = request->length; |
| 430 | response->response.closure = request->closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 431 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 432 | if (request->data && |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 433 | copy_from_user(response->response.data, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 434 | u64_to_uptr(request->data), request->length)) { |
Stefan Richter | 1f3125a | 2008-12-05 22:44:42 +0100 | [diff] [blame] | 435 | ret = -EFAULT; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 436 | goto failed; |
Stefan Richter | 1f3125a | 2008-12-05 22:44:42 +0100 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | switch (request->tcode) { |
| 440 | case TCODE_WRITE_QUADLET_REQUEST: |
| 441 | case TCODE_WRITE_BLOCK_REQUEST: |
| 442 | case TCODE_READ_QUADLET_REQUEST: |
| 443 | case TCODE_READ_BLOCK_REQUEST: |
| 444 | case TCODE_LOCK_MASK_SWAP: |
| 445 | case TCODE_LOCK_COMPARE_SWAP: |
| 446 | case TCODE_LOCK_FETCH_ADD: |
| 447 | case TCODE_LOCK_LITTLE_ADD: |
| 448 | case TCODE_LOCK_BOUNDED_ADD: |
| 449 | case TCODE_LOCK_WRAP_ADD: |
| 450 | case TCODE_LOCK_VENDOR_DEPENDENT: |
| 451 | break; |
| 452 | default: |
| 453 | ret = -EINVAL; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 454 | goto failed; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 455 | } |
| 456 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 457 | response->resource.release = release_transaction; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 458 | ret = add_client_resource(client, &response->resource, GFP_KERNEL); |
| 459 | if (ret < 0) |
| 460 | goto failed; |
Kristian Høgsberg | 28cf6a0 | 2007-03-07 12:12:50 -0500 | [diff] [blame] | 461 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 462 | fw_send_request(device->card, &response->transaction, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 463 | request->tcode & 0x1f, |
Stefan Richter | 907293d | 2007-01-23 21:11:43 +0100 | [diff] [blame] | 464 | device->node->node_id, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 465 | request->generation, |
Stefan Richter | f139749 | 2007-06-10 21:31:36 +0200 | [diff] [blame] | 466 | device->max_speed, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 467 | request->offset, |
| 468 | response->response.data, request->length, |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 469 | complete_transaction, response); |
| 470 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 471 | if (request->data) |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 472 | return sizeof(request) + request->length; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 473 | else |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 474 | return sizeof(request); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 475 | failed: |
Stefan Richter | 1f3125a | 2008-12-05 22:44:42 +0100 | [diff] [blame] | 476 | kfree(response); |
| 477 | |
| 478 | return ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | struct address_handler { |
| 482 | struct fw_address_handler handler; |
| 483 | __u64 closure; |
| 484 | struct client *client; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 485 | struct client_resource resource; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 486 | }; |
| 487 | |
| 488 | struct request { |
| 489 | struct fw_request *request; |
| 490 | void *data; |
| 491 | size_t length; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 492 | struct client_resource resource; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 493 | }; |
| 494 | |
| 495 | struct request_event { |
| 496 | struct event event; |
| 497 | struct fw_cdev_event_request request; |
| 498 | }; |
| 499 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 500 | static void release_request(struct client *client, |
| 501 | struct client_resource *resource) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 502 | { |
| 503 | struct request *request = |
| 504 | container_of(resource, struct request, resource); |
| 505 | |
| 506 | fw_send_response(client->device->card, request->request, |
| 507 | RCODE_CONFLICT_ERROR); |
| 508 | kfree(request); |
| 509 | } |
| 510 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 511 | static void handle_request(struct fw_card *card, struct fw_request *r, |
| 512 | int tcode, int destination, int source, |
| 513 | int generation, int speed, |
| 514 | unsigned long long offset, |
| 515 | void *payload, size_t length, void *callback_data) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 516 | { |
| 517 | struct address_handler *handler = callback_data; |
| 518 | struct request *request; |
| 519 | struct request_event *e; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 520 | struct client *client = handler->client; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 521 | int ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 522 | |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 523 | request = kmalloc(sizeof(*request), GFP_ATOMIC); |
| 524 | e = kmalloc(sizeof(*e), GFP_ATOMIC); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 525 | if (request == NULL || e == NULL) |
| 526 | goto failed; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 527 | |
| 528 | request->request = r; |
| 529 | request->data = payload; |
| 530 | request->length = length; |
| 531 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 532 | request->resource.release = release_request; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 533 | ret = add_client_resource(client, &request->resource, GFP_ATOMIC); |
| 534 | if (ret < 0) |
| 535 | goto failed; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 536 | |
| 537 | e->request.type = FW_CDEV_EVENT_REQUEST; |
| 538 | e->request.tcode = tcode; |
| 539 | e->request.offset = offset; |
| 540 | e->request.length = length; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 541 | e->request.handle = request->resource.handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 542 | e->request.closure = handler->closure; |
| 543 | |
| 544 | queue_event(client, &e->event, |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 545 | &e->request, sizeof(e->request), payload, length); |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 546 | return; |
| 547 | |
| 548 | failed: |
| 549 | kfree(request); |
| 550 | kfree(e); |
| 551 | fw_send_response(card, r, RCODE_CONFLICT_ERROR); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 552 | } |
| 553 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 554 | static void release_address_handler(struct client *client, |
| 555 | struct client_resource *resource) |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 556 | { |
| 557 | struct address_handler *handler = |
| 558 | container_of(resource, struct address_handler, resource); |
| 559 | |
| 560 | fw_core_remove_address_handler(&handler->handler); |
| 561 | kfree(handler); |
| 562 | } |
| 563 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 564 | static int ioctl_allocate(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 565 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 566 | struct fw_cdev_allocate *request = buffer; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 567 | struct address_handler *handler; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 568 | struct fw_address_region region; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 569 | int ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 570 | |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 571 | handler = kmalloc(sizeof(*handler), GFP_KERNEL); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 572 | if (handler == NULL) |
| 573 | return -ENOMEM; |
| 574 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 575 | region.start = request->offset; |
| 576 | region.end = request->offset + request->length; |
| 577 | handler->handler.length = request->length; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 578 | handler->handler.address_callback = handle_request; |
| 579 | handler->handler.callback_data = handler; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 580 | handler->closure = request->closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 581 | handler->client = client; |
| 582 | |
Stefan Richter | 3e0b5f0 | 2008-12-14 19:21:01 +0100 | [diff] [blame] | 583 | ret = fw_core_add_address_handler(&handler->handler, ®ion); |
| 584 | if (ret < 0) { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 585 | kfree(handler); |
Stefan Richter | 3e0b5f0 | 2008-12-14 19:21:01 +0100 | [diff] [blame] | 586 | return ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 587 | } |
| 588 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 589 | handler->resource.release = release_address_handler; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 590 | ret = add_client_resource(client, &handler->resource, GFP_KERNEL); |
| 591 | if (ret < 0) { |
| 592 | release_address_handler(client, &handler->resource); |
| 593 | return ret; |
| 594 | } |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 595 | request->handle = handler->resource.handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 596 | |
| 597 | return 0; |
| 598 | } |
| 599 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 600 | static int ioctl_deallocate(struct client *client, void *buffer) |
Kristian Høgsberg | 9472316 | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 601 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 602 | struct fw_cdev_deallocate *request = buffer; |
Kristian Høgsberg | 9472316 | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 603 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 604 | return release_client_resource(client, request->handle, |
| 605 | release_address_handler, NULL); |
Kristian Høgsberg | 9472316 | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 606 | } |
| 607 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 608 | static int ioctl_send_response(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 609 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 610 | struct fw_cdev_send_response *request = buffer; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 611 | struct client_resource *resource; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 612 | struct request *r; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 613 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 614 | if (release_client_resource(client, request->handle, |
| 615 | release_request, &resource) < 0) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 616 | return -EINVAL; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 617 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 618 | r = container_of(resource, struct request, resource); |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 619 | if (request->length < r->length) |
| 620 | r->length = request->length; |
| 621 | if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 622 | return -EFAULT; |
| 623 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 624 | fw_send_response(client->device->card, r->request, request->rcode); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 625 | kfree(r); |
| 626 | |
| 627 | return 0; |
| 628 | } |
| 629 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 630 | static int ioctl_initiate_bus_reset(struct client *client, void *buffer) |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 631 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 632 | struct fw_cdev_initiate_bus_reset *request = buffer; |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 633 | int short_reset; |
| 634 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 635 | short_reset = (request->type == FW_CDEV_SHORT_RESET); |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 636 | |
| 637 | return fw_core_initiate_bus_reset(client->device->card, short_reset); |
| 638 | } |
| 639 | |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 640 | struct descriptor { |
| 641 | struct fw_descriptor d; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 642 | struct client_resource resource; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 643 | u32 data[0]; |
| 644 | }; |
| 645 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 646 | static void release_descriptor(struct client *client, |
| 647 | struct client_resource *resource) |
| 648 | { |
| 649 | struct descriptor *descriptor = |
| 650 | container_of(resource, struct descriptor, resource); |
| 651 | |
| 652 | fw_core_remove_descriptor(&descriptor->d); |
| 653 | kfree(descriptor); |
| 654 | } |
| 655 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 656 | static int ioctl_add_descriptor(struct client *client, void *buffer) |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 657 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 658 | struct fw_cdev_add_descriptor *request = buffer; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 659 | struct descriptor *descriptor; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 660 | int ret; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 661 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 662 | if (request->length > 256) |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 663 | return -EINVAL; |
| 664 | |
| 665 | descriptor = |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 666 | kmalloc(sizeof(*descriptor) + request->length * 4, GFP_KERNEL); |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 667 | if (descriptor == NULL) |
| 668 | return -ENOMEM; |
| 669 | |
| 670 | if (copy_from_user(descriptor->data, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 671 | u64_to_uptr(request->data), request->length * 4)) { |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 672 | ret = -EFAULT; |
| 673 | goto failed; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 674 | } |
| 675 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 676 | descriptor->d.length = request->length; |
| 677 | descriptor->d.immediate = request->immediate; |
| 678 | descriptor->d.key = request->key; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 679 | descriptor->d.data = descriptor->data; |
| 680 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 681 | ret = fw_core_add_descriptor(&descriptor->d); |
| 682 | if (ret < 0) |
| 683 | goto failed; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 684 | |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 685 | descriptor->resource.release = release_descriptor; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 686 | ret = add_client_resource(client, &descriptor->resource, GFP_KERNEL); |
| 687 | if (ret < 0) { |
| 688 | fw_core_remove_descriptor(&descriptor->d); |
| 689 | goto failed; |
| 690 | } |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 691 | request->handle = descriptor->resource.handle; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 692 | |
| 693 | return 0; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 694 | failed: |
| 695 | kfree(descriptor); |
| 696 | |
| 697 | return ret; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 698 | } |
| 699 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 700 | static int ioctl_remove_descriptor(struct client *client, void *buffer) |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 701 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 702 | struct fw_cdev_remove_descriptor *request = buffer; |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 703 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 704 | return release_client_resource(client, request->handle, |
| 705 | release_descriptor, NULL); |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 706 | } |
| 707 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 708 | static void iso_callback(struct fw_iso_context *context, u32 cycle, |
| 709 | size_t header_length, void *header, void *data) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 710 | { |
| 711 | struct client *client = data; |
Stefan Richter | 930e4b7 | 2007-08-03 20:56:31 +0200 | [diff] [blame] | 712 | struct iso_interrupt *irq; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 713 | |
Stefan Richter | 930e4b7 | 2007-08-03 20:56:31 +0200 | [diff] [blame] | 714 | irq = kzalloc(sizeof(*irq) + header_length, GFP_ATOMIC); |
| 715 | if (irq == NULL) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 716 | return; |
| 717 | |
Stefan Richter | 930e4b7 | 2007-08-03 20:56:31 +0200 | [diff] [blame] | 718 | irq->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; |
| 719 | irq->interrupt.closure = client->iso_closure; |
| 720 | irq->interrupt.cycle = cycle; |
| 721 | irq->interrupt.header_length = header_length; |
| 722 | memcpy(irq->interrupt.header, header, header_length); |
| 723 | queue_event(client, &irq->event, &irq->interrupt, |
| 724 | sizeof(irq->interrupt) + header_length, NULL, 0); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 725 | } |
| 726 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 727 | static int ioctl_create_iso_context(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 728 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 729 | struct fw_cdev_create_iso_context *request = buffer; |
Kristian Høgsberg | 24315c5 | 2007-06-20 17:48:07 -0400 | [diff] [blame] | 730 | struct fw_iso_context *context; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 731 | |
Stefan Richter | fae6031 | 2008-02-20 21:10:06 +0100 | [diff] [blame] | 732 | /* We only support one context at this time. */ |
| 733 | if (client->iso_context != NULL) |
| 734 | return -EBUSY; |
| 735 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 736 | if (request->channel > 63) |
Kristian Høgsberg | 21efb3c | 2007-02-16 17:34:50 -0500 | [diff] [blame] | 737 | return -EINVAL; |
| 738 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 739 | switch (request->type) { |
Kristian Høgsberg | c70dc78 | 2007-03-14 17:34:53 -0400 | [diff] [blame] | 740 | case FW_ISO_CONTEXT_RECEIVE: |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 741 | if (request->header_size < 4 || (request->header_size & 3)) |
Kristian Høgsberg | c70dc78 | 2007-03-14 17:34:53 -0400 | [diff] [blame] | 742 | return -EINVAL; |
| 743 | |
| 744 | break; |
| 745 | |
| 746 | case FW_ISO_CONTEXT_TRANSMIT: |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 747 | if (request->speed > SCODE_3200) |
Kristian Høgsberg | c70dc78 | 2007-03-14 17:34:53 -0400 | [diff] [blame] | 748 | return -EINVAL; |
| 749 | |
| 750 | break; |
| 751 | |
| 752 | default: |
Kristian Høgsberg | 21efb3c | 2007-02-16 17:34:50 -0500 | [diff] [blame] | 753 | return -EINVAL; |
Kristian Høgsberg | c70dc78 | 2007-03-14 17:34:53 -0400 | [diff] [blame] | 754 | } |
| 755 | |
Kristian Høgsberg | 24315c5 | 2007-06-20 17:48:07 -0400 | [diff] [blame] | 756 | context = fw_iso_context_create(client->device->card, |
| 757 | request->type, |
| 758 | request->channel, |
| 759 | request->speed, |
| 760 | request->header_size, |
| 761 | iso_callback, client); |
| 762 | if (IS_ERR(context)) |
| 763 | return PTR_ERR(context); |
| 764 | |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 765 | client->iso_closure = request->closure; |
Kristian Høgsberg | 24315c5 | 2007-06-20 17:48:07 -0400 | [diff] [blame] | 766 | client->iso_context = context; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 767 | |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 768 | /* We only support one context at this time. */ |
| 769 | request->handle = 0; |
| 770 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 771 | return 0; |
| 772 | } |
| 773 | |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 774 | /* Macros for decoding the iso packet control header. */ |
| 775 | #define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff) |
| 776 | #define GET_INTERRUPT(v) (((v) >> 16) & 0x01) |
| 777 | #define GET_SKIP(v) (((v) >> 17) & 0x01) |
Stefan Richter | 7a10034 | 2008-09-12 18:09:55 +0200 | [diff] [blame] | 778 | #define GET_TAG(v) (((v) >> 18) & 0x03) |
| 779 | #define GET_SY(v) (((v) >> 20) & 0x0f) |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 780 | #define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff) |
| 781 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 782 | static int ioctl_queue_iso(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 783 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 784 | struct fw_cdev_queue_iso *request = buffer; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 785 | struct fw_cdev_iso_packet __user *p, *end, *next; |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 786 | struct fw_iso_context *ctx = client->iso_context; |
Kristian Høgsberg | ef370ee | 2007-03-28 20:46:23 +0200 | [diff] [blame] | 787 | unsigned long payload, buffer_end, header_length; |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 788 | u32 control; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 789 | int count; |
| 790 | struct { |
| 791 | struct fw_iso_packet packet; |
| 792 | u8 header[256]; |
| 793 | } u; |
| 794 | |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 795 | if (ctx == NULL || request->handle != 0) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 796 | return -EINVAL; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 797 | |
Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 798 | /* |
| 799 | * If the user passes a non-NULL data pointer, has mmap()'ed |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 800 | * the iso buffer, and the pointer points inside the buffer, |
| 801 | * we setup the payload pointers accordingly. Otherwise we |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 802 | * set them both to 0, which will still let packets with |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 803 | * payload_length == 0 through. In other words, if no packets |
| 804 | * use the indirect payload, the iso buffer need not be mapped |
Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 805 | * and the request->data pointer is ignored. |
| 806 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 807 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 808 | payload = (unsigned long)request->data - client->vm_start; |
Kristian Høgsberg | ef370ee | 2007-03-28 20:46:23 +0200 | [diff] [blame] | 809 | buffer_end = client->buffer.page_count << PAGE_SHIFT; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 810 | if (request->data == 0 || client->buffer.pages == NULL || |
Kristian Høgsberg | ef370ee | 2007-03-28 20:46:23 +0200 | [diff] [blame] | 811 | payload >= buffer_end) { |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 812 | payload = 0; |
Kristian Høgsberg | ef370ee | 2007-03-28 20:46:23 +0200 | [diff] [blame] | 813 | buffer_end = 0; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 814 | } |
| 815 | |
Al Viro | 1ccc914 | 2007-10-14 19:34:40 +0100 | [diff] [blame] | 816 | p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(request->packets); |
| 817 | |
| 818 | if (!access_ok(VERIFY_READ, p, request->size)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 819 | return -EFAULT; |
| 820 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 821 | end = (void __user *)p + request->size; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 822 | count = 0; |
| 823 | while (p < end) { |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 824 | if (get_user(control, &p->control)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 825 | return -EFAULT; |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 826 | u.packet.payload_length = GET_PAYLOAD_LENGTH(control); |
| 827 | u.packet.interrupt = GET_INTERRUPT(control); |
| 828 | u.packet.skip = GET_SKIP(control); |
| 829 | u.packet.tag = GET_TAG(control); |
| 830 | u.packet.sy = GET_SY(control); |
| 831 | u.packet.header_length = GET_HEADER_LENGTH(control); |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 832 | |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 833 | if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 834 | header_length = u.packet.header_length; |
| 835 | } else { |
Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 836 | /* |
| 837 | * We require that header_length is a multiple of |
| 838 | * the fixed header size, ctx->header_size. |
| 839 | */ |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 840 | if (ctx->header_size == 0) { |
| 841 | if (u.packet.header_length > 0) |
| 842 | return -EINVAL; |
| 843 | } else if (u.packet.header_length % ctx->header_size != 0) { |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 844 | return -EINVAL; |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 845 | } |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 846 | header_length = 0; |
| 847 | } |
| 848 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 849 | next = (struct fw_cdev_iso_packet __user *) |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 850 | &p->header[header_length / 4]; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 851 | if (next > end) |
| 852 | return -EINVAL; |
| 853 | if (__copy_from_user |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 854 | (u.packet.header, p->header, header_length)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 855 | return -EFAULT; |
Kristian Høgsberg | 98b6cbe | 2007-02-16 17:34:51 -0500 | [diff] [blame] | 856 | if (u.packet.skip && ctx->type == FW_ISO_CONTEXT_TRANSMIT && |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 857 | u.packet.header_length + u.packet.payload_length > 0) |
| 858 | return -EINVAL; |
Kristian Høgsberg | ef370ee | 2007-03-28 20:46:23 +0200 | [diff] [blame] | 859 | if (payload + u.packet.payload_length > buffer_end) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 860 | return -EINVAL; |
| 861 | |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 862 | if (fw_iso_context_queue(ctx, &u.packet, |
| 863 | &client->buffer, payload)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 864 | break; |
| 865 | |
| 866 | p = next; |
| 867 | payload += u.packet.payload_length; |
| 868 | count++; |
| 869 | } |
| 870 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 871 | request->size -= uptr_to_u64(p) - request->packets; |
| 872 | request->packets = uptr_to_u64(p); |
| 873 | request->data = client->vm_start + payload; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 874 | |
| 875 | return count; |
| 876 | } |
| 877 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 878 | static int ioctl_start_iso(struct client *client, void *buffer) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 879 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 880 | struct fw_cdev_start_iso *request = buffer; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 881 | |
Stefan Richter | fae6031 | 2008-02-20 21:10:06 +0100 | [diff] [blame] | 882 | if (client->iso_context == NULL || request->handle != 0) |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 883 | return -EINVAL; |
Stefan Richter | fae6031 | 2008-02-20 21:10:06 +0100 | [diff] [blame] | 884 | |
Kristian Høgsberg | eb0306e | 2007-03-14 17:34:54 -0400 | [diff] [blame] | 885 | if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE) { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 886 | if (request->tags == 0 || request->tags > 15) |
Kristian Høgsberg | eb0306e | 2007-03-14 17:34:54 -0400 | [diff] [blame] | 887 | return -EINVAL; |
| 888 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 889 | if (request->sync > 15) |
Kristian Høgsberg | eb0306e | 2007-03-14 17:34:54 -0400 | [diff] [blame] | 890 | return -EINVAL; |
| 891 | } |
| 892 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 893 | return fw_iso_context_start(client->iso_context, request->cycle, |
| 894 | request->sync, request->tags); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 895 | } |
| 896 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 897 | static int ioctl_stop_iso(struct client *client, void *buffer) |
Kristian Høgsberg | b829566 | 2007-02-16 17:34:42 -0500 | [diff] [blame] | 898 | { |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 899 | struct fw_cdev_stop_iso *request = buffer; |
| 900 | |
Stefan Richter | fae6031 | 2008-02-20 21:10:06 +0100 | [diff] [blame] | 901 | if (client->iso_context == NULL || request->handle != 0) |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 902 | return -EINVAL; |
| 903 | |
Kristian Høgsberg | b829566 | 2007-02-16 17:34:42 -0500 | [diff] [blame] | 904 | return fw_iso_context_stop(client->iso_context); |
| 905 | } |
| 906 | |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 907 | static int ioctl_get_cycle_timer(struct client *client, void *buffer) |
| 908 | { |
| 909 | struct fw_cdev_get_cycle_timer *request = buffer; |
| 910 | struct fw_card *card = client->device->card; |
| 911 | unsigned long long bus_time; |
| 912 | struct timeval tv; |
| 913 | unsigned long flags; |
| 914 | |
| 915 | preempt_disable(); |
| 916 | local_irq_save(flags); |
| 917 | |
| 918 | bus_time = card->driver->get_bus_time(card); |
| 919 | do_gettimeofday(&tv); |
| 920 | |
| 921 | local_irq_restore(flags); |
| 922 | preempt_enable(); |
| 923 | |
| 924 | request->local_time = tv.tv_sec * 1000000ULL + tv.tv_usec; |
| 925 | request->cycle_timer = bus_time & 0xffffffff; |
| 926 | return 0; |
| 927 | } |
| 928 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 929 | static int (* const ioctl_handlers[])(struct client *client, void *buffer) = { |
| 930 | ioctl_get_info, |
| 931 | ioctl_send_request, |
| 932 | ioctl_allocate, |
| 933 | ioctl_deallocate, |
| 934 | ioctl_send_response, |
| 935 | ioctl_initiate_bus_reset, |
| 936 | ioctl_add_descriptor, |
| 937 | ioctl_remove_descriptor, |
| 938 | ioctl_create_iso_context, |
| 939 | ioctl_queue_iso, |
| 940 | ioctl_start_iso, |
| 941 | ioctl_stop_iso, |
Stefan Richter | a64408b | 2007-09-29 10:41:58 +0200 | [diff] [blame] | 942 | ioctl_get_cycle_timer, |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 943 | }; |
| 944 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 945 | static int dispatch_ioctl(struct client *client, |
| 946 | unsigned int cmd, void __user *arg) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 947 | { |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 948 | char buffer[256]; |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 949 | int ret; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 950 | |
| 951 | if (_IOC_TYPE(cmd) != '#' || |
| 952 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers)) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 953 | return -EINVAL; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 954 | |
| 955 | if (_IOC_DIR(cmd) & _IOC_WRITE) { |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 956 | if (_IOC_SIZE(cmd) > sizeof(buffer) || |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 957 | copy_from_user(buffer, arg, _IOC_SIZE(cmd))) |
| 958 | return -EFAULT; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 959 | } |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 960 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 961 | ret = ioctl_handlers[_IOC_NR(cmd)](client, buffer); |
| 962 | if (ret < 0) |
| 963 | return ret; |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 964 | |
| 965 | if (_IOC_DIR(cmd) & _IOC_READ) { |
Kristian Høgsberg | 2d826cc | 2007-05-09 19:23:14 -0400 | [diff] [blame] | 966 | if (_IOC_SIZE(cmd) > sizeof(buffer) || |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 967 | copy_to_user(arg, buffer, _IOC_SIZE(cmd))) |
| 968 | return -EFAULT; |
| 969 | } |
| 970 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 971 | return ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 972 | } |
| 973 | |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 974 | static long fw_device_op_ioctl(struct file *file, |
| 975 | unsigned int cmd, unsigned long arg) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 976 | { |
| 977 | struct client *client = file->private_data; |
| 978 | |
Jay Fenlason | 551f4cb | 2008-05-16 11:15:23 -0400 | [diff] [blame] | 979 | if (fw_device_is_shutdown(client->device)) |
| 980 | return -ENODEV; |
| 981 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 982 | return dispatch_ioctl(client, cmd, (void __user *) arg); |
| 983 | } |
| 984 | |
| 985 | #ifdef CONFIG_COMPAT |
Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame^] | 986 | static long fw_device_op_compat_ioctl(struct file *file, |
| 987 | unsigned int cmd, unsigned long arg) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 988 | { |
| 989 | struct client *client = file->private_data; |
| 990 | |
Jay Fenlason | 551f4cb | 2008-05-16 11:15:23 -0400 | [diff] [blame] | 991 | if (fw_device_is_shutdown(client->device)) |
| 992 | return -ENODEV; |
| 993 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 994 | return dispatch_ioctl(client, cmd, compat_ptr(arg)); |
| 995 | } |
| 996 | #endif |
| 997 | |
| 998 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) |
| 999 | { |
| 1000 | struct client *client = file->private_data; |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1001 | enum dma_data_direction direction; |
| 1002 | unsigned long size; |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 1003 | int page_count, ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1004 | |
Jay Fenlason | 551f4cb | 2008-05-16 11:15:23 -0400 | [diff] [blame] | 1005 | if (fw_device_is_shutdown(client->device)) |
| 1006 | return -ENODEV; |
| 1007 | |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1008 | /* FIXME: We could support multiple buffers, but we don't. */ |
| 1009 | if (client->buffer.pages != NULL) |
| 1010 | return -EBUSY; |
| 1011 | |
| 1012 | if (!(vma->vm_flags & VM_SHARED)) |
| 1013 | return -EINVAL; |
| 1014 | |
| 1015 | if (vma->vm_start & ~PAGE_MASK) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1016 | return -EINVAL; |
| 1017 | |
| 1018 | client->vm_start = vma->vm_start; |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1019 | size = vma->vm_end - vma->vm_start; |
| 1020 | page_count = size >> PAGE_SHIFT; |
| 1021 | if (size & ~PAGE_MASK) |
| 1022 | return -EINVAL; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1023 | |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1024 | if (vma->vm_flags & VM_WRITE) |
| 1025 | direction = DMA_TO_DEVICE; |
| 1026 | else |
| 1027 | direction = DMA_FROM_DEVICE; |
| 1028 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 1029 | ret = fw_iso_buffer_init(&client->buffer, client->device->card, |
| 1030 | page_count, direction); |
| 1031 | if (ret < 0) |
| 1032 | return ret; |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1033 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 1034 | ret = fw_iso_buffer_map(&client->buffer, vma); |
| 1035 | if (ret < 0) |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1036 | fw_iso_buffer_destroy(&client->buffer, client->device->card); |
| 1037 | |
Stefan Richter | 2dbd7d7 | 2008-12-14 21:45:45 +0100 | [diff] [blame] | 1038 | return ret; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1039 | } |
| 1040 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 1041 | static int shutdown_resource(int id, void *p, void *data) |
| 1042 | { |
| 1043 | struct client_resource *r = p; |
| 1044 | struct client *client = data; |
| 1045 | |
| 1046 | r->release(client, r); |
| 1047 | |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1051 | static int fw_device_op_release(struct inode *inode, struct file *file) |
| 1052 | { |
| 1053 | struct client *client = file->private_data; |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 1054 | struct event *e, *next_e; |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 1055 | unsigned long flags; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1056 | |
Stefan Richter | 97811e3 | 2008-12-14 19:19:23 +0100 | [diff] [blame] | 1057 | mutex_lock(&client->device->client_list_mutex); |
| 1058 | list_del(&client->link); |
| 1059 | mutex_unlock(&client->device->client_list_mutex); |
| 1060 | |
Kristian Høgsberg | 9aad812 | 2007-02-16 17:34:38 -0500 | [diff] [blame] | 1061 | if (client->buffer.pages) |
| 1062 | fw_iso_buffer_destroy(&client->buffer, client->device->card); |
| 1063 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1064 | if (client->iso_context) |
| 1065 | fw_iso_context_destroy(client->iso_context); |
| 1066 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 1067 | /* Freeze client->resource_idr and client->event_list */ |
| 1068 | spin_lock_irqsave(&client->lock, flags); |
| 1069 | client->in_shutdown = true; |
| 1070 | spin_unlock_irqrestore(&client->lock, flags); |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 1071 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 1072 | idr_for_each(&client->resource_idr, shutdown_resource, client); |
| 1073 | idr_remove_all(&client->resource_idr); |
| 1074 | idr_destroy(&client->resource_idr); |
Kristian Høgsberg | 28cf6a0 | 2007-03-07 12:12:50 -0500 | [diff] [blame] | 1075 | |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 1076 | list_for_each_entry_safe(e, next_e, &client->event_list, link) |
| 1077 | kfree(e); |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1078 | |
Jay Fenlason | 45ee319 | 2008-12-21 16:47:17 +0100 | [diff] [blame] | 1079 | /* |
| 1080 | * FIXME: client should be reference-counted. It's extremely unlikely |
| 1081 | * but there may still be transactions being completed at this point. |
| 1082 | */ |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1083 | fw_device_put(client->device); |
| 1084 | kfree(client); |
| 1085 | |
| 1086 | return 0; |
| 1087 | } |
| 1088 | |
| 1089 | static unsigned int fw_device_op_poll(struct file *file, poll_table * pt) |
| 1090 | { |
| 1091 | struct client *client = file->private_data; |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 1092 | unsigned int mask = 0; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1093 | |
| 1094 | poll_wait(file, &client->wait, pt); |
| 1095 | |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 1096 | if (fw_device_is_shutdown(client->device)) |
| 1097 | mask |= POLLHUP | POLLERR; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1098 | if (!list_empty(&client->event_list)) |
Kristian Høgsberg | 2603bf2 | 2007-03-07 12:12:48 -0500 | [diff] [blame] | 1099 | mask |= POLLIN | POLLRDNORM; |
| 1100 | |
| 1101 | return mask; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1102 | } |
| 1103 | |
Stefan Richter | 21ebcd1 | 2007-01-14 15:29:07 +0100 | [diff] [blame] | 1104 | const struct file_operations fw_device_ops = { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1105 | .owner = THIS_MODULE, |
| 1106 | .open = fw_device_op_open, |
| 1107 | .read = fw_device_op_read, |
| 1108 | .unlocked_ioctl = fw_device_op_ioctl, |
| 1109 | .poll = fw_device_op_poll, |
| 1110 | .release = fw_device_op_release, |
| 1111 | .mmap = fw_device_op_mmap, |
| 1112 | |
| 1113 | #ifdef CONFIG_COMPAT |
Stefan Richter | 5af4e5e | 2007-01-21 20:45:32 +0100 | [diff] [blame] | 1114 | .compat_ioctl = fw_device_op_compat_ioctl, |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 1115 | #endif |
| 1116 | }; |