diff options
Diffstat (limited to 'drivers/scsi/aacraid/commctrl.c')
-rw-r--r-- | drivers/scsi/aacraid/commctrl.c | 112 |
1 files changed, 58 insertions, 54 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 1e6d7a9c75bf..851a7e599c50 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 | ||
58 | static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) | 58 | static 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 | /* |
@@ -243,6 +243,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) | |||
243 | * Search the list of AdapterFibContext addresses on the adapter | 243 | * Search the list of AdapterFibContext addresses on the adapter |
244 | * to be sure this is a valid address | 244 | * to be sure this is a valid address |
245 | */ | 245 | */ |
246 | spin_lock_irqsave(&dev->fib_lock, flags); | ||
246 | entry = dev->fib_list.next; | 247 | entry = dev->fib_list.next; |
247 | fibctx = NULL; | 248 | fibctx = NULL; |
248 | 249 | ||
@@ -251,37 +252,37 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) | |||
251 | /* | 252 | /* |
252 | * Extract the AdapterFibContext from the Input parameters. | 253 | * Extract the AdapterFibContext from the Input parameters. |
253 | */ | 254 | */ |
254 | if (fibctx->unique == f.fibctx) { /* We found a winner */ | 255 | if (fibctx->unique == f.fibctx) { /* We found a winner */ |
255 | break; | 256 | break; |
256 | } | 257 | } |
257 | entry = entry->next; | 258 | entry = entry->next; |
258 | fibctx = NULL; | 259 | fibctx = NULL; |
259 | } | 260 | } |
260 | if (!fibctx) { | 261 | if (!fibctx) { |
262 | spin_unlock_irqrestore(&dev->fib_lock, flags); | ||
261 | dprintk ((KERN_INFO "Fib Context not found\n")); | 263 | dprintk ((KERN_INFO "Fib Context not found\n")); |
262 | return -EINVAL; | 264 | return -EINVAL; |
263 | } | 265 | } |
264 | 266 | ||
265 | if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || | 267 | if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || |
266 | (fibctx->size != sizeof(struct aac_fib_context))) { | 268 | (fibctx->size != sizeof(struct aac_fib_context))) { |
269 | spin_unlock_irqrestore(&dev->fib_lock, flags); | ||
267 | dprintk ((KERN_INFO "Fib Context corrupt?\n")); | 270 | dprintk ((KERN_INFO "Fib Context corrupt?\n")); |
268 | return -EINVAL; | 271 | return -EINVAL; |
269 | } | 272 | } |
270 | status = 0; | 273 | status = 0; |
271 | spin_lock_irqsave(&dev->fib_lock, flags); | ||
272 | /* | 274 | /* |
273 | * If there are no fibs to send back, then either wait or return | 275 | * If there are no fibs to send back, then either wait or return |
274 | * -EAGAIN | 276 | * -EAGAIN |
275 | */ | 277 | */ |
276 | return_fib: | 278 | return_fib: |
277 | if (!list_empty(&fibctx->fib_list)) { | 279 | if (!list_empty(&fibctx->fib_list)) { |
278 | struct list_head * entry; | ||
279 | /* | 280 | /* |
280 | * Pull the next fib from the fibs | 281 | * Pull the next fib from the fibs |
281 | */ | 282 | */ |
282 | entry = fibctx->fib_list.next; | 283 | entry = fibctx->fib_list.next; |
283 | list_del(entry); | 284 | list_del(entry); |
284 | 285 | ||
285 | fib = list_entry(entry, struct fib, fiblink); | 286 | fib = list_entry(entry, struct fib, fiblink); |
286 | fibctx->count--; | 287 | fibctx->count--; |
287 | spin_unlock_irqrestore(&dev->fib_lock, flags); | 288 | spin_unlock_irqrestore(&dev->fib_lock, flags); |
@@ -289,7 +290,7 @@ return_fib: | |||
289 | kfree(fib->hw_fib_va); | 290 | kfree(fib->hw_fib_va); |
290 | kfree(fib); | 291 | kfree(fib); |
291 | return -EFAULT; | 292 | return -EFAULT; |
292 | } | 293 | } |
293 | /* | 294 | /* |
294 | * Free the space occupied by this copy of the fib. | 295 | * Free the space occupied by this copy of the fib. |
295 | */ | 296 | */ |
@@ -318,7 +319,7 @@ return_fib: | |||
318 | } | 319 | } |
319 | } else { | 320 | } else { |
320 | status = -EAGAIN; | 321 | status = -EAGAIN; |
321 | } | 322 | } |
322 | } | 323 | } |
323 | fibctx->jiffies = jiffies/HZ; | 324 | fibctx->jiffies = jiffies/HZ; |
324 | return status; | 325 | return status; |
@@ -327,7 +328,9 @@ return_fib: | |||
327 | int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) | 328 | int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) |
328 | { | 329 | { |
329 | struct fib *fib; | 330 | struct fib *fib; |
331 | unsigned long flags; | ||
330 | 332 | ||
333 | spin_lock_irqsave(&dev->fib_lock, flags); | ||
331 | /* | 334 | /* |
332 | * First free any FIBs that have not been consumed. | 335 | * First free any FIBs that have not been consumed. |
333 | */ | 336 | */ |
@@ -350,6 +353,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) | |||
350 | * Remove the Context from the AdapterFibContext List | 353 | * Remove the Context from the AdapterFibContext List |
351 | */ | 354 | */ |
352 | list_del(&fibctx->next); | 355 | list_del(&fibctx->next); |
356 | spin_unlock_irqrestore(&dev->fib_lock, flags); | ||
353 | /* | 357 | /* |
354 | * Invalidate context | 358 | * Invalidate context |
355 | */ | 359 | */ |
@@ -368,7 +372,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) | |||
368 | * | 372 | * |
369 | * This routine will close down the fibctx passed in from the user. | 373 | * This routine will close down the fibctx passed in from the user. |
370 | */ | 374 | */ |
371 | 375 | ||
372 | static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) | 376 | static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) |
373 | { | 377 | { |
374 | struct aac_fib_context *fibctx; | 378 | struct aac_fib_context *fibctx; |
@@ -415,8 +419,8 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) | |||
415 | * @arg: ioctl arguments | 419 | * @arg: ioctl arguments |
416 | * | 420 | * |
417 | * This routine returns the driver version. | 421 | * This routine returns the driver version. |
418 | * Under Linux, there have been no version incompatibilities, so this is | 422 | * Under Linux, there have been no version incompatibilities, so this is |
419 | * simple! | 423 | * simple! |
420 | */ | 424 | */ |
421 | 425 | ||
422 | static int check_revision(struct aac_dev *dev, void __user *arg) | 426 | static int check_revision(struct aac_dev *dev, void __user *arg) |
@@ -426,12 +430,12 @@ static int check_revision(struct aac_dev *dev, void __user *arg) | |||
426 | u32 version; | 430 | u32 version; |
427 | 431 | ||
428 | response.compat = 1; | 432 | response.compat = 1; |
429 | version = (simple_strtol(driver_version, | 433 | version = (simple_strtol(driver_version, |
430 | &driver_version, 10) << 24) | 0x00000400; | 434 | &driver_version, 10) << 24) | 0x00000400; |
431 | version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; | 435 | version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; |
432 | version += simple_strtol(driver_version + 1, NULL, 10); | 436 | version += simple_strtol(driver_version + 1, NULL, 10); |
433 | response.version = cpu_to_le32(version); | 437 | response.version = cpu_to_le32(version); |
434 | # if (defined(AAC_DRIVER_BUILD)) | 438 | # ifdef AAC_DRIVER_BUILD |
435 | response.build = cpu_to_le32(AAC_DRIVER_BUILD); | 439 | response.build = cpu_to_le32(AAC_DRIVER_BUILD); |
436 | # else | 440 | # else |
437 | response.build = cpu_to_le32(9999); | 441 | response.build = cpu_to_le32(9999); |
@@ -464,7 +468,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
464 | u32 data_dir; | 468 | u32 data_dir; |
465 | void __user *sg_user[32]; | 469 | void __user *sg_user[32]; |
466 | void *sg_list[32]; | 470 | void *sg_list[32]; |
467 | u32 sg_indx = 0; | 471 | u32 sg_indx = 0; |
468 | u32 byte_count = 0; | 472 | u32 byte_count = 0; |
469 | u32 actual_fibsize64, actual_fibsize = 0; | 473 | u32 actual_fibsize64, actual_fibsize = 0; |
470 | int i; | 474 | int i; |
@@ -475,7 +479,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
475 | return -EBUSY; | 479 | return -EBUSY; |
476 | } | 480 | } |
477 | if (!capable(CAP_SYS_ADMIN)){ | 481 | if (!capable(CAP_SYS_ADMIN)){ |
478 | dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); | 482 | dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); |
479 | return -EPERM; | 483 | return -EPERM; |
480 | } | 484 | } |
481 | /* | 485 | /* |
@@ -490,7 +494,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
490 | 494 | ||
491 | memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */ | 495 | memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */ |
492 | if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){ | 496 | if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){ |
493 | dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); | 497 | dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); |
494 | rcode = -EFAULT; | 498 | rcode = -EFAULT; |
495 | goto cleanup; | 499 | goto cleanup; |
496 | } | 500 | } |
@@ -507,7 +511,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
507 | goto cleanup; | 511 | goto cleanup; |
508 | } | 512 | } |
509 | if(copy_from_user(user_srbcmd, user_srb,fibsize)){ | 513 | if(copy_from_user(user_srbcmd, user_srb,fibsize)){ |
510 | dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); | 514 | dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); |
511 | rcode = -EFAULT; | 515 | rcode = -EFAULT; |
512 | goto cleanup; | 516 | goto cleanup; |
513 | } | 517 | } |
@@ -518,15 +522,15 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
518 | // Fix up srb for endian and force some values | 522 | // Fix up srb for endian and force some values |
519 | 523 | ||
520 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this | 524 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this |
521 | srbcmd->channel = cpu_to_le32(user_srbcmd->channel); | 525 | srbcmd->channel = cpu_to_le32(user_srbcmd->channel); |
522 | srbcmd->id = cpu_to_le32(user_srbcmd->id); | 526 | srbcmd->id = cpu_to_le32(user_srbcmd->id); |
523 | srbcmd->lun = cpu_to_le32(user_srbcmd->lun); | 527 | srbcmd->lun = cpu_to_le32(user_srbcmd->lun); |
524 | srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout); | 528 | srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout); |
525 | srbcmd->flags = cpu_to_le32(flags); | 529 | srbcmd->flags = cpu_to_le32(flags); |
526 | srbcmd->retry_limit = 0; // Obsolete parameter | 530 | srbcmd->retry_limit = 0; // Obsolete parameter |
527 | srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size); | 531 | srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size); |
528 | memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb)); | 532 | memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb)); |
529 | 533 | ||
530 | switch (flags & (SRB_DataIn | SRB_DataOut)) { | 534 | switch (flags & (SRB_DataIn | SRB_DataOut)) { |
531 | case SRB_DataOut: | 535 | case SRB_DataOut: |
532 | data_dir = DMA_TO_DEVICE; | 536 | data_dir = DMA_TO_DEVICE; |
@@ -582,7 +586,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
582 | void* p; | 586 | void* p; |
583 | /* Does this really need to be GFP_DMA? */ | 587 | /* Does this really need to be GFP_DMA? */ |
584 | p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA); | 588 | p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
585 | if(p == 0) { | 589 | if(!p) { |
586 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", | 590 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
587 | upsg->sg[i].count,i,upsg->count)); | 591 | upsg->sg[i].count,i,upsg->count)); |
588 | rcode = -ENOMEM; | 592 | rcode = -ENOMEM; |
@@ -594,7 +598,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
594 | sg_list[i] = p; // save so we can clean up later | 598 | sg_list[i] = p; // save so we can clean up later |
595 | sg_indx = i; | 599 | sg_indx = i; |
596 | 600 | ||
597 | if( flags & SRB_DataOut ){ | 601 | if (flags & SRB_DataOut) { |
598 | if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ | 602 | if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ |
599 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); | 603 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
600 | rcode = -EFAULT; | 604 | rcode = -EFAULT; |
@@ -626,7 +630,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
626 | void* p; | 630 | void* p; |
627 | /* Does this really need to be GFP_DMA? */ | 631 | /* Does this really need to be GFP_DMA? */ |
628 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); | 632 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
629 | if(p == 0) { | 633 | if(!p) { |
630 | kfree (usg); | 634 | kfree (usg); |
631 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", | 635 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
632 | usg->sg[i].count,i,usg->count)); | 636 | usg->sg[i].count,i,usg->count)); |
@@ -637,7 +641,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
637 | sg_list[i] = p; // save so we can clean up later | 641 | sg_list[i] = p; // save so we can clean up later |
638 | sg_indx = i; | 642 | sg_indx = i; |
639 | 643 | ||
640 | if( flags & SRB_DataOut ){ | 644 | if (flags & SRB_DataOut) { |
641 | if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ | 645 | if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ |
642 | kfree (usg); | 646 | kfree (usg); |
643 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); | 647 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
@@ -668,7 +672,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
668 | void* p; | 672 | void* p; |
669 | /* Does this really need to be GFP_DMA? */ | 673 | /* Does this really need to be GFP_DMA? */ |
670 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); | 674 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
671 | if(p == 0) { | 675 | if(!p) { |
672 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", | 676 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
673 | usg->sg[i].count,i,usg->count)); | 677 | usg->sg[i].count,i,usg->count)); |
674 | rcode = -ENOMEM; | 678 | rcode = -ENOMEM; |
@@ -680,7 +684,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
680 | sg_list[i] = p; // save so we can clean up later | 684 | sg_list[i] = p; // save so we can clean up later |
681 | sg_indx = i; | 685 | sg_indx = i; |
682 | 686 | ||
683 | if( flags & SRB_DataOut ){ | 687 | if (flags & SRB_DataOut) { |
684 | if(copy_from_user(p,sg_user[i],usg->sg[i].count)){ | 688 | if(copy_from_user(p,sg_user[i],usg->sg[i].count)){ |
685 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); | 689 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
686 | rcode = -EFAULT; | 690 | rcode = -EFAULT; |
@@ -698,7 +702,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
698 | dma_addr_t addr; | 702 | dma_addr_t addr; |
699 | void* p; | 703 | void* p; |
700 | p = kmalloc(upsg->sg[i].count, GFP_KERNEL); | 704 | p = kmalloc(upsg->sg[i].count, GFP_KERNEL); |
701 | if(p == 0) { | 705 | if (!p) { |
702 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", | 706 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
703 | upsg->sg[i].count, i, upsg->count)); | 707 | upsg->sg[i].count, i, upsg->count)); |
704 | rcode = -ENOMEM; | 708 | rcode = -ENOMEM; |
@@ -708,7 +712,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
708 | sg_list[i] = p; // save so we can clean up later | 712 | sg_list[i] = p; // save so we can clean up later |
709 | sg_indx = i; | 713 | sg_indx = i; |
710 | 714 | ||
711 | if( flags & SRB_DataOut ){ | 715 | if (flags & SRB_DataOut) { |
712 | if(copy_from_user(p, sg_user[i], | 716 | if(copy_from_user(p, sg_user[i], |
713 | upsg->sg[i].count)) { | 717 | upsg->sg[i].count)) { |
714 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); | 718 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
@@ -734,19 +738,19 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
734 | } | 738 | } |
735 | 739 | ||
736 | if (status != 0){ | 740 | if (status != 0){ |
737 | dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n")); | 741 | dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n")); |
738 | rcode = -ENXIO; | 742 | rcode = -ENXIO; |
739 | goto cleanup; | 743 | goto cleanup; |
740 | } | 744 | } |
741 | 745 | ||
742 | if( flags & SRB_DataIn ) { | 746 | if (flags & SRB_DataIn) { |
743 | for(i = 0 ; i <= sg_indx; i++){ | 747 | for(i = 0 ; i <= sg_indx; i++){ |
744 | byte_count = le32_to_cpu( | 748 | byte_count = le32_to_cpu( |
745 | (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) | 749 | (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) |
746 | ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count | 750 | ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count |
747 | : srbcmd->sg.sg[i].count); | 751 | : srbcmd->sg.sg[i].count); |
748 | if(copy_to_user(sg_user[i], sg_list[i], byte_count)){ | 752 | if(copy_to_user(sg_user[i], sg_list[i], byte_count)){ |
749 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n")); | 753 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n")); |
750 | rcode = -EFAULT; | 754 | rcode = -EFAULT; |
751 | goto cleanup; | 755 | goto cleanup; |
752 | 756 | ||
@@ -756,7 +760,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
756 | 760 | ||
757 | reply = (struct aac_srb_reply *) fib_data(srbfib); | 761 | reply = (struct aac_srb_reply *) fib_data(srbfib); |
758 | if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){ | 762 | if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){ |
759 | dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n")); | 763 | dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n")); |
760 | rcode = -EFAULT; | 764 | rcode = -EFAULT; |
761 | goto cleanup; | 765 | goto cleanup; |
762 | } | 766 | } |
@@ -775,34 +779,34 @@ cleanup: | |||
775 | } | 779 | } |
776 | 780 | ||
777 | struct aac_pci_info { | 781 | struct aac_pci_info { |
778 | u32 bus; | 782 | u32 bus; |
779 | u32 slot; | 783 | u32 slot; |
780 | }; | 784 | }; |
781 | 785 | ||
782 | 786 | ||
783 | static int aac_get_pci_info(struct aac_dev* dev, void __user *arg) | 787 | static int aac_get_pci_info(struct aac_dev* dev, void __user *arg) |
784 | { | 788 | { |
785 | struct aac_pci_info pci_info; | 789 | struct aac_pci_info pci_info; |
786 | 790 | ||
787 | pci_info.bus = dev->pdev->bus->number; | 791 | pci_info.bus = dev->pdev->bus->number; |
788 | pci_info.slot = PCI_SLOT(dev->pdev->devfn); | 792 | pci_info.slot = PCI_SLOT(dev->pdev->devfn); |
789 | 793 | ||
790 | if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) { | 794 | if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) { |
791 | dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n")); | 795 | dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n")); |
792 | return -EFAULT; | 796 | return -EFAULT; |
793 | } | 797 | } |
794 | return 0; | 798 | return 0; |
795 | } | 799 | } |
796 | 800 | ||
797 | 801 | ||
798 | int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) | 802 | int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) |
799 | { | 803 | { |
800 | int status; | 804 | int status; |
801 | 805 | ||
802 | /* | 806 | /* |
803 | * HBA gets first crack | 807 | * HBA gets first crack |
804 | */ | 808 | */ |
805 | 809 | ||
806 | status = aac_dev_ioctl(dev, cmd, arg); | 810 | status = aac_dev_ioctl(dev, cmd, arg); |
807 | if(status != -ENOTTY) | 811 | if(status != -ENOTTY) |
808 | return status; | 812 | return status; |
@@ -832,7 +836,7 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) | |||
832 | break; | 836 | break; |
833 | default: | 837 | default: |
834 | status = -ENOTTY; | 838 | status = -ENOTTY; |
835 | break; | 839 | break; |
836 | } | 840 | } |
837 | return status; | 841 | return status; |
838 | } | 842 | } |