Index: head/sys/cam/ata/ata_da.c =================================================================== --- head/sys/cam/ata/ata_da.c +++ head/sys/cam/ata/ata_da.c @@ -911,7 +911,7 @@ int error; periph = (struct cam_periph *)dp->d_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { return(ENXIO); } @@ -1328,7 +1328,7 @@ softc->state = ADA_STATE_LOGDIR; else break; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) softc->state = ADA_STATE_NORMAL; else xpt_schedule(periph, CAM_PRIORITY_DEV); @@ -1841,7 +1841,7 @@ * We'll release this reference once GEOM calls us back (via * adadiskgonecb()) telling us that our provider has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -1866,7 +1866,7 @@ * Create our sysctl variables, now that we know * we have successfully attached. */ - if (cam_periph_acquire(periph) == CAM_REQ_CMP) + if (cam_periph_acquire(periph) == 0) taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); /* Index: head/sys/cam/ata/ata_pmp.c =================================================================== --- head/sys/cam/ata/ata_pmp.c +++ head/sys/cam/ata/ata_pmp.c @@ -315,7 +315,7 @@ if (code == AC_SENT_BDR || code == AC_BUS_RESET) softc->found = 0; /* We have to reset everything. */ if (softc->state == PMP_STATE_NORMAL) { - if (cam_periph_acquire(periph) == CAM_REQ_CMP) { + if (cam_periph_acquire(periph) == 0) { if (softc->pm_pid == 0x37261095 || softc->pm_pid == 0x38261095) softc->state = PMP_STATE_PM_QUIRKS_1; @@ -343,7 +343,7 @@ char tmpstr[32], tmpstr2[16]; periph = (struct cam_periph *)context; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return; softc = (struct pmp_softc *)periph->softc; Index: head/sys/cam/ata/ata_xpt.c =================================================================== --- head/sys/cam/ata/ata_xpt.c +++ head/sys/cam/ata/ata_xpt.c @@ -280,7 +280,6 @@ proberegister(struct cam_periph *periph, void *arg) { union ccb *request_ccb; /* CCB representing the probe request */ - cam_status status; probe_softc *softc; request_ccb = (union ccb *)arg; @@ -304,10 +303,9 @@ periph->softc = softc; softc->periph = periph; softc->action = PROBE_INVALID; - status = cam_periph_acquire(periph); - if (status != CAM_REQ_CMP) { - return (status); - } + if (cam_periph_acquire(periph) != 0) + return (CAM_REQ_CMP_ERR); + CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n")); ata_device_transport(periph->path); probeschedule(periph); Index: head/sys/cam/cam_periph.h =================================================================== --- head/sys/cam/cam_periph.h +++ head/sys/cam/cam_periph.h @@ -159,7 +159,7 @@ ac_callback_t *, ac_code, void *arg); struct cam_periph *cam_periph_find(struct cam_path *path, char *name); int cam_periph_list(struct cam_path *, struct sbuf *); -cam_status cam_periph_acquire(struct cam_periph *periph); +int cam_periph_acquire(struct cam_periph *periph); void cam_periph_doacquire(struct cam_periph *periph); void cam_periph_release(struct cam_periph *periph); void cam_periph_release_locked(struct cam_periph *periph); Index: head/sys/cam/cam_periph.c =================================================================== --- head/sys/cam/cam_periph.c +++ head/sys/cam/cam_periph.c @@ -403,19 +403,19 @@ return (count); } -cam_status +int cam_periph_acquire(struct cam_periph *periph) { - cam_status status; + int status; - status = CAM_REQ_CMP_ERR; if (periph == NULL) - return (status); + return (EINVAL); + status = ENOENT; xpt_lock_buses(); if ((periph->flags & CAM_PERIPH_INVALID) == 0) { periph->refcount++; - status = CAM_REQ_CMP; + status = 0; } xpt_unlock_buses(); @@ -482,7 +482,7 @@ * from user us while we sleep. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return (ENXIO); cam_periph_assert(periph, MA_OWNED); Index: head/sys/cam/ctl/scsi_ctl.c =================================================================== --- head/sys/cam/ctl/scsi_ctl.c +++ head/sys/cam/ctl/scsi_ctl.c @@ -459,7 +459,7 @@ struct ctlfe_lun_softc *softc; union ccb ccb; cam_status status; - int i; + int i, acstatus; softc = (struct ctlfe_lun_softc *)arg; bus_softc = softc->parent_softc; @@ -539,11 +539,11 @@ } } - status = cam_periph_acquire(periph); - if ((status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + acstatus = cam_periph_acquire(periph); + if (acstatus != 0) { xpt_print(periph->path, "%s: could not acquire reference " - "count, status = %#x\n", __func__, status); - return (status); + "count, status = %#x\n", __func__, acstatus); + return (CAM_REQ_CMP_ERR); } if (i == 0) { Index: head/sys/cam/mmc/mmc_da.c =================================================================== --- head/sys/cam/mmc/mmc_da.c +++ head/sys/cam/mmc/mmc_da.c @@ -369,7 +369,7 @@ int error; periph = (struct cam_periph *)dp->d_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { return(ENXIO); } @@ -744,7 +744,7 @@ * We'll release this reference once GEOM calls us back (via * sddadiskgonecb()) telling us that our provider has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); Index: head/sys/cam/mmc/mmc_xpt.c =================================================================== --- head/sys/cam/mmc/mmc_xpt.c +++ head/sys/cam/mmc/mmc_xpt.c @@ -471,9 +471,9 @@ static cam_status mmcprobe_register(struct cam_periph *periph, void *arg) { - union ccb *request_ccb; /* CCB representing the probe request */ - cam_status status; mmcprobe_softc *softc; + union ccb *request_ccb; /* CCB representing the probe request */ + int status; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("mmcprobe_register\n")); @@ -501,10 +501,10 @@ status = cam_periph_acquire(periph); memset(&periph->path->device->mmc_ident_data, 0, sizeof(struct mmc_params)); - if (status != CAM_REQ_CMP) { + if (status != 0) { printf("proberegister: cam_periph_acquire failed (status=%d)\n", status); - return (status); + return (CAM_REQ_CMP_ERR); } CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n")); Index: head/sys/cam/nvme/nvme_da.c =================================================================== --- head/sys/cam/nvme/nvme_da.c +++ head/sys/cam/nvme/nvme_da.c @@ -260,7 +260,7 @@ int error; periph = (struct cam_periph *)dp->d_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { return(ENXIO); } @@ -785,7 +785,7 @@ * We'll release this reference once GEOM calls us back (via * ndadiskgonecb()) telling us that our provider has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -807,7 +807,7 @@ * Create our sysctl variables, now that we know * we have successfully attached. */ - if (cam_periph_acquire(periph) == CAM_REQ_CMP) + if (cam_periph_acquire(periph) == 0) taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); /* Index: head/sys/cam/nvme/nvme_xpt.c =================================================================== --- head/sys/cam/nvme/nvme_xpt.c +++ head/sys/cam/nvme/nvme_xpt.c @@ -198,7 +198,6 @@ nvme_probe_register(struct cam_periph *periph, void *arg) { union ccb *request_ccb; /* CCB representing the probe request */ - cam_status status; nvme_probe_softc *softc; request_ccb = (union ccb *)arg; @@ -222,10 +221,9 @@ periph->softc = softc; softc->periph = periph; softc->action = NVME_PROBE_INVALID; - status = cam_periph_acquire(periph); - if (status != CAM_REQ_CMP) { - return (status); - } + if (cam_periph_acquire(periph) != 0) + return (CAM_REQ_CMP_ERR); + CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n")); // nvme_device_transport(periph->path); Index: head/sys/cam/scsi/scsi_cd.c =================================================================== --- head/sys/cam/scsi/scsi_cd.c +++ head/sys/cam/scsi/scsi_cd.c @@ -445,7 +445,7 @@ case AC_SCSI_AEN: softc = (struct cd_softc *)periph->softc; if (softc->state == CD_STATE_NORMAL && !softc->tur) { - if (cam_periph_acquire(periph) == CAM_REQ_CMP) { + if (cam_periph_acquire(periph) == 0) { softc->tur = 1; xpt_schedule(periph, CAM_PRIORITY_NORMAL); } @@ -480,7 +480,7 @@ char tmpstr[32], tmpstr2[16]; periph = (struct cam_periph *)context; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return; softc = (struct cd_softc *)periph->softc; @@ -676,7 +676,7 @@ * We'll release this reference once GEOM calls us back (via * dadiskgonecb()) telling us that our provider has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -717,7 +717,7 @@ periph = (struct cam_periph *)dp->d_drv1; softc = (struct cd_softc *)periph->softc; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return(ENXIO); cam_periph_lock(periph); @@ -2601,7 +2601,7 @@ if (softc->state == CD_STATE_NORMAL && !softc->tur && softc->outstanding_cmds == 0) { - if (cam_periph_acquire(periph) == CAM_REQ_CMP) { + if (cam_periph_acquire(periph) == 0) { softc->tur = 1; xpt_schedule(periph, CAM_PRIORITY_NORMAL); } Index: head/sys/cam/scsi/scsi_da.c =================================================================== --- head/sys/cam/scsi/scsi_da.c +++ head/sys/cam/scsi/scsi_da.c @@ -1565,7 +1565,7 @@ token_sanity(token); DA_PERIPH_PRINT(periph, "acquiring device %s (%d): %d\n", da_ref_text[token], token, err); - if (err == CAM_REQ_CMP) { + if (err == 0) { int cnt; struct da_softc *softc = periph->softc; @@ -1628,7 +1628,7 @@ int error; periph = (struct cam_periph *)dp->d_drv1; - if (da_periph_acquire(periph, DA_REF_OPEN) != CAM_REQ_CMP) { + if (da_periph_acquire(periph, DA_REF_OPEN) != 0) { return (ENXIO); } @@ -2061,7 +2061,7 @@ case AC_SCSI_AEN: softc = (struct da_softc *)periph->softc; if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR)) { - if (da_periph_acquire(periph, DA_REF_TUR) == CAM_REQ_CMP) { + if (da_periph_acquire(periph, DA_REF_TUR) == 0) { cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR); daschedule(periph); } @@ -2732,7 +2732,7 @@ * We'll release this reference once GEOM calls us back (via * dadiskgonecb()) telling us that our provider has been freed. */ - if (da_periph_acquire(periph, DA_REF_GEOM) != CAM_REQ_CMP) { + if (da_periph_acquire(periph, DA_REF_GEOM) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -4700,7 +4700,7 @@ * we have successfully attached. */ /* increase the refcount */ - if (da_periph_acquire(periph, DA_REF_SYSCTL) == CAM_REQ_CMP) { + if (da_periph_acquire(periph, DA_REF_SYSCTL) == 0) { taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); @@ -5558,7 +5558,7 @@ dareprobe(struct cam_periph *periph) { struct da_softc *softc; - cam_status status; + int status; softc = (struct da_softc *)periph->softc; @@ -5567,8 +5567,7 @@ return; status = da_periph_acquire(periph, DA_REF_REPROBE); - KASSERT(status == CAM_REQ_CMP, - ("dareprobe: cam_periph_acquire failed")); + KASSERT(status == 0, ("dareprobe: cam_periph_acquire failed")); softc->state = DA_STATE_PROBE_WP; xpt_schedule(periph, CAM_PRIORITY_DEV); @@ -5666,7 +5665,7 @@ if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) && LIST_EMPTY(&softc->pending_ccbs)) { - if (da_periph_acquire(periph, DA_REF_TUR) == CAM_REQ_CMP) { + if (da_periph_acquire(periph, DA_REF_TUR) == 0) { cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR); daschedule(periph); } Index: head/sys/cam/scsi/scsi_enc.c =================================================================== --- head/sys/cam/scsi/scsi_enc.c +++ head/sys/cam/scsi/scsi_enc.c @@ -267,7 +267,7 @@ int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return (ENXIO); cam_periph_lock(periph); @@ -859,7 +859,7 @@ callout_init_mtx(&enc->status_updater, cam_periph_mtx(enc->periph), 0); - if (cam_periph_acquire(enc->periph) != CAM_REQ_CMP) + if (cam_periph_acquire(enc->periph) != 0) return (ENXIO); result = kproc_create(enc_daemon, enc, &enc->enc_daemon, /*flags*/0, @@ -975,7 +975,7 @@ * instance for it. We'll release this reference once the devfs * instance has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); Index: head/sys/cam/scsi/scsi_pass.c =================================================================== --- head/sys/cam/scsi/scsi_pass.c +++ head/sys/cam/scsi/scsi_pass.c @@ -518,7 +518,6 @@ buftype = (uintptr_t)arg; if (buftype == CDAI_TYPE_PHYS_PATH) { struct pass_softc *softc; - cam_status status; softc = (struct pass_softc *)periph->softc; /* @@ -527,8 +526,7 @@ * a situation where the periph goes away before * the task queue has a chance to run. */ - status = cam_periph_acquire(periph); - if (status != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) break; taskqueue_enqueue(taskqueue_thread, @@ -626,7 +624,7 @@ * Acquire a reference to the periph that we can release once we've * cleaned up the kqueue. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -638,7 +636,7 @@ * instance for it. We'll release this reference once the devfs * instance has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -665,7 +663,7 @@ * Hold a reference to the periph before we create the physical * path alias so it can't go away. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -705,7 +703,7 @@ int error; periph = (struct cam_periph *)dev->si_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return (ENXIO); cam_periph_lock(periph); Index: head/sys/cam/scsi/scsi_pt.c =================================================================== --- head/sys/cam/scsi/scsi_pt.c +++ head/sys/cam/scsi/scsi_pt.c @@ -142,7 +142,7 @@ int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return (ENXIO); softc = (struct pt_softc *)periph->softc; Index: head/sys/cam/scsi/scsi_sa.c =================================================================== --- head/sys/cam/scsi/scsi_sa.c +++ head/sys/cam/scsi/scsi_sa.c @@ -657,7 +657,7 @@ int error; periph = (struct cam_periph *)dev->si_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { return (ENXIO); } @@ -2495,7 +2495,7 @@ * instances for it. We'll release this reference once the devfs * instances have been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); Index: head/sys/cam/scsi/scsi_sg.c =================================================================== --- head/sys/cam/scsi/scsi_sg.c +++ head/sys/cam/scsi/scsi_sg.c @@ -353,7 +353,7 @@ * instance for it. We'll release this reference once the devfs * instance has been freed. */ - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { + if (cam_periph_acquire(periph) != 0) { xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); @@ -439,7 +439,7 @@ int error = 0; periph = (struct cam_periph *)dev->si_drv1; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) + if (cam_periph_acquire(periph) != 0) return (ENXIO); /* Index: head/sys/cam/scsi/scsi_xpt.c =================================================================== --- head/sys/cam/scsi/scsi_xpt.c +++ head/sys/cam/scsi/scsi_xpt.c @@ -657,7 +657,6 @@ proberegister(struct cam_periph *periph, void *arg) { union ccb *request_ccb; /* CCB representing the probe request */ - cam_status status; probe_softc *softc; request_ccb = (union ccb *)arg; @@ -681,10 +680,9 @@ periph->softc = softc; softc->periph = periph; softc->action = PROBE_INVALID; - status = cam_periph_acquire(periph); - if (status != CAM_REQ_CMP) { - return (status); - } + if (cam_periph_acquire(periph) != 0) + return (CAM_REQ_CMP_ERR); + CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n")); scsi_devise_transport(periph->path);