diff options
author | Warner Losh <imp@FreeBSD.org> | 2021-06-28 22:01:30 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2021-06-28 22:13:03 +0000 |
commit | 30f8afd0270e0bb70e1e0df1cf8de7a841797a30 (patch) | |
tree | 9c4bbe98fc3a47eff83b3c176b7f152854a6e554 /sys/dev | |
parent | dcd5dea96509f6e483861350c9ef1d6a85b44ff6 (diff) | |
download | src-30f8afd0270e0bb70e1e0df1cf8de7a841797a30.tar.gz src-30f8afd0270e0bb70e1e0df1cf8de7a841797a30.zip |
cam: fix xpt_bus_register and xpt_bus_deregister return errno
xpt_bus_register and xpt_bus_deregister returns a hybrid error that's
neither a cam_status, nor an errno, but a mix of both. Update
xpt_bus_register and xpt_bus_deregister to return an errno. The vast
majority of current users compare against zero, which can also be
spelled CAM_SUCCESS. Nobody uses CAM_FAILURE, so remove that symbol
to prevent comfusion (nothing returns it either).
Where the return value is saved, ensure that the variable 'error' is
used to store an errno and 'status' is used to store a cam_status where
it makes the code clearer (usually just in functions that already mix
and match). Where the return value isn't used at all, avoid storing it
at all.
Reviewed by: scottl@, mav@ (earlier version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30860
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/iscsi/iscsi.c | 3 | ||||
-rw-r--r-- | sys/dev/smartpqi/smartpqi_cam.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/storage/umass.c | 10 | ||||
-rw-r--r-- | sys/dev/vmware/pvscsi/pvscsi.c | 8 |
4 files changed, 14 insertions, 15 deletions
diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 7ddb5a9ce1ec..9a1b539e539b 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -1506,8 +1506,7 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc, return (ENOMEM); } - error = xpt_bus_register(is->is_sim, NULL, 0); - if (error != 0) { + if (xpt_bus_register(is->is_sim, NULL, 0) != 0) { ISCSI_SESSION_UNLOCK(is); ISCSI_SESSION_WARN(is, "failed to register bus"); iscsi_session_terminate(is); diff --git a/sys/dev/smartpqi/smartpqi_cam.c b/sys/dev/smartpqi/smartpqi_cam.c index e389eb143e4a..1278434131d9 100644 --- a/sys/dev/smartpqi/smartpqi_cam.c +++ b/sys/dev/smartpqi/smartpqi_cam.c @@ -1204,7 +1204,7 @@ register_sim(struct pqisrc_softstate *softs, int card_index) { int max_transactions; union ccb *ccb = NULL; - cam_status status = 0; + int error; struct ccb_setasync csa; struct cam_sim *sim; @@ -1231,9 +1231,9 @@ register_sim(struct pqisrc_softstate *softs, int card_index) softs->os_specific.sim = sim; mtx_lock(&softs->os_specific.cam_lock); - status = xpt_bus_register(sim, softs->os_specific.pqi_dev, 0); - if (status != CAM_SUCCESS) { - DBG_ERR("xpt_bus_register failed status=%d\n", status); + error = xpt_bus_register(sim, softs->os_specific.pqi_dev, 0); + if (error != CAM_SUCCESS) { + DBG_ERR("xpt_bus_register failed errno %d\n", error); cam_sim_free(softs->os_specific.sim, FALSE); cam_simq_free(softs->os_specific.devq); mtx_unlock(&softs->os_specific.cam_lock); diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index bc07fe50b6ab..65c72b06e244 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -2129,11 +2129,11 @@ umass_cam_attach(struct umass_softc *sc) static void umass_cam_detach_sim(struct umass_softc *sc) { - cam_status status; + int error; if (sc->sc_sim != NULL) { - status = xpt_bus_deregister(cam_sim_path(sc->sc_sim)); - if (status == CAM_REQ_CMP) { + error = xpt_bus_deregister(cam_sim_path(sc->sc_sim)); + if (error == 0) { /* accessing the softc is not possible after this */ sc->sc_sim->softc = NULL; DPRINTF(sc, UDMASS_SCSI, "%s: %s:%d:%d caling " @@ -2143,8 +2143,8 @@ umass_cam_detach_sim(struct umass_softc *sc) sc->sc_sim->refcount, sc->sc_sim->mtx); cam_sim_free(sc->sc_sim, /* free_devq */ TRUE); } else { - panic("%s: %s: CAM layer is busy: %#x\n", - __func__, sc->sc_name, status); + panic("%s: %s: CAM layer is busy: errno %d\n", + __func__, sc->sc_name, error); } sc->sc_sim = NULL; } diff --git a/sys/dev/vmware/pvscsi/pvscsi.c b/sys/dev/vmware/pvscsi/pvscsi.c index ad32d2ab4959..f64b20863f60 100644 --- a/sys/dev/vmware/pvscsi/pvscsi.c +++ b/sys/dev/vmware/pvscsi/pvscsi.c @@ -1548,16 +1548,16 @@ pvscsi_free_all(struct pvscsi_softc *sc) { if (sc->sim) { - int32_t status; + int error; if (sc->bus_path) { xpt_free_path(sc->bus_path); } - status = xpt_bus_deregister(cam_sim_path(sc->sim)); - if (status != CAM_REQ_CMP) { + error = xpt_bus_deregister(cam_sim_path(sc->sim)); + if (error != 0) { device_printf(sc->dev, - "Error deregistering bus, status=%d\n", status); + "Error deregistering bus, error %d\n", error); } cam_sim_free(sc->sim, TRUE); |