cam_periph.c (142157) | cam_periph.c (147723) |
---|---|
1/*- 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cam/cam_periph.c 142157 2005-02-20 23:45:49Z scottl $"); | 31__FBSDID("$FreeBSD: head/sys/cam/cam_periph.c 147723 2005-07-01 15:21:30Z avatar $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/malloc.h> | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/malloc.h> |
37#include <sys/kernel.h> |
|
37#include <sys/linker_set.h> 38#include <sys/bio.h> 39#include <sys/lock.h> 40#include <sys/mutex.h> 41#include <sys/buf.h> 42#include <sys/proc.h> 43#include <sys/devicestat.h> 44#include <sys/bus.h> --- 33 unchanged lines hidden (view full) --- 78 union ccb *save_ccb, 79 int *openings, 80 u_int32_t *relsim_flags, 81 u_int32_t *timeout); 82 83static int nperiph_drivers; 84struct periph_driver **periph_drivers; 85 | 38#include <sys/linker_set.h> 39#include <sys/bio.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/buf.h> 43#include <sys/proc.h> 44#include <sys/devicestat.h> 45#include <sys/bus.h> --- 33 unchanged lines hidden (view full) --- 79 union ccb *save_ccb, 80 int *openings, 81 u_int32_t *relsim_flags, 82 u_int32_t *timeout); 83 84static int nperiph_drivers; 85struct periph_driver **periph_drivers; 86 |
87MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers"); 88 |
|
86void 87periphdriver_register(void *data) 88{ 89 struct periph_driver **newdrivers, **old; 90 int ndrivers; 91 92 ndrivers = nperiph_drivers + 2; 93 newdrivers = malloc(sizeof(*newdrivers) * ndrivers, M_TEMP, M_WAITOK); --- 45 unchanged lines hidden (view full) --- 139 } else { 140 printf("cam_periph_alloc: attempt to re-allocate " 141 "valid device %s%d rejected\n", 142 periph->periph_name, periph->unit_number); 143 } 144 return (CAM_REQ_INVALID); 145 } 146 | 89void 90periphdriver_register(void *data) 91{ 92 struct periph_driver **newdrivers, **old; 93 int ndrivers; 94 95 ndrivers = nperiph_drivers + 2; 96 newdrivers = malloc(sizeof(*newdrivers) * ndrivers, M_TEMP, M_WAITOK); --- 45 unchanged lines hidden (view full) --- 142 } else { 143 printf("cam_periph_alloc: attempt to re-allocate " 144 "valid device %s%d rejected\n", 145 periph->periph_name, periph->unit_number); 146 } 147 return (CAM_REQ_INVALID); 148 } 149 |
147 periph = (struct cam_periph *)malloc(sizeof(*periph), M_DEVBUF, | 150 periph = (struct cam_periph *)malloc(sizeof(*periph), M_CAMPERIPH, |
148 M_NOWAIT); 149 150 if (periph == NULL) 151 return (CAM_RESRC_UNAVAIL); 152 153 init_level++; 154 155 for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) { --- 59 unchanged lines hidden (view full) --- 215 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); 216 splx(s); 217 xpt_remove_periph(periph); 218 /* FALLTHROUGH */ 219 case 2: 220 xpt_free_path(periph->path); 221 /* FALLTHROUGH */ 222 case 1: | 151 M_NOWAIT); 152 153 if (periph == NULL) 154 return (CAM_RESRC_UNAVAIL); 155 156 init_level++; 157 158 for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) { --- 59 unchanged lines hidden (view full) --- 218 TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); 219 splx(s); 220 xpt_remove_periph(periph); 221 /* FALLTHROUGH */ 222 case 2: 223 xpt_free_path(periph->path); 224 /* FALLTHROUGH */ 225 case 1: |
223 free(periph, M_DEVBUF); | 226 free(periph, M_CAMPERIPH); |
224 /* FALLTHROUGH */ 225 case 0: 226 /* No cleanup to perform. */ 227 break; 228 default: 229 panic("cam_periph_alloc: Unkown init level"); 230 } 231 return(status); --- 248 unchanged lines hidden (view full) --- 480 default: 481 arg = NULL; 482 break; 483 } 484 periph->deferred_callback(NULL, periph->deferred_ac, 485 periph->path, arg); 486 } 487 xpt_free_path(periph->path); | 227 /* FALLTHROUGH */ 228 case 0: 229 /* No cleanup to perform. */ 230 break; 231 default: 232 panic("cam_periph_alloc: Unkown init level"); 233 } 234 return(status); --- 248 unchanged lines hidden (view full) --- 483 default: 484 arg = NULL; 485 break; 486 } 487 periph->deferred_callback(NULL, periph->deferred_ac, 488 periph->path, arg); 489 } 490 xpt_free_path(periph->path); |
488 free(periph, M_DEVBUF); | 491 free(periph, M_CAMPERIPH); |
489} 490 491/* 492 * Wait interruptibly for an exclusive lock. 493 */ 494int 495cam_periph_lock(struct cam_periph *periph, int priority) 496{ --- 1247 unchanged lines hidden --- | 492} 493 494/* 495 * Wait interruptibly for an exclusive lock. 496 */ 497int 498cam_periph_lock(struct cam_periph *periph, int priority) 499{ --- 1247 unchanged lines hidden --- |