diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-10-23 13:50:51 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-10-23 13:50:51 +0000 |
commit | db1718ae77c3ceb72c00adf6b750068797715425 (patch) | |
tree | 68aacf8f826b6cb8f535827db205106149ea13fb /sys | |
parent | 4d6c2a96e91eadebb5073d8a4a76e6d5c3fcd5d9 (diff) |
There used to be three possible return values from sd_get_parms(), but
for some years it's been a succeed/fail function. So switch to using
0/-1 as return values and nuke SDGP_RESULT_OFFLINE and SDGP_RESULT_OK
#defines. Shake out logic inside sd_get_parms() to take account of the
change, making it clearer. Removes a possible panic().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/sd.c | 49 | ||||
-rw-r--r-- | sys/scsi/sdvar.h | 6 |
2 files changed, 18 insertions, 37 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 8b379ccc982..fa969d60afd 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.291 2019/10/22 15:46:40 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.292 2019/10/23 13:50:49 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -162,7 +162,7 @@ sdattach(struct device *parent, struct device *self, void *aux) int sd_autoconf = scsi_autoconf | SCSI_SILENT | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE; struct dk_cache dkc; - int error, result, sortby = BUFQ_DEFAULT; + int error, sortby = BUFQ_DEFAULT; SC_DEBUG(link, SDEV_DB2, ("sdattach:\n")); @@ -211,17 +211,13 @@ sdattach(struct device *parent, struct device *self, void *aux) /* Check that it is still responding and ok. */ error = scsi_test_unit_ready(sc->sc_link, TEST_READY_RETRIES * 3, sd_autoconf); - - if (error) - result = SDGP_RESULT_OFFLINE; - else - result = sd_get_parms(sc, sd_autoconf); + if (error == 0) + error = sd_get_parms(sc, sd_autoconf); if (ISSET(link->flags, SDEV_REMOVABLE)) scsi_prevent(link, PR_ALLOW, sd_autoconf); - switch (result) { - case SDGP_RESULT_OK: + if (error == 0) { printf("%s: %lluMB, %lu bytes/sector, %llu sectors", sc->sc_dev.dv_xname, dp->disksize / (1048576 / dp->secsize), dp->secsize, @@ -230,20 +226,9 @@ sdattach(struct device *parent, struct device *self, void *aux) sortby = BUFQ_FIFO; printf(", thin"); } - if (ISSET(link->flags, SDEV_READONLY)) { + if (ISSET(link->flags, SDEV_READONLY)) printf(", readonly"); - } printf("\n"); - break; - - case SDGP_RESULT_OFFLINE: - break; - -#ifdef DIAGNOSTIC - default: - panic("sdattach: unknown result (%#x) from sd_get_parms", result); - break; -#endif /* DIAGNOSTIC */ } /* @@ -436,8 +421,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) goto die; } SET(link->flags, SDEV_MEDIA_LOADED); - if (sd_get_parms(sc, (rawopen ? SCSI_SILENT : 0)) - == SDGP_RESULT_OFFLINE) { + if (sd_get_parms(sc, (rawopen ? SCSI_SILENT : 0)) == -1) { if (ISSET(sc->flags, SDF_DYING)) { error = ENXIO; goto die; @@ -1714,10 +1698,11 @@ sd_thin_params(struct sd_softc *sc, int flags) } /* - * Fill out the disk parameter structure. Return SDGP_RESULT_OK if the - * structure is correctly filled in, SDGP_RESULT_OFFLINE otherwise. The caller - * is responsible for clearing the SDEV_MEDIA_LOADED flag if the structure - * cannot be completed. + * Fill out the disk parameter structure. Return 0 if the structure is correctly + * filled in, otherwise return -1. + * + * The caller is responsible for clearing the SDEV_MEDIA_LOADED flag if the + * structure cannot be completed. */ int sd_get_parms(struct sd_softc *sc, int flags) @@ -1733,7 +1718,7 @@ sd_get_parms(struct sd_softc *sc, int flags) int err = 0, big; if (sd_size(sc, flags) != 0) - return (SDGP_RESULT_OFFLINE); + return -1; if (ISSET(sc->flags, SDF_THIN) && sd_thin_params(sc, flags) != 0) { /* we dont know the unmap limits, so we cant use thin shizz */ @@ -1836,7 +1821,7 @@ validate: dma_free(buf, sizeof(*buf)); if (dp->disksize == 0) - return (SDGP_RESULT_OFFLINE); + return -1; if (dp->secsize == 0) dp->secsize = (secsize == 0) ? 512 : secsize; @@ -1857,7 +1842,7 @@ validate: default: SC_DEBUG(sc->sc_link, SDEV_DB1, ("sd_get_parms: bad secsize: %#lx\n", dp->secsize)); - return (SDGP_RESULT_OFFLINE); + return -1; } /* @@ -1887,11 +1872,11 @@ validate: dp->sectors = dp->disksize; } - return (SDGP_RESULT_OK); + return 0; die: dma_free(buf, sizeof(*buf)); - return (SDGP_RESULT_OFFLINE); + return -1; } int diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h index 333239d5774..6cd99951394 100644 --- a/sys/scsi/sdvar.h +++ b/sys/scsi/sdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdvar.h,v 1.43 2019/09/27 23:07:42 krw Exp $ */ +/* $OpenBSD: sdvar.h,v 1.44 2019/10/23 13:50:50 krw Exp $ */ /* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */ /*- @@ -77,9 +77,5 @@ struct sd_softc { struct scsi_xshandler sc_xsh; }; - -#define SDGP_RESULT_OK 0 /* parameters obtained */ -#define SDGP_RESULT_OFFLINE 1 /* no media, or otherwise losing */ - #endif /* _KERNEL */ #endif /* _SCSI_SDVAR_H */ |