FreeBSD/sys/dev/aacraid/aacraid_cam.c
/*
 * Register the driver as a CAM SIM
 */
Register the driver as a CAM SIM
Register the driver as a CAM SIM
static int
aac_cam_attach(device_t dev)
{
	struct cam_devq *devq;
	struct cam_sim *sim;
	struct cam_path *path;
	struct aac_cam *camsc;
	struct aac_sim *inf;
	camsc = (struct aac_cam *)device_get_softc(dev);
	inf = (struct aac_sim *)device_get_ivars(dev);
	if (!inf)
		return (EIO);
	fwprintf(inf->aac_sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
	camsc->inf = inf;
	camsc->inf->aac_cam = camsc;
	devq = cam_simq_alloc(inf->TargetsPerBus);
	if (devq == NULL)
		return (EIO);
	sim = aac_sim_alloc(aac_cam_action, aac_cam_poll, "aacraidp", camsc,
	    device_get_unit(dev), &inf->aac_sc->aac_io_lock, 1, 1, devq);
	if (sim == NULL) {
		cam_simq_free(devq);
		return (EIO);
	}
	mtx_lock(&inf->aac_sc->aac_io_lock);
	if (aac_xpt_bus_register(sim, dev, 0) != CAM_SUCCESS) {
		cam_sim_free(sim, TRUE);
		mtx_unlock(&inf->aac_sc->aac_io_lock);
		return (EIO);
	}
	if (xpt_create_path(&path, NULL, cam_sim_path(sim),
	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
		xpt_bus_deregister(cam_sim_path(sim));
		cam_sim_free(sim, TRUE);
		mtx_unlock(&inf->aac_sc->aac_io_lock);
		return (EIO);
	}
#if __FreeBSD_version >= 700000
	inf->aac_sc->cam_rescan_cb = aac_cam_rescan;
#endif
	mtx_unlock(&inf->aac_sc->aac_io_lock);
	camsc->sim = sim;
	camsc->path = path;
	return (0);
}
static int aac_cam_attach ( device_t dev ) { struct cam_devq * devq ; struct cam_sim * sim ; struct cam_path * path ; struct aac_cam * camsc ; struct aac_sim * inf ; camsc = ( struct aac_cam * ) device_get_softc ( dev ) ; inf = ( struct aac_sim * ) device_get_ivars ( dev ) ; if ( ! inf ) return ( EIO ) ; fwprintf ( inf -> aac_sc , HBA_FLAGS_DBG_FUNCTION_ENTRY_B , " " ) ; camsc -> inf = inf ; camsc -> inf -> aac_cam = camsc ; devq = cam_simq_alloc ( inf -> TargetsPerBus ) ; if ( devq == NULL ) return ( EIO ) ; sim = aac_sim_alloc ( aac_cam_action , aac_cam_poll , " " , camsc , device_get_unit ( dev ) , & inf -> aac_sc -> aac_io_lock , 1 , 1 , devq ) ; if ( sim == NULL ) { cam_simq_free ( devq ) ; return ( EIO ) ; } mtx_lock ( & inf -> aac_sc -> aac_io_lock ) ; if ( aac_xpt_bus_register ( sim , dev , 0 ) != CAM_SUCCESS ) { cam_sim_free ( sim , TRUE ) ; mtx_unlock ( & inf -> aac_sc -> aac_io_lock ) ; return ( EIO ) ; } if ( xpt_create_path ( & path , NULL , cam_sim_path ( sim ) , CAM_TARGET_WILDCARD , CAM_LUN_WILDCARD ) != CAM_REQ_CMP ) { xpt_bus_deregister ( cam_sim_path ( sim ) ) ; cam_sim_free ( sim , TRUE ) ; mtx_unlock ( & inf -> aac_sc -> aac_io_lock ) ; return ( EIO ) ; } #if __FreeBSD_version >= 700000 inf -> aac_sc -> cam_rescan_cb = aac_cam_rescan ; #endif mtx_unlock ( & inf -> aac_sc -> aac_io_lock ) ; camsc -> sim = sim ; camsc -> path = path ; return ( 0 ) ; }
Register the driver as a CAM SIM
Register the driver as a CAM SIM
/* Since every bus has it's own sim, every bus 'appears' as bus 0 */