aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/video1394.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/video1394.c')
-rw-r--r--drivers/ieee1394/video1394.c139
1 files changed, 93 insertions, 46 deletions
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 4bedf7113f40..d68c4658f2fc 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -35,6 +35,11 @@
35 * 35 *
36 */ 36 */
37 37
38/* Markus Tavenrath <speedygoo@speedygoo.de> :
39 - fixed checks for valid buffer-numbers in video1394_icotl
40 - changed the ways the dma prg's are used, now it's possible to use
41 even a single dma buffer
42*/
38#include <linux/config.h> 43#include <linux/config.h>
39#include <linux/kernel.h> 44#include <linux/kernel.h>
40#include <linux/list.h> 45#include <linux/list.h>
@@ -112,6 +117,7 @@ struct dma_iso_ctx {
112 struct it_dma_prg **it_prg; 117 struct it_dma_prg **it_prg;
113 118
114 unsigned int *buffer_status; 119 unsigned int *buffer_status;
120 unsigned int *buffer_prg_assignment;
115 struct timeval *buffer_time; /* time when the buffer was received */ 121 struct timeval *buffer_time; /* time when the buffer was received */
116 unsigned int *last_used_cmd; /* For ISO Transmit with 122 unsigned int *last_used_cmd; /* For ISO Transmit with
117 variable sized packets only ! */ 123 variable sized packets only ! */
@@ -180,23 +186,14 @@ static int free_dma_iso_ctx(struct dma_iso_ctx *d)
180 kfree(d->prg_reg); 186 kfree(d->prg_reg);
181 } 187 }
182 188
183 if (d->ir_prg) 189 kfree(d->ir_prg);
184 kfree(d->ir_prg); 190 kfree(d->it_prg);
185 191 kfree(d->buffer_status);
186 if (d->it_prg) 192 kfree(d->buffer_prg_assignment);
187 kfree(d->it_prg); 193 kfree(d->buffer_time);
188 194 kfree(d->last_used_cmd);
189 if (d->buffer_status) 195 kfree(d->next_buffer);
190 kfree(d->buffer_status);
191 if (d->buffer_time)
192 kfree(d->buffer_time);
193 if (d->last_used_cmd)
194 kfree(d->last_used_cmd);
195 if (d->next_buffer)
196 kfree(d->next_buffer);
197
198 list_del(&d->link); 196 list_del(&d->link);
199
200 kfree(d); 197 kfree(d);
201 198
202 return 0; 199 return 0;
@@ -230,7 +227,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
230 /* Init the regions for easy cleanup */ 227 /* Init the regions for easy cleanup */
231 dma_region_init(&d->dma); 228 dma_region_init(&d->dma);
232 229
233 if (dma_region_alloc(&d->dma, d->num_desc * d->buf_size, ohci->dev, 230 if (dma_region_alloc(&d->dma, (d->num_desc - 1) * d->buf_size, ohci->dev,
234 PCI_DMA_BIDIRECTIONAL)) { 231 PCI_DMA_BIDIRECTIONAL)) {
235 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer"); 232 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma buffer");
236 free_dma_iso_ctx(d); 233 free_dma_iso_ctx(d);
@@ -342,6 +339,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
342 339
343 d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), 340 d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int),
344 GFP_KERNEL); 341 GFP_KERNEL);
342 d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int),
343 GFP_KERNEL);
345 d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), 344 d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval),
346 GFP_KERNEL); 345 GFP_KERNEL);
347 d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), 346 d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int),
@@ -354,6 +353,11 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
354 free_dma_iso_ctx(d); 353 free_dma_iso_ctx(d);
355 return NULL; 354 return NULL;
356 } 355 }
356 if (d->buffer_prg_assignment == NULL) {
357 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment");
358 free_dma_iso_ctx(d);
359 return NULL;
360 }
357 if (d->buffer_time == NULL) { 361 if (d->buffer_time == NULL) {
358 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time"); 362 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time");
359 free_dma_iso_ctx(d); 363 free_dma_iso_ctx(d);
@@ -370,6 +374,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
370 return NULL; 374 return NULL;
371 } 375 }
372 memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); 376 memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int));
377 memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int));
373 memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); 378 memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval));
374 memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); 379 memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int));
375 memset(d->next_buffer, -1, d->num_desc * sizeof(int)); 380 memset(d->next_buffer, -1, d->num_desc * sizeof(int));
@@ -379,7 +384,7 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
379 PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers " 384 PRINT(KERN_INFO, ohci->host->id, "Iso %s DMA: %d buffers "
380 "of size %d allocated for a frame size %d, each with %d prgs", 385 "of size %d allocated for a frame size %d, each with %d prgs",
381 (type == OHCI_ISO_RECEIVE) ? "receive" : "transmit", 386 (type == OHCI_ISO_RECEIVE) ? "receive" : "transmit",
382 d->num_desc, d->buf_size, d->frame_size, d->nb_cmd); 387 d->num_desc - 1, d->buf_size, d->frame_size, d->nb_cmd);
383 388
384 return d; 389 return d;
385} 390}
@@ -394,11 +399,36 @@ static void reset_ir_status(struct dma_iso_ctx *d, int n)
394 d->ir_prg[n][i].status = cpu_to_le32(d->left_size); 399 d->ir_prg[n][i].status = cpu_to_le32(d->left_size);
395} 400}
396 401
402static void reprogram_dma_ir_prg(struct dma_iso_ctx *d, int n, int buffer, int flags)
403{
404 struct dma_cmd *ir_prg = d->ir_prg[n];
405 unsigned long buf = (unsigned long)d->dma.kvirt + buffer * d->buf_size;
406 int i;
407
408 d->buffer_prg_assignment[n] = buffer;
409
410 ir_prg[0].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma, buf -
411 (unsigned long)d->dma.kvirt));
412 ir_prg[1].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
413 (buf + 4) - (unsigned long)d->dma.kvirt));
414
415 for (i=2;i<d->nb_cmd-1;i++) {
416 ir_prg[i].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
417 (buf+(i-1)*PAGE_SIZE) -
418 (unsigned long)d->dma.kvirt));
419 }
420
421 ir_prg[i].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
422 DMA_CTL_IRQ | DMA_CTL_BRANCH | d->left_size);
423 ir_prg[i].address = cpu_to_le32(dma_region_offset_to_bus(&d->dma,
424 (buf+(i-1)*PAGE_SIZE) - (unsigned long)d->dma.kvirt));
425}
426
397static void initialize_dma_ir_prg(struct dma_iso_ctx *d, int n, int flags) 427static void initialize_dma_ir_prg(struct dma_iso_ctx *d, int n, int flags)
398{ 428{
399 struct dma_cmd *ir_prg = d->ir_prg[n]; 429 struct dma_cmd *ir_prg = d->ir_prg[n];
400 struct dma_prog_region *ir_reg = &d->prg_reg[n]; 430 struct dma_prog_region *ir_reg = &d->prg_reg[n];
401 unsigned long buf = (unsigned long)d->dma.kvirt + n * d->buf_size; 431 unsigned long buf = (unsigned long)d->dma.kvirt;
402 int i; 432 int i;
403 433
404 /* the first descriptor will read only 4 bytes */ 434 /* the first descriptor will read only 4 bytes */
@@ -508,7 +538,7 @@ static void wakeup_dma_ir_ctx(unsigned long l)
508 for (i = 0; i < d->num_desc; i++) { 538 for (i = 0; i < d->num_desc; i++) {
509 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) { 539 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) {
510 reset_ir_status(d, i); 540 reset_ir_status(d, i);
511 d->buffer_status[i] = VIDEO1394_BUFFER_READY; 541 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
512 do_gettimeofday(&d->buffer_time[i]); 542 do_gettimeofday(&d->buffer_time[i]);
513 } 543 }
514 } 544 }
@@ -585,7 +615,7 @@ static void wakeup_dma_it_ctx(unsigned long l)
585 int next = d->next_buffer[i]; 615 int next = d->next_buffer[i];
586 put_timestamp(ohci, d, next); 616 put_timestamp(ohci, d, next);
587 d->it_prg[i][d->last_used_cmd[i]].end.status = 0; 617 d->it_prg[i][d->last_used_cmd[i]].end.status = 0;
588 d->buffer_status[i] = VIDEO1394_BUFFER_READY; 618 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
589 } 619 }
590 } 620 }
591 621
@@ -595,11 +625,25 @@ static void wakeup_dma_it_ctx(unsigned long l)
595 wake_up_interruptible(&d->waitq); 625 wake_up_interruptible(&d->waitq);
596} 626}
597 627
628static void reprogram_dma_it_prg(struct dma_iso_ctx *d, int n, int buffer)
629{
630 struct it_dma_prg *it_prg = d->it_prg[n];
631 unsigned long buf = (unsigned long)d->dma.kvirt + buffer * d->buf_size;
632 int i;
633
634 d->buffer_prg_assignment[n] = buffer;
635 for (i=0;i<d->nb_cmd;i++) {
636 it_prg[i].end.address =
637 cpu_to_le32(dma_region_offset_to_bus(&d->dma,
638 (buf+i*d->packet_size) - (unsigned long)d->dma.kvirt));
639 }
640}
641
598static void initialize_dma_it_prg(struct dma_iso_ctx *d, int n, int sync_tag) 642static void initialize_dma_it_prg(struct dma_iso_ctx *d, int n, int sync_tag)
599{ 643{
600 struct it_dma_prg *it_prg = d->it_prg[n]; 644 struct it_dma_prg *it_prg = d->it_prg[n];
601 struct dma_prog_region *it_reg = &d->prg_reg[n]; 645 struct dma_prog_region *it_reg = &d->prg_reg[n];
602 unsigned long buf = (unsigned long)d->dma.kvirt + n * d->buf_size; 646 unsigned long buf = (unsigned long)d->dma.kvirt;
603 int i; 647 int i;
604 d->last_used_cmd[n] = d->nb_cmd - 1; 648 d->last_used_cmd[n] = d->nb_cmd - 1;
605 for (i=0;i<d->nb_cmd;i++) { 649 for (i=0;i<d->nb_cmd;i++) {
@@ -796,7 +840,7 @@ static int __video1394_ioctl(struct file *file,
796 840
797 if (cmd == VIDEO1394_IOC_LISTEN_CHANNEL) { 841 if (cmd == VIDEO1394_IOC_LISTEN_CHANNEL) {
798 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_RECEIVE, 842 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_RECEIVE,
799 v.nb_buffers, v.buf_size, 843 v.nb_buffers + 1, v.buf_size,
800 v.channel, 0); 844 v.channel, 0);
801 845
802 if (d == NULL) { 846 if (d == NULL) {
@@ -817,7 +861,7 @@ static int __video1394_ioctl(struct file *file,
817 } 861 }
818 else { 862 else {
819 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_TRANSMIT, 863 d = alloc_dma_iso_ctx(ohci, OHCI_ISO_TRANSMIT,
820 v.nb_buffers, v.buf_size, 864 v.nb_buffers + 1, v.buf_size,
821 v.channel, v.packet_size); 865 v.channel, v.packet_size);
822 866
823 if (d == NULL) { 867 if (d == NULL) {
@@ -889,6 +933,7 @@ static int __video1394_ioctl(struct file *file,
889 { 933 {
890 struct video1394_wait v; 934 struct video1394_wait v;
891 struct dma_iso_ctx *d; 935 struct dma_iso_ctx *d;
936 int next_prg;
892 937
893 if (copy_from_user(&v, argp, sizeof(v))) 938 if (copy_from_user(&v, argp, sizeof(v)))
894 return -EFAULT; 939 return -EFAULT;
@@ -896,7 +941,7 @@ static int __video1394_ioctl(struct file *file,
896 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 941 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
897 if (d == NULL) return -EFAULT; 942 if (d == NULL) return -EFAULT;
898 943
899 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 944 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
900 PRINT(KERN_ERR, ohci->host->id, 945 PRINT(KERN_ERR, ohci->host->id,
901 "Buffer %d out of range",v.buffer); 946 "Buffer %d out of range",v.buffer);
902 return -EINVAL; 947 return -EINVAL;
@@ -913,12 +958,14 @@ static int __video1394_ioctl(struct file *file,
913 958
914 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED; 959 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED;
915 960
961 next_prg = (d->last_buffer + 1) % d->num_desc;
916 if (d->last_buffer>=0) 962 if (d->last_buffer>=0)
917 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 963 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress =
918 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) 964 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg], 0)
919 & 0xfffffff0) | 0x1); 965 & 0xfffffff0) | 0x1);
920 966
921 d->last_buffer = v.buffer; 967 d->last_buffer = next_prg;
968 reprogram_dma_ir_prg(d, d->last_buffer, v.buffer, d->flags);
922 969
923 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 0; 970 d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress = 0;
924 971
@@ -930,7 +977,7 @@ static int __video1394_ioctl(struct file *file,
930 977
931 /* Tell the controller where the first program is */ 978 /* Tell the controller where the first program is */
932 reg_write(ohci, d->cmdPtr, 979 reg_write(ohci, d->cmdPtr,
933 dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) | 0x1); 980 dma_prog_region_offset_to_bus(&d->prg_reg[d->last_buffer], 0) | 0x1);
934 981
935 /* Run IR context */ 982 /* Run IR context */
936 reg_write(ohci, d->ctrlSet, 0x8000); 983 reg_write(ohci, d->ctrlSet, 0x8000);
@@ -951,7 +998,7 @@ static int __video1394_ioctl(struct file *file,
951 { 998 {
952 struct video1394_wait v; 999 struct video1394_wait v;
953 struct dma_iso_ctx *d; 1000 struct dma_iso_ctx *d;
954 int i; 1001 int i = 0;
955 1002
956 if (copy_from_user(&v, argp, sizeof(v))) 1003 if (copy_from_user(&v, argp, sizeof(v)))
957 return -EFAULT; 1004 return -EFAULT;
@@ -959,7 +1006,7 @@ static int __video1394_ioctl(struct file *file,
959 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 1006 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
960 if (d == NULL) return -EFAULT; 1007 if (d == NULL) return -EFAULT;
961 1008
962 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1009 if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) {
963 PRINT(KERN_ERR, ohci->host->id, 1010 PRINT(KERN_ERR, ohci->host->id,
964 "Buffer %d out of range",v.buffer); 1011 "Buffer %d out of range",v.buffer);
965 return -EINVAL; 1012 return -EINVAL;
@@ -1005,9 +1052,9 @@ static int __video1394_ioctl(struct file *file,
1005 * Look ahead to see how many more buffers have been received 1052 * Look ahead to see how many more buffers have been received
1006 */ 1053 */
1007 i=0; 1054 i=0;
1008 while (d->buffer_status[(v.buffer+1)%d->num_desc]== 1055 while (d->buffer_status[(v.buffer+1)%(d->num_desc - 1)]==
1009 VIDEO1394_BUFFER_READY) { 1056 VIDEO1394_BUFFER_READY) {
1010 v.buffer=(v.buffer+1)%d->num_desc; 1057 v.buffer=(v.buffer+1)%(d->num_desc - 1);
1011 i++; 1058 i++;
1012 } 1059 }
1013 spin_unlock_irqrestore(&d->lock, flags); 1060 spin_unlock_irqrestore(&d->lock, flags);
@@ -1023,6 +1070,7 @@ static int __video1394_ioctl(struct file *file,
1023 struct video1394_wait v; 1070 struct video1394_wait v;
1024 unsigned int *psizes = NULL; 1071 unsigned int *psizes = NULL;
1025 struct dma_iso_ctx *d; 1072 struct dma_iso_ctx *d;
1073 int next_prg;
1026 1074
1027 if (copy_from_user(&v, argp, sizeof(v))) 1075 if (copy_from_user(&v, argp, sizeof(v)))
1028 return -EFAULT; 1076 return -EFAULT;
@@ -1030,7 +1078,7 @@ static int __video1394_ioctl(struct file *file,
1030 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1078 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1031 if (d == NULL) return -EFAULT; 1079 if (d == NULL) return -EFAULT;
1032 1080
1033 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1081 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
1034 PRINT(KERN_ERR, ohci->host->id, 1082 PRINT(KERN_ERR, ohci->host->id,
1035 "Buffer %d out of range",v.buffer); 1083 "Buffer %d out of range",v.buffer);
1036 return -EINVAL; 1084 return -EINVAL;
@@ -1056,19 +1104,19 @@ static int __video1394_ioctl(struct file *file,
1056 1104
1057 spin_lock_irqsave(&d->lock,flags); 1105 spin_lock_irqsave(&d->lock,flags);
1058 1106
1107 // last_buffer is last_prg
1108 next_prg = (d->last_buffer + 1) % d->num_desc;
1059 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) { 1109 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) {
1060 PRINT(KERN_ERR, ohci->host->id, 1110 PRINT(KERN_ERR, ohci->host->id,
1061 "Buffer %d is already used",v.buffer); 1111 "Buffer %d is already used",v.buffer);
1062 spin_unlock_irqrestore(&d->lock,flags); 1112 spin_unlock_irqrestore(&d->lock,flags);
1063 if (psizes) 1113 kfree(psizes);
1064 kfree(psizes);
1065 return -EBUSY; 1114 return -EBUSY;
1066 } 1115 }
1067 1116
1068 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { 1117 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) {
1069 initialize_dma_it_prg_var_packet_queue( 1118 initialize_dma_it_prg_var_packet_queue(
1070 d, v.buffer, psizes, 1119 d, next_prg, psizes, ohci);
1071 ohci);
1072 } 1120 }
1073 1121
1074 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED; 1122 d->buffer_status[v.buffer]=VIDEO1394_BUFFER_QUEUED;
@@ -1076,16 +1124,17 @@ static int __video1394_ioctl(struct file *file,
1076 if (d->last_buffer >= 0) { 1124 if (d->last_buffer >= 0) {
1077 d->it_prg[d->last_buffer] 1125 d->it_prg[d->last_buffer]
1078 [ d->last_used_cmd[d->last_buffer] ].end.branchAddress = 1126 [ d->last_used_cmd[d->last_buffer] ].end.branchAddress =
1079 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 1127 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg],
1080 0) & 0xfffffff0) | 0x3); 1128 0) & 0xfffffff0) | 0x3);
1081 1129
1082 d->it_prg[d->last_buffer] 1130 d->it_prg[d->last_buffer]
1083 [ d->last_used_cmd[d->last_buffer] ].begin.branchAddress = 1131 [ d->last_used_cmd[d->last_buffer] ].begin.branchAddress =
1084 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 1132 cpu_to_le32((dma_prog_region_offset_to_bus(&d->prg_reg[next_prg],
1085 0) & 0xfffffff0) | 0x3); 1133 0) & 0xfffffff0) | 0x3);
1086 d->next_buffer[d->last_buffer] = v.buffer; 1134 d->next_buffer[d->last_buffer] = (v.buffer + 1) % (d->num_desc - 1);
1087 } 1135 }
1088 d->last_buffer = v.buffer; 1136 d->last_buffer = next_prg;
1137 reprogram_dma_it_prg(d, d->last_buffer, v.buffer);
1089 d->next_buffer[d->last_buffer] = -1; 1138 d->next_buffer[d->last_buffer] = -1;
1090 1139
1091 d->it_prg[d->last_buffer][d->last_used_cmd[d->last_buffer]].end.branchAddress = 0; 1140 d->it_prg[d->last_buffer][d->last_used_cmd[d->last_buffer]].end.branchAddress = 0;
@@ -1100,7 +1149,7 @@ static int __video1394_ioctl(struct file *file,
1100 1149
1101 /* Tell the controller where the first program is */ 1150 /* Tell the controller where the first program is */
1102 reg_write(ohci, d->cmdPtr, 1151 reg_write(ohci, d->cmdPtr,
1103 dma_prog_region_offset_to_bus(&d->prg_reg[v.buffer], 0) | 0x3); 1152 dma_prog_region_offset_to_bus(&d->prg_reg[next_prg], 0) | 0x3);
1104 1153
1105 /* Run IT context */ 1154 /* Run IT context */
1106 reg_write(ohci, d->ctrlSet, 0x8000); 1155 reg_write(ohci, d->ctrlSet, 0x8000);
@@ -1116,9 +1165,7 @@ static int __video1394_ioctl(struct file *file,
1116 } 1165 }
1117 } 1166 }
1118 1167
1119 if (psizes) 1168 kfree(psizes);
1120 kfree(psizes);
1121
1122 return 0; 1169 return 0;
1123 1170
1124 } 1171 }
@@ -1133,7 +1180,7 @@ static int __video1394_ioctl(struct file *file,
1133 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel); 1180 d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
1134 if (d == NULL) return -EFAULT; 1181 if (d == NULL) return -EFAULT;
1135 1182
1136 if ((v.buffer<0) || (v.buffer>d->num_desc)) { 1183 if ((v.buffer<0) || (v.buffer>=d->num_desc-1)) {
1137 PRINT(KERN_ERR, ohci->host->id, 1184 PRINT(KERN_ERR, ohci->host->id,
1138 "Buffer %d out of range",v.buffer); 1185 "Buffer %d out of range",v.buffer);
1139 return -EINVAL; 1186 return -EINVAL;