aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/commctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aacraid/commctrl.c')
-rw-r--r--drivers/scsi/aacraid/commctrl.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index a27207e27c30..f8afa358b6b6 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -48,13 +48,13 @@
48 * ioctl_send_fib - send a FIB from userspace 48 * ioctl_send_fib - send a FIB from userspace
49 * @dev: adapter is being processed 49 * @dev: adapter is being processed
50 * @arg: arguments to the ioctl call 50 * @arg: arguments to the ioctl call
51 * 51 *
52 * This routine sends a fib to the adapter on behalf of a user level 52 * This routine sends a fib to the adapter on behalf of a user level
53 * program. 53 * program.
54 */ 54 */
55# define AAC_DEBUG_PREAMBLE KERN_INFO 55# define AAC_DEBUG_PREAMBLE KERN_INFO
56# define AAC_DEBUG_POSTAMBLE 56# define AAC_DEBUG_POSTAMBLE
57 57
58static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) 58static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
59{ 59{
60 struct hw_fib * kfib; 60 struct hw_fib * kfib;
@@ -71,7 +71,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
71 if(fibptr == NULL) { 71 if(fibptr == NULL) {
72 return -ENOMEM; 72 return -ENOMEM;
73 } 73 }
74 74
75 kfib = fibptr->hw_fib_va; 75 kfib = fibptr->hw_fib_va;
76 /* 76 /*
77 * First copy in the header so that we can check the size field. 77 * First copy in the header so that we can check the size field.
@@ -109,7 +109,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
109 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) { 109 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
110 aac_adapter_interrupt(dev); 110 aac_adapter_interrupt(dev);
111 /* 111 /*
112 * Since we didn't really send a fib, zero out the state to allow 112 * Since we didn't really send a fib, zero out the state to allow
113 * cleanup code not to assert. 113 * cleanup code not to assert.
114 */ 114 */
115 kfib->header.XferState = 0; 115 kfib->header.XferState = 0;
@@ -169,7 +169,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
169 169
170 fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT; 170 fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;
171 fibctx->size = sizeof(struct aac_fib_context); 171 fibctx->size = sizeof(struct aac_fib_context);
172 /* 172 /*
173 * Yes yes, I know this could be an index, but we have a 173 * Yes yes, I know this could be an index, but we have a
174 * better guarantee of uniqueness for the locked loop below. 174 * better guarantee of uniqueness for the locked loop below.
175 * Without the aid of a persistent history, this also helps 175 * Without the aid of a persistent history, this also helps
@@ -189,7 +189,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
189 INIT_LIST_HEAD(&fibctx->fib_list); 189 INIT_LIST_HEAD(&fibctx->fib_list);
190 fibctx->jiffies = jiffies/HZ; 190 fibctx->jiffies = jiffies/HZ;
191 /* 191 /*
192 * Now add this context onto the adapter's 192 * Now add this context onto the adapter's
193 * AdapterFibContext list. 193 * AdapterFibContext list.
194 */ 194 */
195 spin_lock_irqsave(&dev->fib_lock, flags); 195 spin_lock_irqsave(&dev->fib_lock, flags);
@@ -207,12 +207,12 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
207 } 207 }
208 list_add_tail(&fibctx->next, &dev->fib_list); 208 list_add_tail(&fibctx->next, &dev->fib_list);
209 spin_unlock_irqrestore(&dev->fib_lock, flags); 209 spin_unlock_irqrestore(&dev->fib_lock, flags);
210 if (copy_to_user(arg, &fibctx->unique, 210 if (copy_to_user(arg, &fibctx->unique,
211 sizeof(fibctx->unique))) { 211 sizeof(fibctx->unique))) {
212 status = -EFAULT; 212 status = -EFAULT;
213 } else { 213 } else {
214 status = 0; 214 status = 0;
215 } 215 }
216 } 216 }
217 return status; 217 return status;
218} 218}
@@ -221,8 +221,8 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
221 * next_getadapter_fib - get the next fib 221 * next_getadapter_fib - get the next fib
222 * @dev: adapter to use 222 * @dev: adapter to use
223 * @arg: ioctl argument 223 * @arg: ioctl argument
224 * 224 *
225 * This routine will get the next Fib, if available, from the AdapterFibContext 225 * This routine will get the next Fib, if available, from the AdapterFibContext
226 * passed in from the user. 226 * passed in from the user.
227 */ 227 */
228 228
@@ -234,7 +234,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
234 int status; 234 int status;
235 struct list_head * entry; 235 struct list_head * entry;
236 unsigned long flags; 236 unsigned long flags;
237 237
238 if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl))) 238 if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
239 return -EFAULT; 239 return -EFAULT;
240 /* 240 /*
@@ -280,7 +280,7 @@ return_fib:
280 */ 280 */
281 entry = fibctx->fib_list.next; 281 entry = fibctx->fib_list.next;
282 list_del(entry); 282 list_del(entry);
283 283
284 fib = list_entry(entry, struct fib, fiblink); 284 fib = list_entry(entry, struct fib, fiblink);
285 fibctx->count--; 285 fibctx->count--;
286 spin_unlock_irqrestore(&dev->fib_lock, flags); 286 spin_unlock_irqrestore(&dev->fib_lock, flags);
@@ -288,7 +288,7 @@ return_fib:
288 kfree(fib->hw_fib_va); 288 kfree(fib->hw_fib_va);
289 kfree(fib); 289 kfree(fib);
290 return -EFAULT; 290 return -EFAULT;
291 } 291 }
292 /* 292 /*
293 * Free the space occupied by this copy of the fib. 293 * Free the space occupied by this copy of the fib.
294 */ 294 */
@@ -317,7 +317,7 @@ return_fib:
317 } 317 }
318 } else { 318 } else {
319 status = -EAGAIN; 319 status = -EAGAIN;
320 } 320 }
321 } 321 }
322 fibctx->jiffies = jiffies/HZ; 322 fibctx->jiffies = jiffies/HZ;
323 return status; 323 return status;
@@ -367,7 +367,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)
367 * 367 *
368 * This routine will close down the fibctx passed in from the user. 368 * This routine will close down the fibctx passed in from the user.
369 */ 369 */
370 370
371static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) 371static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
372{ 372{
373 struct aac_fib_context *fibctx; 373 struct aac_fib_context *fibctx;
@@ -414,7 +414,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
414 * @arg: ioctl arguments 414 * @arg: ioctl arguments
415 * 415 *
416 * This routine returns the driver version. 416 * This routine returns the driver version.
417 * Under Linux, there have been no version incompatibilities, so this is 417 * Under Linux, there have been no version incompatibilities, so this is
418 * simple! 418 * simple!
419 */ 419 */
420 420
@@ -425,12 +425,12 @@ static int check_revision(struct aac_dev *dev, void __user *arg)
425 u32 version; 425 u32 version;
426 426
427 response.compat = 1; 427 response.compat = 1;
428 version = (simple_strtol(driver_version, 428 version = (simple_strtol(driver_version,
429 &driver_version, 10) << 24) | 0x00000400; 429 &driver_version, 10) << 24) | 0x00000400;
430 version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; 430 version += simple_strtol(driver_version + 1, &driver_version, 10) << 16;
431 version += simple_strtol(driver_version + 1, NULL, 10); 431 version += simple_strtol(driver_version + 1, NULL, 10);
432 response.version = cpu_to_le32(version); 432 response.version = cpu_to_le32(version);
433# if (defined(AAC_DRIVER_BUILD)) 433# ifdef AAC_DRIVER_BUILD
434 response.build = cpu_to_le32(AAC_DRIVER_BUILD); 434 response.build = cpu_to_le32(AAC_DRIVER_BUILD);
435# else 435# else
436 response.build = cpu_to_le32(9999); 436 response.build = cpu_to_le32(9999);
@@ -474,7 +474,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
474 return -EBUSY; 474 return -EBUSY;
475 } 475 }
476 if (!capable(CAP_SYS_ADMIN)){ 476 if (!capable(CAP_SYS_ADMIN)){
477 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); 477 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
478 return -EPERM; 478 return -EPERM;
479 } 479 }
480 /* 480 /*
@@ -489,7 +489,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
489 489
490 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */ 490 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
491 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){ 491 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
492 dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); 492 dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
493 rcode = -EFAULT; 493 rcode = -EFAULT;
494 goto cleanup; 494 goto cleanup;
495 } 495 }
@@ -506,7 +506,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
506 goto cleanup; 506 goto cleanup;
507 } 507 }
508 if(copy_from_user(user_srbcmd, user_srb,fibsize)){ 508 if(copy_from_user(user_srbcmd, user_srb,fibsize)){
509 dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); 509 dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
510 rcode = -EFAULT; 510 rcode = -EFAULT;
511 goto cleanup; 511 goto cleanup;
512 } 512 }
@@ -525,7 +525,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
525 srbcmd->retry_limit = 0; // Obsolete parameter 525 srbcmd->retry_limit = 0; // Obsolete parameter
526 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size); 526 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size);
527 memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb)); 527 memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb));
528 528
529 switch (flags & (SRB_DataIn | SRB_DataOut)) { 529 switch (flags & (SRB_DataIn | SRB_DataOut)) {
530 case SRB_DataOut: 530 case SRB_DataOut:
531 data_dir = DMA_TO_DEVICE; 531 data_dir = DMA_TO_DEVICE;
@@ -593,7 +593,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
593 sg_list[i] = p; // save so we can clean up later 593 sg_list[i] = p; // save so we can clean up later
594 sg_indx = i; 594 sg_indx = i;
595 595
596 if( flags & SRB_DataOut ){ 596 if (flags & SRB_DataOut) {
597 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 597 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
598 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 598 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
599 rcode = -EFAULT; 599 rcode = -EFAULT;
@@ -636,7 +636,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
636 sg_list[i] = p; // save so we can clean up later 636 sg_list[i] = p; // save so we can clean up later
637 sg_indx = i; 637 sg_indx = i;
638 638
639 if( flags & SRB_DataOut ){ 639 if (flags & SRB_DataOut) {
640 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ 640 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
641 kfree (usg); 641 kfree (usg);
642 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 642 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -679,7 +679,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
679 sg_list[i] = p; // save so we can clean up later 679 sg_list[i] = p; // save so we can clean up later
680 sg_indx = i; 680 sg_indx = i;
681 681
682 if( flags & SRB_DataOut ){ 682 if (flags & SRB_DataOut) {
683 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){ 683 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
684 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 684 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
685 rcode = -EFAULT; 685 rcode = -EFAULT;
@@ -707,7 +707,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
707 sg_list[i] = p; // save so we can clean up later 707 sg_list[i] = p; // save so we can clean up later
708 sg_indx = i; 708 sg_indx = i;
709 709
710 if( flags & SRB_DataOut ){ 710 if (flags & SRB_DataOut) {
711 if(copy_from_user(p, sg_user[i], 711 if(copy_from_user(p, sg_user[i],
712 upsg->sg[i].count)) { 712 upsg->sg[i].count)) {
713 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); 713 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -733,19 +733,19 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
733 } 733 }
734 734
735 if (status != 0){ 735 if (status != 0){
736 dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n")); 736 dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
737 rcode = -ENXIO; 737 rcode = -ENXIO;
738 goto cleanup; 738 goto cleanup;
739 } 739 }
740 740
741 if( flags & SRB_DataIn ) { 741 if (flags & SRB_DataIn) {
742 for(i = 0 ; i <= sg_indx; i++){ 742 for(i = 0 ; i <= sg_indx; i++){
743 byte_count = le32_to_cpu( 743 byte_count = le32_to_cpu(
744 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) 744 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
745 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count 745 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
746 : srbcmd->sg.sg[i].count); 746 : srbcmd->sg.sg[i].count);
747 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){ 747 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
748 dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n")); 748 dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
749 rcode = -EFAULT; 749 rcode = -EFAULT;
750 goto cleanup; 750 goto cleanup;
751 751
@@ -755,7 +755,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
755 755
756 reply = (struct aac_srb_reply *) fib_data(srbfib); 756 reply = (struct aac_srb_reply *) fib_data(srbfib);
757 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){ 757 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
758 dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n")); 758 dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
759 rcode = -EFAULT; 759 rcode = -EFAULT;
760 goto cleanup; 760 goto cleanup;
761 } 761 }
@@ -774,34 +774,34 @@ cleanup:
774} 774}
775 775
776struct aac_pci_info { 776struct aac_pci_info {
777 u32 bus; 777 u32 bus;
778 u32 slot; 778 u32 slot;
779}; 779};
780 780
781 781
782static int aac_get_pci_info(struct aac_dev* dev, void __user *arg) 782static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
783{ 783{
784 struct aac_pci_info pci_info; 784 struct aac_pci_info pci_info;
785 785
786 pci_info.bus = dev->pdev->bus->number; 786 pci_info.bus = dev->pdev->bus->number;
787 pci_info.slot = PCI_SLOT(dev->pdev->devfn); 787 pci_info.slot = PCI_SLOT(dev->pdev->devfn);
788 788
789 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) { 789 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
790 dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n")); 790 dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
791 return -EFAULT; 791 return -EFAULT;
792 } 792 }
793 return 0; 793 return 0;
794} 794}
795 795
796 796
797int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) 797int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
798{ 798{
799 int status; 799 int status;
800 800
801 /* 801 /*
802 * HBA gets first crack 802 * HBA gets first crack
803 */ 803 */
804 804
805 status = aac_dev_ioctl(dev, cmd, arg); 805 status = aac_dev_ioctl(dev, cmd, arg);
806 if(status != -ENOTTY) 806 if(status != -ENOTTY)
807 return status; 807 return status;
@@ -831,7 +831,7 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
831 break; 831 break;
832 default: 832 default:
833 status = -ENOTTY; 833 status = -ENOTTY;
834 break; 834 break;
835 } 835 }
836 return status; 836 return status;
837} 837}