aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-cdev.c24
-rw-r--r--drivers/firewire/core-device.c1
-rw-r--r--drivers/firewire/core-iso.c15
-rw-r--r--drivers/firewire/net.c1
-rw-r--r--drivers/firewire/ohci.c25
5 files changed, 42 insertions, 24 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 882472d1e144..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>
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 99c20f1b613a..8f5aebfb29df 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
@@ -189,7 +190,7 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
189 for (try = 0; try < 5; try++) { 190 for (try = 0; try < 5; try++) {
190 new = allocate ? old - bandwidth : old + bandwidth; 191 new = allocate ? old - bandwidth : old + bandwidth;
191 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL) 192 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL)
192 break; 193 return -EBUSY;
193 194
194 data[0] = cpu_to_be32(old); 195 data[0] = cpu_to_be32(old);
195 data[1] = cpu_to_be32(new); 196 data[1] = cpu_to_be32(new);
@@ -217,7 +218,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
217 u32 channels_mask, u64 offset, bool allocate, __be32 data[2]) 218 u32 channels_mask, u64 offset, bool allocate, __be32 data[2])
218{ 219{
219 __be32 c, all, old; 220 __be32 c, all, old;
220 int i, retry = 5; 221 int i, ret = -EIO, retry = 5;
221 222
222 old = all = allocate ? cpu_to_be32(~0) : 0; 223 old = all = allocate ? cpu_to_be32(~0) : 0;
223 224
@@ -225,6 +226,8 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
225 if (!(channels_mask & 1 << i)) 226 if (!(channels_mask & 1 << i))
226 continue; 227 continue;
227 228
229 ret = -EBUSY;
230
228 c = cpu_to_be32(1 << (31 - i)); 231 c = cpu_to_be32(1 << (31 - i));
229 if ((old & c) != (all & c)) 232 if ((old & c) != (all & c))
230 continue; 233 continue;
@@ -250,12 +253,16 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
250 253
251 /* 1394-1995 IRM, fall through to retry. */ 254 /* 1394-1995 IRM, fall through to retry. */
252 default: 255 default:
253 if (retry--) 256 if (retry) {
257 retry--;
254 i--; 258 i--;
259 } else {
260 ret = -EIO;
261 }
255 } 262 }
256 } 263 }
257 264
258 return -EIO; 265 return ret;
259} 266}
260 267
261static void deallocate_channel(struct fw_card *card, int irm_id, 268static void deallocate_channel(struct fw_card *card, int irm_id,
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 e33917bf97d2..94b16e0340ae 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
@@ -1158,7 +1158,7 @@ static void handle_local_lock(struct fw_ohci *ohci,
1158 struct fw_packet *packet, u32 csr) 1158 struct fw_packet *packet, u32 csr)
1159{ 1159{
1160 struct fw_packet response; 1160 struct fw_packet response;
1161 int tcode, length, ext_tcode, sel; 1161 int tcode, length, ext_tcode, sel, try;
1162 __be32 *payload, lock_old; 1162 __be32 *payload, lock_old;
1163 u32 lock_arg, lock_data; 1163 u32 lock_arg, lock_data;
1164 1164
@@ -1185,21 +1185,26 @@ static void handle_local_lock(struct fw_ohci *ohci,
1185 reg_write(ohci, OHCI1394_CSRCompareData, lock_arg); 1185 reg_write(ohci, OHCI1394_CSRCompareData, lock_arg);
1186 reg_write(ohci, OHCI1394_CSRControl, sel); 1186 reg_write(ohci, OHCI1394_CSRControl, sel);
1187 1187
1188 if (reg_read(ohci, OHCI1394_CSRControl) & 0x80000000) 1188 for (try = 0; try < 20; try++)
1189 lock_old = cpu_to_be32(reg_read(ohci, OHCI1394_CSRData)); 1189 if (reg_read(ohci, OHCI1394_CSRControl) & 0x80000000) {
1190 else 1190 lock_old = cpu_to_be32(reg_read(ohci,
1191 fw_notify("swap not done yet\n"); 1191 OHCI1394_CSRData));
1192 fw_fill_response(&response, packet->header,
1193 RCODE_COMPLETE,
1194 &lock_old, sizeof(lock_old));
1195 goto out;
1196 }
1197
1198 fw_error("swap not done (CSR lock timeout)\n");
1199 fw_fill_response(&response, packet->header, RCODE_BUSY, NULL, 0);
1192 1200
1193 fw_fill_response(&response, packet->header,
1194 RCODE_COMPLETE, &lock_old, sizeof(lock_old));
1195 out: 1201 out:
1196 fw_core_handle_response(&ohci->card, &response); 1202 fw_core_handle_response(&ohci->card, &response);
1197} 1203}
1198 1204
1199static void handle_local_request(struct context *ctx, struct fw_packet *packet) 1205static void handle_local_request(struct context *ctx, struct fw_packet *packet)
1200{ 1206{
1201 u64 offset; 1207 u64 offset, csr;
1202 u32 csr;
1203 1208
1204 if (ctx == &ctx->ohci->at_request_ctx) { 1209 if (ctx == &ctx->ohci->at_request_ctx) {
1205 packet->ack = ACK_PENDING; 1210 packet->ack = ACK_PENDING;