diff options
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-cdev.c | 24 | ||||
-rw-r--r-- | drivers/firewire/core-device.c | 104 | ||||
-rw-r--r-- | drivers/firewire/core-iso.c | 6 | ||||
-rw-r--r-- | drivers/firewire/net.c | 1 | ||||
-rw-r--r-- | drivers/firewire/ohci.c | 6 |
5 files changed, 65 insertions, 76 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 8be720b278b7..14a34d99eea2 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/poll.h> | 35 | #include <linux/poll.h> |
36 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
37 | #include <linux/slab.h> | ||
37 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
38 | #include <linux/string.h> | 39 | #include <linux/string.h> |
39 | #include <linux/time.h> | 40 | #include <linux/time.h> |
@@ -959,6 +960,8 @@ static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg) | |||
959 | u.packet.header_length = GET_HEADER_LENGTH(control); | 960 | u.packet.header_length = GET_HEADER_LENGTH(control); |
960 | 961 | ||
961 | if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { | 962 | if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { |
963 | if (u.packet.header_length % 4 != 0) | ||
964 | return -EINVAL; | ||
962 | header_length = u.packet.header_length; | 965 | header_length = u.packet.header_length; |
963 | } else { | 966 | } else { |
964 | /* | 967 | /* |
@@ -968,7 +971,8 @@ static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg) | |||
968 | if (ctx->header_size == 0) { | 971 | if (ctx->header_size == 0) { |
969 | if (u.packet.header_length > 0) | 972 | if (u.packet.header_length > 0) |
970 | return -EINVAL; | 973 | return -EINVAL; |
971 | } else if (u.packet.header_length % ctx->header_size != 0) { | 974 | } else if (u.packet.header_length == 0 || |
975 | u.packet.header_length % ctx->header_size != 0) { | ||
972 | return -EINVAL; | 976 | return -EINVAL; |
973 | } | 977 | } |
974 | header_length = 0; | 978 | header_length = 0; |
@@ -1353,24 +1357,24 @@ static int dispatch_ioctl(struct client *client, | |||
1353 | return -ENODEV; | 1357 | return -ENODEV; |
1354 | 1358 | ||
1355 | if (_IOC_TYPE(cmd) != '#' || | 1359 | if (_IOC_TYPE(cmd) != '#' || |
1356 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers)) | 1360 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || |
1361 | _IOC_SIZE(cmd) > sizeof(buffer)) | ||
1357 | return -EINVAL; | 1362 | return -EINVAL; |
1358 | 1363 | ||
1359 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | 1364 | if (_IOC_DIR(cmd) == _IOC_READ) |
1360 | if (_IOC_SIZE(cmd) > sizeof(buffer) || | 1365 | memset(&buffer, 0, _IOC_SIZE(cmd)); |
1361 | copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) | 1366 | |
1367 | if (_IOC_DIR(cmd) & _IOC_WRITE) | ||
1368 | if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) | ||
1362 | return -EFAULT; | 1369 | return -EFAULT; |
1363 | } | ||
1364 | 1370 | ||
1365 | ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); | 1371 | ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); |
1366 | if (ret < 0) | 1372 | if (ret < 0) |
1367 | return ret; | 1373 | return ret; |
1368 | 1374 | ||
1369 | if (_IOC_DIR(cmd) & _IOC_READ) { | 1375 | if (_IOC_DIR(cmd) & _IOC_READ) |
1370 | if (_IOC_SIZE(cmd) > sizeof(buffer) || | 1376 | if (copy_to_user(arg, &buffer, _IOC_SIZE(cmd))) |
1371 | copy_to_user(arg, &buffer, _IOC_SIZE(cmd))) | ||
1372 | return -EFAULT; | 1377 | return -EFAULT; |
1373 | } | ||
1374 | 1378 | ||
1375 | return ret; | 1379 | return ret; |
1376 | } | 1380 | } |
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 5db0518c66da..4b8523f00dce 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/rwsem.h> | 35 | #include <linux/rwsem.h> |
36 | #include <linux/slab.h> | ||
36 | #include <linux/spinlock.h> | 37 | #include <linux/spinlock.h> |
37 | #include <linux/string.h> | 38 | #include <linux/string.h> |
38 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
@@ -126,97 +127,74 @@ int fw_csr_string(const u32 *directory, int key, char *buf, size_t size) | |||
126 | } | 127 | } |
127 | EXPORT_SYMBOL(fw_csr_string); | 128 | EXPORT_SYMBOL(fw_csr_string); |
128 | 129 | ||
129 | static bool is_fw_unit(struct device *dev); | 130 | static void get_ids(const u32 *directory, int *id) |
130 | |||
131 | static int match_unit_directory(const u32 *directory, u32 match_flags, | ||
132 | const struct ieee1394_device_id *id) | ||
133 | { | 131 | { |
134 | struct fw_csr_iterator ci; | 132 | struct fw_csr_iterator ci; |
135 | int key, value, match; | 133 | int key, value; |
136 | 134 | ||
137 | match = 0; | ||
138 | fw_csr_iterator_init(&ci, directory); | 135 | fw_csr_iterator_init(&ci, directory); |
139 | while (fw_csr_iterator_next(&ci, &key, &value)) { | 136 | while (fw_csr_iterator_next(&ci, &key, &value)) { |
140 | if (key == CSR_VENDOR && value == id->vendor_id) | 137 | switch (key) { |
141 | match |= IEEE1394_MATCH_VENDOR_ID; | 138 | case CSR_VENDOR: id[0] = value; break; |
142 | if (key == CSR_MODEL && value == id->model_id) | 139 | case CSR_MODEL: id[1] = value; break; |
143 | match |= IEEE1394_MATCH_MODEL_ID; | 140 | case CSR_SPECIFIER_ID: id[2] = value; break; |
144 | if (key == CSR_SPECIFIER_ID && value == id->specifier_id) | 141 | case CSR_VERSION: id[3] = value; break; |
145 | match |= IEEE1394_MATCH_SPECIFIER_ID; | 142 | } |
146 | if (key == CSR_VERSION && value == id->version) | ||
147 | match |= IEEE1394_MATCH_VERSION; | ||
148 | } | 143 | } |
144 | } | ||
145 | |||
146 | static void get_modalias_ids(struct fw_unit *unit, int *id) | ||
147 | { | ||
148 | get_ids(&fw_parent_device(unit)->config_rom[5], id); | ||
149 | get_ids(unit->directory, id); | ||
150 | } | ||
151 | |||
152 | static bool match_ids(const struct ieee1394_device_id *id_table, int *id) | ||
153 | { | ||
154 | int match = 0; | ||
155 | |||
156 | if (id[0] == id_table->vendor_id) | ||
157 | match |= IEEE1394_MATCH_VENDOR_ID; | ||
158 | if (id[1] == id_table->model_id) | ||
159 | match |= IEEE1394_MATCH_MODEL_ID; | ||
160 | if (id[2] == id_table->specifier_id) | ||
161 | match |= IEEE1394_MATCH_SPECIFIER_ID; | ||
162 | if (id[3] == id_table->version) | ||
163 | match |= IEEE1394_MATCH_VERSION; | ||
149 | 164 | ||
150 | return (match & match_flags) == match_flags; | 165 | return (match & id_table->match_flags) == id_table->match_flags; |
151 | } | 166 | } |
152 | 167 | ||
168 | static bool is_fw_unit(struct device *dev); | ||
169 | |||
153 | static int fw_unit_match(struct device *dev, struct device_driver *drv) | 170 | static int fw_unit_match(struct device *dev, struct device_driver *drv) |
154 | { | 171 | { |
155 | struct fw_unit *unit = fw_unit(dev); | 172 | const struct ieee1394_device_id *id_table = |
156 | struct fw_device *device; | 173 | container_of(drv, struct fw_driver, driver)->id_table; |
157 | const struct ieee1394_device_id *id; | 174 | int id[] = {0, 0, 0, 0}; |
158 | 175 | ||
159 | /* We only allow binding to fw_units. */ | 176 | /* We only allow binding to fw_units. */ |
160 | if (!is_fw_unit(dev)) | 177 | if (!is_fw_unit(dev)) |
161 | return 0; | 178 | return 0; |
162 | 179 | ||
163 | device = fw_parent_device(unit); | 180 | get_modalias_ids(fw_unit(dev), id); |
164 | id = container_of(drv, struct fw_driver, driver)->id_table; | ||
165 | 181 | ||
166 | for (; id->match_flags != 0; id++) { | 182 | for (; id_table->match_flags != 0; id_table++) |
167 | if (match_unit_directory(unit->directory, id->match_flags, id)) | 183 | if (match_ids(id_table, id)) |
168 | return 1; | 184 | return 1; |
169 | 185 | ||
170 | /* Also check vendor ID in the root directory. */ | ||
171 | if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) && | ||
172 | match_unit_directory(&device->config_rom[5], | ||
173 | IEEE1394_MATCH_VENDOR_ID, id) && | ||
174 | match_unit_directory(unit->directory, id->match_flags | ||
175 | & ~IEEE1394_MATCH_VENDOR_ID, id)) | ||
176 | return 1; | ||
177 | } | ||
178 | |||
179 | return 0; | 186 | return 0; |
180 | } | 187 | } |
181 | 188 | ||
182 | static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) | 189 | static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) |
183 | { | 190 | { |
184 | struct fw_device *device = fw_parent_device(unit); | 191 | int id[] = {0, 0, 0, 0}; |
185 | struct fw_csr_iterator ci; | ||
186 | 192 | ||
187 | int key, value; | 193 | get_modalias_ids(unit, id); |
188 | int vendor = 0; | ||
189 | int model = 0; | ||
190 | int specifier_id = 0; | ||
191 | int version = 0; | ||
192 | |||
193 | fw_csr_iterator_init(&ci, &device->config_rom[5]); | ||
194 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
195 | switch (key) { | ||
196 | case CSR_VENDOR: | ||
197 | vendor = value; | ||
198 | break; | ||
199 | case CSR_MODEL: | ||
200 | model = value; | ||
201 | break; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | fw_csr_iterator_init(&ci, unit->directory); | ||
206 | while (fw_csr_iterator_next(&ci, &key, &value)) { | ||
207 | switch (key) { | ||
208 | case CSR_SPECIFIER_ID: | ||
209 | specifier_id = value; | ||
210 | break; | ||
211 | case CSR_VERSION: | ||
212 | version = value; | ||
213 | break; | ||
214 | } | ||
215 | } | ||
216 | 194 | ||
217 | return snprintf(buffer, buffer_size, | 195 | return snprintf(buffer, buffer_size, |
218 | "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", | 196 | "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", |
219 | vendor, model, specifier_id, version); | 197 | id[0], id[1], id[2], id[3]); |
220 | } | 198 | } |
221 | 199 | ||
222 | static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) | 200 | static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) |
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 1c0b504a42f3..3784a47865b7 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/firewire-constants.h> | 26 | #include <linux/firewire-constants.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/slab.h> | ||
29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
30 | #include <linux/vmalloc.h> | 31 | #include <linux/vmalloc.h> |
31 | 32 | ||
@@ -331,8 +332,9 @@ void fw_iso_resource_manage(struct fw_card *card, int generation, | |||
331 | if (ret < 0) | 332 | if (ret < 0) |
332 | *bandwidth = 0; | 333 | *bandwidth = 0; |
333 | 334 | ||
334 | if (allocate && ret < 0 && c >= 0) { | 335 | if (allocate && ret < 0) { |
335 | deallocate_channel(card, irm_id, generation, c, buffer); | 336 | if (c >= 0) |
337 | deallocate_channel(card, irm_id, generation, c, buffer); | ||
336 | *channel = ret; | 338 | *channel = ret; |
337 | } | 339 | } |
338 | } | 340 | } |
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index 2d3dc7ded0a9..7142eeec8074 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/netdevice.h> | 22 | #include <linux/netdevice.h> |
23 | #include <linux/skbuff.h> | 23 | #include <linux/skbuff.h> |
24 | #include <linux/slab.h> | ||
24 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
25 | 26 | ||
26 | #include <asm/unaligned.h> | 27 | #include <asm/unaligned.h> |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 8e180a27be7c..c9388fbb3bcc 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
25 | #include <linux/firewire.h> | 25 | #include <linux/firewire.h> |
26 | #include <linux/firewire-constants.h> | 26 | #include <linux/firewire-constants.h> |
27 | #include <linux/gfp.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
30 | #include <linux/io.h> | 29 | #include <linux/io.h> |
@@ -35,6 +34,7 @@ | |||
35 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/pci_ids.h> | 36 | #include <linux/pci_ids.h> |
37 | #include <linux/slab.h> | ||
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | #include <linux/string.h> | 39 | #include <linux/string.h> |
40 | 40 | ||
@@ -231,6 +231,8 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card) | |||
231 | 231 | ||
232 | static char ohci_driver_name[] = KBUILD_MODNAME; | 232 | static char ohci_driver_name[] = KBUILD_MODNAME; |
233 | 233 | ||
234 | #define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 | ||
235 | |||
234 | #define QUIRK_CYCLE_TIMER 1 | 236 | #define QUIRK_CYCLE_TIMER 1 |
235 | #define QUIRK_RESET_PACKET 2 | 237 | #define QUIRK_RESET_PACKET 2 |
236 | #define QUIRK_BE_HEADERS 4 | 238 | #define QUIRK_BE_HEADERS 4 |
@@ -239,6 +241,8 @@ static char ohci_driver_name[] = KBUILD_MODNAME; | |||
239 | static const struct { | 241 | static const struct { |
240 | unsigned short vendor, device, flags; | 242 | unsigned short vendor, device, flags; |
241 | } ohci_quirks[] = { | 243 | } ohci_quirks[] = { |
244 | {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER | | ||
245 | QUIRK_RESET_PACKET}, | ||
242 | {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, | 246 | {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, |
243 | {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, | 247 | {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, |
244 | {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, | 248 | {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, |