summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2019-09-10 22:39:14 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2019-09-10 22:39:14 +0000
commit0a7191e5c24cc0de593758a7795db6acf26cfd25 (patch)
tree6cac75f6cbd99d7646334471617846dd54505746 /sys
parentd2363b9f3a5b62d5f3a1413e5438a0693b0d73ec (diff)
No need to check for ST_MOUNTED before calling st_mount_tape() AND in
st_mount_tape(). Just keep the latter. st_mount_tape() is called from inside stopen() which has already found the relevant st_softc(), incremented the device reference count, and checked if it is dying. No need to repeast that in st_mount_tape(). Just pass the st_softc.
Diffstat (limited to 'sys')
-rw-r--r--sys/scsi/st.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index 8253264415c..68617d861a1 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.163 2019/09/10 19:04:36 krw Exp $ */
+/* $OpenBSD: st.c,v 1.164 2019/09/10 22:39:13 krw Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -207,7 +207,7 @@ int stdetach(struct device *, int);
void stminphys(struct buf *);
void ststart(struct scsi_xfer *);
-int st_mount_tape(dev_t, int);
+int st_mount_tape(struct st_softc *, int);
void st_unmount(struct st_softc *, int, int);
int st_decide_mode(struct st_softc *, int);
void st_buf_done(struct scsi_xfer *);
@@ -407,12 +407,10 @@ stopen(dev_t dev, int flags, int fmt, struct proc *p)
goto done;
}
- if (!ISSET(st->flags, ST_MOUNTED)) {
- error = st_mount_tape(dev, flags);
- if (error != 0) {
- CLR(link->flags, SDEV_OPEN);
- goto done;
- }
+ error = st_mount_tape(st, flags);
+ if (error != 0) {
+ CLR(link->flags, SDEV_OPEN);
+ goto done;
}
/*
@@ -478,34 +476,22 @@ done:
}
/*
- * Start a new mount session.
- * Copy in all the default parameters from the selected device mode.
- * and try guess any that seem to be defaulted.
+ * Start a new mount session if needed.
*/
int
-st_mount_tape(dev_t dev, int flags)
+st_mount_tape(struct st_softc *st, int flags)
{
- struct st_softc *st;
- struct scsi_link *link;
+ struct scsi_link *link = st->sc_link;
int error = 0;
- st = stlookup(STUNIT(dev));
- if (st == NULL)
- return ENXIO;
- if (ISSET(st->flags, ST_DYING)) {
- error = ENXIO;
- goto done;
- }
- link = st->sc_link;
+ if (ISSET(st->flags, ST_MOUNTED))
+ return 0;
SC_DEBUG(link, SDEV_DB1, ("mounting\n"));
- if (ISSET(st->flags, ST_MOUNTED))
- goto done;
-
/*
- * If the media is new, then make sure we give it a chance to
- * to do a 'load' instruction. (We assume it is new.)
+ * Assume the media is new and give it a chance to
+ * to do a 'load' instruction.
*/
if ((error = st_load(st, LD_LOAD, 0)) != 0)
goto done;
@@ -579,7 +565,6 @@ st_mount_tape(dev_t dev, int flags)
st->media_eom = -1;
done:
- device_unref(&st->sc_dev);
return error;
}