Deleted Added
full compact
amr.c (143121) amr.c (143488)
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * Copyright (c) 2005 Scott Long
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999,2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * Copyright (c) 2005 Scott Long
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
59__FBSDID("$FreeBSD: head/sys/dev/amr/amr.c 143121 2005-03-04 06:11:00Z scottl $");
59__FBSDID("$FreeBSD: head/sys/dev/amr/amr.c 143488 2005-03-13 06:25:53Z scottl $");
60
61/*
62 * Driver for the AMI MegaRaid family of controllers.
63 */
64
65#include <sys/param.h>
66#include <sys/systm.h>
67#include <sys/malloc.h>

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

466 ap = NULL;
467
468 /* Logical Drive not supported by the driver */
469 if (au_cmd[0] == 0xa4 && au_cmd[1] == 0x1c)
470 return (ENOIOCTL);
471
472 /* handle inbound data buffer */
473 if (au_length != 0 && au_cmd[0] != 0x06) {
60
61/*
62 * Driver for the AMI MegaRaid family of controllers.
63 */
64
65#include <sys/param.h>
66#include <sys/systm.h>
67#include <sys/malloc.h>

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

466 ap = NULL;
467
468 /* Logical Drive not supported by the driver */
469 if (au_cmd[0] == 0xa4 && au_cmd[1] == 0x1c)
470 return (ENOIOCTL);
471
472 /* handle inbound data buffer */
473 if (au_length != 0 && au_cmd[0] != 0x06) {
474 if ((dp = malloc(au_length, M_DEVBUF, M_WAITOK)) == NULL)
475 return(ENOMEM);
474 dp = malloc(au_length, M_DEVBUF, M_WAITOK|M_ZERO);
476
475
477 if ((ap = malloc(sizeof(struct amr_passthrough ), M_DEVBUF, M_WAITOK)) == NULL)
478 return(ENOMEM);
479
480 if ((error = copyin(au_buffer, dp, au_length)) != 0) {
481 free(dp, M_DEVBUF);
482 return (error);
483 }
484 debug(2, "copyin %ld bytes from %p -> %p", au_length, au_buffer, dp);
485 }
486
476 if ((error = copyin(au_buffer, dp, au_length)) != 0) {
477 free(dp, M_DEVBUF);
478 return (error);
479 }
480 debug(2, "copyin %ld bytes from %p -> %p", au_length, au_buffer, dp);
481 }
482
483 /* Allocate this now before the mutex gets held */
484 if (au_cmd[0] == AMR_CMD_PASS)
485 ap = malloc(sizeof(struct amr_passthrough), M_DEVBUF, M_WAITOK|M_ZERO);
486
487 mtx_lock(&sc->amr_io_lock);
488 if ((ac = amr_alloccmd(sc)) == NULL) {
489 error = ENOMEM;
490 goto out;
491 }
492
493 /* handle SCSI passthrough command */
494 if (au_cmd[0] == AMR_CMD_PASS) {

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

558 debug(2, "%16d", (int)dp);
559 *au_statusp = ac->ac_status;
560
561out:
562 /*
563 * At this point, we know that there is a lock held and that these
564 * objects have been allocated.
565 */
487 mtx_lock(&sc->amr_io_lock);
488 if ((ac = amr_alloccmd(sc)) == NULL) {
489 error = ENOMEM;
490 goto out;
491 }
492
493 /* handle SCSI passthrough command */
494 if (au_cmd[0] == AMR_CMD_PASS) {

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

558 debug(2, "%16d", (int)dp);
559 *au_statusp = ac->ac_status;
560
561out:
562 /*
563 * At this point, we know that there is a lock held and that these
564 * objects have been allocated.
565 */
566 free(dp, M_DEVBUF);
567 free(ap, M_DEVBUF);
568 amr_releasecmd(ac);
566 if (ac != NULL)
567 amr_releasecmd(ac);
569 mtx_unlock(&sc->amr_io_lock);
568 mtx_unlock(&sc->amr_io_lock);
569 if (dp != NULL)
570 free(dp, M_DEVBUF);
571 if (ap != NULL)
572 free(ap, M_DEVBUF);
570 return(error);
571}
572
573/********************************************************************************
574 ********************************************************************************
575 Status Monitoring
576 ********************************************************************************
577 ********************************************************************************/

--- 1418 unchanged lines hidden ---
573 return(error);
574}
575
576/********************************************************************************
577 ********************************************************************************
578 Status Monitoring
579 ********************************************************************************
580 ********************************************************************************/

--- 1418 unchanged lines hidden ---