hpsa.c (a1926d1745114789687ac029ae8c58944b7d2256) hpsa.c (b03a7771c81a0d5f026250c8cd4091d9ee767fdc)
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *

--- 2419 unchanged lines hidden (view full) ---

2428 if ((iocommand.buf_size < 1) &&
2429 (iocommand.Request.Type.Direction != XFER_NONE)) {
2430 return -EINVAL;
2431 }
2432 if (iocommand.buf_size > 0) {
2433 buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
2434 if (buff == NULL)
2435 return -EFAULT;
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *

--- 2419 unchanged lines hidden (view full) ---

2428 if ((iocommand.buf_size < 1) &&
2429 (iocommand.Request.Type.Direction != XFER_NONE)) {
2430 return -EINVAL;
2431 }
2432 if (iocommand.buf_size > 0) {
2433 buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
2434 if (buff == NULL)
2435 return -EFAULT;
2436 }
2437 if (iocommand.Request.Type.Direction == XFER_WRITE) {
2438 /* Copy the data into the buffer we created */
2439 if (copy_from_user(buff, iocommand.buf, iocommand.buf_size)) {
2440 kfree(buff);
2441 return -EFAULT;
2436 if (iocommand.Request.Type.Direction == XFER_WRITE) {
2437 /* Copy the data into the buffer we created */
2438 if (copy_from_user(buff, iocommand.buf,
2439 iocommand.buf_size)) {
2440 kfree(buff);
2441 return -EFAULT;
2442 }
2443 } else {
2444 memset(buff, 0, iocommand.buf_size);
2442 }
2445 }
2443 } else
2444 memset(buff, 0, iocommand.buf_size);
2446 }
2445 c = cmd_special_alloc(h);
2446 if (c == NULL) {
2447 kfree(buff);
2448 return -ENOMEM;
2449 }
2450 /* Fill in the command type */
2451 c->cmd_type = CMD_IOCTL_PEND;
2452 /* Fill in Command Header */

--- 29 unchanged lines hidden (view full) ---

2482 /* Copy the error information out */
2483 memcpy(&iocommand.error_info, c->err_info,
2484 sizeof(iocommand.error_info));
2485 if (copy_to_user(argp, &iocommand, sizeof(iocommand))) {
2486 kfree(buff);
2487 cmd_special_free(h, c);
2488 return -EFAULT;
2489 }
2447 c = cmd_special_alloc(h);
2448 if (c == NULL) {
2449 kfree(buff);
2450 return -ENOMEM;
2451 }
2452 /* Fill in the command type */
2453 c->cmd_type = CMD_IOCTL_PEND;
2454 /* Fill in Command Header */

--- 29 unchanged lines hidden (view full) ---

2484 /* Copy the error information out */
2485 memcpy(&iocommand.error_info, c->err_info,
2486 sizeof(iocommand.error_info));
2487 if (copy_to_user(argp, &iocommand, sizeof(iocommand))) {
2488 kfree(buff);
2489 cmd_special_free(h, c);
2490 return -EFAULT;
2491 }
2490
2491 if (iocommand.Request.Type.Direction == XFER_READ) {
2492 if (iocommand.Request.Type.Direction == XFER_READ &&
2493 iocommand.buf_size > 0) {
2492 /* Copy the data out of the buffer we created */
2493 if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) {
2494 kfree(buff);
2495 cmd_special_free(h, c);
2496 return -EFAULT;
2497 }
2498 }
2499 kfree(buff);

--- 76 unchanged lines hidden (view full) ---

2576 }
2577 c = cmd_special_alloc(h);
2578 if (c == NULL) {
2579 status = -ENOMEM;
2580 goto cleanup1;
2581 }
2582 c->cmd_type = CMD_IOCTL_PEND;
2583 c->Header.ReplyQueue = 0;
2494 /* Copy the data out of the buffer we created */
2495 if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) {
2496 kfree(buff);
2497 cmd_special_free(h, c);
2498 return -EFAULT;
2499 }
2500 }
2501 kfree(buff);

