FreeBSD/sys/cam/scsi/scsi_pass.c
/*
 * Generally, "ccb" should be the CCB supplied by the kernel.  "inccb"
 * should be the CCB that is copied in from the user.
 */
Generally, "ccb" should be the CCB supplied by the kernel.  "inccb"
should be the CCB that is copied in from the user.
Generally " ccb " should be the CCB supplied by the kernel . " inccb " should be the CCB that is copied in from the user .
static int
passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
{
	struct pass_softc *softc;
	struct cam_periph_map_info mapinfo;
	xpt_opcode fc;
	int error;
	softc = (struct pass_softc *)periph->softc;
	xpt_merge_ccb(ccb, inccb);
	ccb->ccb_h.cbfcnp = passdone;
	fc = ccb->ccb_h.func_code;
	if ((fc == XPT_SCSI_IO) || (fc == XPT_ATA_IO) || (fc == XPT_SMP_IO)
	 || (fc == XPT_DEV_MATCH) || (fc == XPT_DEV_ADVINFO)) {
		bzero(&mapinfo, sizeof(mapinfo));
		cam_periph_unlock(periph);
		error = cam_periph_mapmem(ccb, &mapinfo, softc->maxio);
		cam_periph_lock(periph);
		if (error)
			return(error);
	} else
		mapinfo.num_bufs_used = 0;
	cam_periph_runccb(ccb, passerror,  CAM_RETRY_SELTO,
	     ((ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ?
	     SF_RETRY_UA : SF_NO_RECOVERY) | SF_NO_PRINT,
	    softc->device_stats);
	cam_periph_unmapmem(ccb, &mapinfo);
	ccb->ccb_h.cbfcnp = NULL;
	ccb->ccb_h.periph_priv = inccb->ccb_h.periph_priv;
	bcopy(ccb, inccb, sizeof(union ccb));
	return(0);
}
static int passsendccb ( struct cam_periph * periph , union ccb * ccb , union ccb * inccb ) { struct pass_softc * softc ; struct cam_periph_map_info mapinfo ; xpt_opcode fc ; int error ; softc = ( struct pass_softc * ) periph -> softc ; xpt_merge_ccb ( ccb , inccb ) ; ccb -> ccb_h . cbfcnp = passdone ; fc = ccb -> ccb_h . func_code ; if ( ( fc == XPT_SCSI_IO ) || ( fc == XPT_ATA_IO ) || ( fc == XPT_SMP_IO ) || ( fc == XPT_DEV_MATCH ) || ( fc == XPT_DEV_ADVINFO ) ) { bzero ( & mapinfo , sizeof ( mapinfo ) ) ; cam_periph_unlock ( periph ) ; error = cam_periph_mapmem ( ccb , & mapinfo , softc -> maxio ) ; cam_periph_lock ( periph ) ; if ( error ) return ( error ) ; } else mapinfo . num_bufs_used = 0 ; cam_periph_runccb ( ccb , passerror , CAM_RETRY_SELTO , ( ( ccb -> ccb_h . flags & CAM_PASS_ERR_RECOVER ) ? SF_RETRY_UA : SF_NO_RECOVERY ) | SF_NO_PRINT , softc -> device_stats ) ; cam_periph_unmapmem ( ccb , & mapinfo ) ; ccb -> ccb_h . cbfcnp = NULL ; ccb -> ccb_h . periph_priv = inccb -> ccb_h . periph_priv ; bcopy ( ccb , inccb , sizeof ( union ccb ) ) ; return ( 0 ) ; }
Generally, "ccb" should be the CCB supplied by the kernel.
Generally " ccb " should be the CCB supplied by the kernel .
/*
	 * There are some fields in the CCB header that need to be
	 * preserved, the rest we get from the user.
	 */ /*
	 */ /*
	 * Let cam_periph_mapmem do a sanity check on the data pointer format.
	 * Even if no data transfer is needed, it's a cheap check and it
	 * simplifies the code.
	 */ /*
		 * cam_periph_mapmem calls into proc and vm functions that can
		 * sleep as well as trigger I/O, so we can't hold the lock.
		 * Dropping it here is reasonably safe.
		 */ /*
		 * cam_periph_mapmem returned an error, we can't continue.
		 * Return the error to the user.
		 */ /* Ensure that the unmap call later on is a no-op. */ /*
	 * If the user wants us to perform any error recovery, then honor
	 * that request.  Otherwise, it's up to the user to perform any
	 * error recovery.
	 */ /* cam_flags */ /* sense_flags */