diff options
-rw-r--r-- | drivers/staging/altpciechdma/altpciechdma.c | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/drivers/staging/altpciechdma/altpciechdma.c b/drivers/staging/altpciechdma/altpciechdma.c index 27059bcc402..df685a98250 100644 --- a/drivers/staging/altpciechdma/altpciechdma.c +++ b/drivers/staging/altpciechdma/altpciechdma.c | |||
@@ -312,15 +312,16 @@ static int __devinit map_bars(struct ape_dev *ape, struct pci_dev *dev) | |||
312 | continue; | 312 | continue; |
313 | /* do not map BARs with address 0 */ | 313 | /* do not map BARs with address 0 */ |
314 | if (!bar_start || !bar_end) { | 314 | if (!bar_start || !bar_end) { |
315 | printk(KERN_DEBUG "BAR #%d is not present?!\n", i); | 315 | printk(KERN_DEBUG "BAR #%d is not present?!\n", i); |
316 | rc = -1; | 316 | rc = -1; |
317 | goto fail; | 317 | goto fail; |
318 | } | 318 | } |
319 | bar_length = bar_end - bar_start + 1; | 319 | bar_length = bar_end - bar_start + 1; |
320 | /* BAR length is less than driver requires? */ | 320 | /* BAR length is less than driver requires? */ |
321 | if (bar_length < bar_min_len[i]) { | 321 | if (bar_length < bar_min_len[i]) { |
322 | printk(KERN_DEBUG "BAR #%d length = %lu bytes but driver " | 322 | printk(KERN_DEBUG "BAR #%d length = %lu bytes but driver " |
323 | "requires at least %lu bytes\n", i, bar_length, bar_min_len[i]); | 323 | "requires at least %lu bytes\n", |
324 | i, bar_length, bar_min_len[i]); | ||
324 | rc = -1; | 325 | rc = -1; |
325 | goto fail; | 326 | goto fail; |
326 | } | 327 | } |
@@ -332,8 +333,8 @@ static int __devinit map_bars(struct ape_dev *ape, struct pci_dev *dev) | |||
332 | rc = -1; | 333 | rc = -1; |
333 | goto fail; | 334 | goto fail; |
334 | } | 335 | } |
335 | printk(KERN_DEBUG "BAR[%d] mapped at 0x%p with length %lu(/%lu).\n", i, | 336 | printk(KERN_DEBUG "BAR[%d] mapped at 0x%p with length %lu(/%lu).\n", i, |
336 | ape->bar[i], bar_min_len[i], bar_length); | 337 | ape->bar[i], bar_min_len[i], bar_length); |
337 | } | 338 | } |
338 | /* succesfully mapped all required BAR regions */ | 339 | /* succesfully mapped all required BAR regions */ |
339 | rc = 0; | 340 | rc = 0; |
@@ -466,15 +467,14 @@ static inline int compare(u32 *p, u32 *q, int len) | |||
466 | } else { | 467 | } else { |
467 | fail++; | 468 | fail++; |
468 | /* show the first few miscompares */ | 469 | /* show the first few miscompares */ |
469 | if (fail < 10) { | 470 | if (fail < 10) |
470 | printk(KERN_DEBUG "[%p] = 0x%08x != [%p] = 0x%08x ?!\n", p, *p, q, *q); | 471 | printk(KERN_DEBUG "[%p] = 0x%08x != [%p] = 0x%08x ?!\n", p, *p, q, *q); |
471 | /* but stop after a while */ | 472 | /* but stop after a while */ |
472 | } else if (fail == 10) { | 473 | else if (fail == 10) |
473 | printk(KERN_DEBUG "---more errors follow! not printed---\n"); | 474 | printk(KERN_DEBUG "---more errors follow! not printed---\n"); |
474 | } else { | 475 | else |
475 | /* stop compare after this many errors */ | 476 | /* stop compare after this many errors */ |
476 | break; | 477 | break; |
477 | } | ||
478 | } | 478 | } |
479 | p++; | 479 | p++; |
480 | q++; | 480 | q++; |
@@ -527,7 +527,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
527 | printk(KERN_DEBUG "ape->table_virt = 0x%p.\n", ape->table_virt); | 527 | printk(KERN_DEBUG "ape->table_virt = 0x%p.\n", ape->table_virt); |
528 | 528 | ||
529 | if (!write_header || !read_header || !ape->table_virt) | 529 | if (!write_header || !read_header || !ape->table_virt) |
530 | goto fail; | 530 | goto fail; |
531 | 531 | ||
532 | /* allocate and map coherently-cached memory for a DMA-able buffer */ | 532 | /* allocate and map coherently-cached memory for a DMA-able buffer */ |
533 | /* @see Documentation/PCI/PCI-DMA-mapping.txt, near line 318 */ | 533 | /* @see Documentation/PCI/PCI-DMA-mapping.txt, near line 318 */ |
@@ -564,9 +564,8 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
564 | /* read 8192 bytes from RC buffer to EP address 4096 */ | 564 | /* read 8192 bytes from RC buffer to EP address 4096 */ |
565 | ape_chdma_desc_set(&ape->table_virt->desc[n], buffer_bus, 4096, 2 * PAGE_SIZE); | 565 | ape_chdma_desc_set(&ape->table_virt->desc[n], buffer_bus, 4096, 2 * PAGE_SIZE); |
566 | #if 1 | 566 | #if 1 |
567 | for (i = 0; i < 255; i++) { | 567 | for (i = 0; i < 255; i++) |
568 | ape_chdma_desc_set(&ape->table_virt->desc[i], buffer_bus, 4096, 2 * PAGE_SIZE); | 568 | ape_chdma_desc_set(&ape->table_virt->desc[i], buffer_bus, 4096, 2 * PAGE_SIZE); |
569 | } | ||
570 | /* index of last descriptor */ | 569 | /* index of last descriptor */ |
571 | n = i - 1; | 570 | n = i - 1; |
572 | #endif | 571 | #endif |
@@ -646,7 +645,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
646 | printk(KERN_DEBUG "EPLAST = %u, n = %d\n", eplast, n); | 645 | printk(KERN_DEBUG "EPLAST = %u, n = %d\n", eplast, n); |
647 | if (eplast == n) { | 646 | if (eplast == n) { |
648 | printk(KERN_DEBUG "DONE\n"); | 647 | printk(KERN_DEBUG "DONE\n"); |
649 | /* print IRQ count before the transfer */ | 648 | /* print IRQ count before the transfer */ |
650 | printk(KERN_DEBUG "#IRQs during transfer: %d\n", ape->irq_count - irq_count); | 649 | printk(KERN_DEBUG "#IRQs during transfer: %d\n", ape->irq_count - irq_count); |
651 | break; | 650 | break; |
652 | } | 651 | } |
@@ -660,9 +659,9 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
660 | n = 0; | 659 | n = 0; |
661 | ape_chdma_desc_set(&ape->table_virt->desc[n], buffer_bus + 8192, 4096, 2 * PAGE_SIZE); | 660 | ape_chdma_desc_set(&ape->table_virt->desc[n], buffer_bus + 8192, 4096, 2 * PAGE_SIZE); |
662 | #if 1 | 661 | #if 1 |
663 | for (i = 0; i < 255; i++) { | 662 | for (i = 0; i < 255; i++) |
664 | ape_chdma_desc_set(&ape->table_virt->desc[i], buffer_bus + 8192, 4096, 2 * PAGE_SIZE); | 663 | ape_chdma_desc_set(&ape->table_virt->desc[i], buffer_bus + 8192, 4096, 2 * PAGE_SIZE); |
665 | } | 664 | |
666 | /* index of last descriptor */ | 665 | /* index of last descriptor */ |
667 | n = i - 1; | 666 | n = i - 1; |
668 | #endif | 667 | #endif |
@@ -690,7 +689,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
690 | w = (u32)(n + 1); | 689 | w = (u32)(n + 1); |
691 | /* enable updates of eplast for each descriptor completion */ | 690 | /* enable updates of eplast for each descriptor completion */ |
692 | w |= (u32)(1UL << 18)/*global EPLAST_EN*/; | 691 | w |= (u32)(1UL << 18)/*global EPLAST_EN*/; |
693 | #if 0 // test variable, make a module option later | 692 | #if 0 /* test variable, make a module option later */ |
694 | /* enable MSI for each descriptor completion */ | 693 | /* enable MSI for each descriptor completion */ |
695 | if (ape->msi_enabled) | 694 | if (ape->msi_enabled) |
696 | w |= (1UL << 17)/*global MSI*/; | 695 | w |= (1UL << 17)/*global MSI*/; |
@@ -714,7 +713,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev) | |||
714 | /** memory write barrier */ | 713 | /** memory write barrier */ |
715 | wmb(); | 714 | wmb(); |
716 | /** dummy read to flush posted writes */ | 715 | /** dummy read to flush posted writes */ |
717 | //(void)ioread32(); | 716 | /* (void) ioread32(); */ |
718 | 717 | ||
719 | printk(KERN_DEBUG "POLL FOR WRITE:\n"); | 718 | printk(KERN_DEBUG "POLL FOR WRITE:\n"); |
720 | /* poll for completion, 1000 times 1 millisecond */ | 719 | /* poll for completion, 1000 times 1 millisecond */ |
@@ -843,7 +842,7 @@ static int __devinit probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
843 | } | 842 | } |
844 | ape->got_regions = 1; | 843 | ape->got_regions = 1; |
845 | 844 | ||
846 | #if 1 // @todo For now, disable 64-bit, because I do not understand the implications (DAC!) | 845 | #if 1 /* @todo For now, disable 64-bit, because I do not understand the implications (DAC!) */ |
847 | /* query for DMA transfer */ | 846 | /* query for DMA transfer */ |
848 | /* @see Documentation/PCI/PCI-DMA-mapping.txt */ | 847 | /* @see Documentation/PCI/PCI-DMA-mapping.txt */ |
849 | if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)) { | 848 | if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)) { |
@@ -1048,10 +1047,9 @@ static ssize_t sg_write(struct file *file, const char __user *buf, size_t count, | |||
1048 | printk(KERN_DEBUG DRV_NAME "_write(buf=0x%p, count=%lld, pos=%llu)\n", | 1047 | printk(KERN_DEBUG DRV_NAME "_write(buf=0x%p, count=%lld, pos=%llu)\n", |
1049 | buf, (s64)count, (u64)*pos); | 1048 | buf, (s64)count, (u64)*pos); |
1050 | /* TODO transfer boundaries at PAGE_SIZE granularity */ | 1049 | /* TODO transfer boundaries at PAGE_SIZE granularity */ |
1051 | while (remaining > 0) | 1050 | while (remaining > 0) { |
1052 | { | ||
1053 | /* limit DMA transfer size */ | 1051 | /* limit DMA transfer size */ |
1054 | transfer_len = (remaining < APE_CHDMA_MAX_TRANSFER_LEN)? remaining: | 1052 | transfer_len = (remaining < APE_CHDMA_MAX_TRANSFER_LEN) ? remaining : |
1055 | APE_CHDMA_MAX_TRANSFER_LEN; | 1053 | APE_CHDMA_MAX_TRANSFER_LEN; |
1056 | /* get all user space buffer pages and create a scattergather list */ | 1054 | /* get all user space buffer pages and create a scattergather list */ |
1057 | sgm_map_user_pages(ape->sgm, transfer_addr, transfer_len, 0/*read from userspace*/); | 1055 | sgm_map_user_pages(ape->sgm, transfer_addr, transfer_len, 0/*read from userspace*/); |
@@ -1085,12 +1083,12 @@ static ssize_t sg_write(struct file *file, const char __user *buf, size_t count, | |||
1085 | /* | 1083 | /* |
1086 | * character device file operations | 1084 | * character device file operations |
1087 | */ | 1085 | */ |
1088 | static struct file_operations sg_fops = { | 1086 | static const struct file_operations sg_fops = { |
1089 | .owner = THIS_MODULE, | 1087 | .owner = THIS_MODULE, |
1090 | .open = sg_open, | 1088 | .open = sg_open, |
1091 | .release = sg_close, | 1089 | .release = sg_close, |
1092 | .read = sg_read, | 1090 | .read = sg_read, |
1093 | .write = sg_write, | 1091 | .write = sg_write, |
1094 | }; | 1092 | }; |
1095 | 1093 | ||
1096 | /* sg_init() - Initialize character device | 1094 | /* sg_init() - Initialize character device |
@@ -1158,12 +1156,12 @@ static struct pci_driver pci_driver = { | |||
1158 | */ | 1156 | */ |
1159 | static int __init alterapciechdma_init(void) | 1157 | static int __init alterapciechdma_init(void) |
1160 | { | 1158 | { |
1161 | int rc = 0; | 1159 | int rc = 0; |
1162 | printk(KERN_DEBUG DRV_NAME " init(), built at " __DATE__ " " __TIME__ "\n"); | 1160 | printk(KERN_DEBUG DRV_NAME " init(), built at " __DATE__ " " __TIME__ "\n"); |
1163 | /* register this driver with the PCI bus driver */ | 1161 | /* register this driver with the PCI bus driver */ |
1164 | rc = pci_register_driver(&pci_driver); | 1162 | rc = pci_register_driver(&pci_driver); |
1165 | if (rc < 0) | 1163 | if (rc < 0) |
1166 | return rc; | 1164 | return rc; |
1167 | return 0; | 1165 | return 0; |
1168 | } | 1166 | } |
1169 | 1167 | ||