--- 76 unchanged lines hidden (view full) ---

2578 }
2579 c = cmd_special_alloc(h);
2580 if (c == NULL) {
2581 status = -ENOMEM;
2582 goto cleanup1;
2583 }
2584 c->cmd_type = CMD_IOCTL_PEND;
2585 c->Header.ReplyQueue = 0;
2584
2585 if (ioc->buf_size > 0) {
2586 c->Header.SGList = sg_used;
2587 c->Header.SGTotal = sg_used;
2588 } else {
2589 c->Header.SGList = 0;
2590 c->Header.SGTotal = 0;
2591 }
2586 c->Header.SGList = c->Header.SGTotal = sg_used;
2592 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN));
2593 c->Header.Tag.lower = c->busaddr;
2594 memcpy(&c->Request, &ioc->Request, sizeof(c->Request));
2595 if (ioc->buf_size > 0) {
2596 int i;
2597 for (i = 0; i < sg_used; i++) {
2598 temp64.val = pci_map_single(h->pdev, buff[i],
2599 buff_size[i], PCI_DMA_BIDIRECTIONAL);
2600 c->SG[i].Addr.lower = temp64.val32.lower;
2601 c->SG[i].Addr.upper = temp64.val32.upper;
2602 c->SG[i].Len = buff_size[i];
2603 /* we are not chaining */
2604 c->SG[i].Ext = 0;
2605 }
2606 }
2607 hpsa_scsi_do_simple_cmd_core(h, c);
2587 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN));
2588 c->Header.Tag.lower = c->busaddr;
2589 memcpy(&c->Request, &ioc->Request, sizeof(c->Request));
2590 if (ioc->buf_size > 0) {
2591 int i;
2592 for (i = 0; i < sg_used; i++) {
2593 temp64.val = pci_map_single(h->pdev, buff[i],
2594 buff_size[i], PCI_DMA_BIDIRECTIONAL);
2595 c->SG[i].Addr.lower = temp64.val32.lower;
2596 c->SG[i].Addr.upper = temp64.val32.upper;
2597 c->SG[i].Len = buff_size[i];
2598 /* we are not chaining */
2599 c->SG[i].Ext = 0;
2600 }
2601 }
2602 hpsa_scsi_do_simple_cmd_core(h, c);
2608 hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL);
2603 if (sg_used)
2604 hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL);
2609 check_ioctl_unit_attention(h, c);
2610 /* Copy the error information out */
2611 memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info));
2612 if (copy_to_user(argp, ioc, sizeof(*ioc))) {
2613 cmd_special_free(h, c);
2614 status = -EFAULT;
2615 goto cleanup1;
2616 }
2605 check_ioctl_unit_attention(h, c);
2606 /* Copy the error information out */
2607 memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info));
2608 if (copy_to_user(argp, ioc, sizeof(*ioc))) {
2609 cmd_special_free(h, c);
2610 status = -EFAULT;
2611 goto cleanup1;
2612 }
2617 if (ioc->Request.Type.Direction == XFER_READ) {
2613 if (ioc->Request.Type.Direction == XFER_READ && ioc->buf_size > 0) {
2618 /* Copy the data out of the buffer we created */
2619 BYTE __user *ptr = ioc->buf;
2620 for (i = 0; i < sg_used; i++) {
2621 if (copy_to_user(ptr, buff[i], buff_size[i])) {
2622 cmd_special_free(h, c);
2623 status = -EFAULT;
2624 goto cleanup1;
2625 }

--- 1480 unchanged lines hidden ---
2614 /* Copy the data out of the buffer we created */
2615 BYTE __user *ptr = ioc->buf;
2616 for (i = 0; i < sg_used; i++) {
2617 if (copy_to_user(ptr, buff[i], buff_size[i])) {
2618 cmd_special_free(h, c);
2619 status = -EFAULT;
2620 goto cleanup1;
2621 }

--- 1480 unchanged lines hidden ---