Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi Convert st(4) to device_t, while here clean u...
details: https://anonhg.NetBSD.org/src/rev/a7f2d7b3d3ab
branches: trunk
changeset: 777654:a7f2d7b3d3ab
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Tue Feb 28 10:58:10 2012 +0000
description:
Convert st(4) to device_t, while here clean up the code and use uintXX_t
instead of u_intXX_t.
diffstat:
sys/dev/scsipi/st.c | 423 ++++++++++++++++++---------------------------
sys/dev/scsipi/st_atapi.c | 25 +-
sys/dev/scsipi/st_scsi.c | 71 +++----
sys/dev/scsipi/stvar.h | 18 +-
4 files changed, 219 insertions(+), 318 deletions(-)
diffs (truncated from 1516 to 300 lines):
diff -r 79c918c070de -r a7f2d7b3d3ab sys/dev/scsipi/st.c
--- a/sys/dev/scsipi/st.c Tue Feb 28 08:58:39 2012 +0000
+++ b/sys/dev/scsipi/st.c Tue Feb 28 10:58:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: st.c,v 1.219 2012/02/25 10:15:50 shattered Exp $ */
+/* $NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.219 2012/02/25 10:15:50 shattered Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $");
#include "opt_scsi.h"
@@ -335,8 +335,8 @@
static int st_interpret_sense(struct scsipi_xfer *);
static int st_touch_tape(struct st_softc *);
static int st_erase(struct st_softc *, int full, int flags);
-static int st_rdpos(struct st_softc *, int, u_int32_t *);
-static int st_setpos(struct st_softc *, int, u_int32_t *);
+static int st_rdpos(struct st_softc *, int, uint32_t *);
+static int st_setpos(struct st_softc *, int, uint32_t *);
static const struct scsipi_periphsw st_switch = {
st_interpret_sense,
@@ -345,7 +345,7 @@
stdone
};
-#if defined(ST_ENABLE_EARLYWARN)
+#if defined(ST_ENABLE_EARLYWARN)
#define ST_INIT_FLAGS ST_EARLYWARN
#else
#define ST_INIT_FLAGS 0
@@ -356,31 +356,25 @@
* A device suitable for this driver
*/
void
-stattach(device_t parent, struct st_softc *st, void *aux)
+stattach(device_t parent, device_t self, void *aux)
{
+ struct st_softc *st = device_private(self);
struct scsipibus_attach_args *sa = aux;
struct scsipi_periph *periph = sa->sa_periph;
SC_DEBUG(periph, SCSIPI_DB2, ("stattach: "));
+ st->sc_dev = self;
- /*
- * Store information needed to contact our base driver
- */
+ /* Store information needed to contact our base driver */
st->sc_periph = periph;
- periph->periph_dev = &st->sc_dev;
+ periph->periph_dev = st->sc_dev;
periph->periph_switch = &st_switch;
- /*
- * Set initial flags
- */
-
+ /* Set initial flags */
st->flags = ST_INIT_FLAGS;
- /*
- * Set up the buf queue for this device
- */
+ /* Set up the buf queue for this device */
bufq_alloc(&st->buf_queue, "fcfs", 0);
-
callout_init(&st->sc_callout, 0);
/*
@@ -388,11 +382,10 @@
* Any steps needed to bring it into line
*/
st_identify_drive(st, &sa->sa_inqbuf);
- /*
- * Use the subdriver to request information regarding the drive.
- */
printf("\n");
- printf("%s: %s", device_xname(&st->sc_dev), st->quirkdata ? "quirks apply, " : "");
+ /* Use the subdriver to request information regarding the drive. */
+ printf("%s : %s", device_xname(st->sc_dev), st->quirkdata
+ ? "quirks apply, " : "");
if (scsipi_test_unit_ready(periph,
XS_CTL_DISCOVERY | XS_CTL_SILENT | XS_CTL_IGNORE_MEDIA_CHANGE) ||
st->ops(st, ST_OPS_MODESENSE,
@@ -408,10 +401,11 @@
(st->flags & ST_READONLY) ? "protected" : "enabled");
}
- st->stats = iostat_alloc(IOSTAT_TAPE, parent, device_xname(&st->sc_dev));
+ st->stats = iostat_alloc(IOSTAT_TAPE, parent,
+ device_xname(st->sc_dev));
- rnd_attach_source(&st->rnd_source, device_xname(&st->sc_dev),
- RND_TYPE_TAPE, 0);
+ rnd_attach_source(&st->rnd_source, device_xname(st->sc_dev),
+ RND_TYPE_TAPE, 0);
}
int
@@ -449,7 +443,7 @@
/* Unhook the entropy source. */
rnd_detach_source(&st->rnd_source);
- return (0);
+ return 0;
}
/*
@@ -484,9 +478,9 @@
static void
st_loadquirks(struct st_softc *st)
{
- int i;
const struct modes *mode;
struct modes *mode2;
+ int i;
mode = st->quirkdata->modes;
mode2 = st->modes;
@@ -509,9 +503,7 @@
}
}
-/*
- * open the device.
- */
+/* open the device. */
static int
stopen(dev_t dev, int flags, int mode, struct lwp *l)
{
@@ -524,7 +516,7 @@
unit = STUNIT(dev);
st = device_lookup_private(&st_cd, unit);
if (st == NULL)
- return (ENXIO);
+ return ENXIO;
stmode = STMODE(dev);
dsty = STDSTY(dev);
@@ -532,24 +524,20 @@
periph = st->sc_periph;
adapt = periph->periph_channel->chan_adapter;
- SC_DEBUG(periph, SCSIPI_DB1, ("open: dev=0x%"PRIx64" (unit %d (of %d))\n", dev,
- unit, st_cd.cd_ndevs));
-
+ SC_DEBUG(periph, SCSIPI_DB1,
+ ("open: dev=0x%"PRIx64" (unit %d (of %d))\n", dev, unit,
+ st_cd.cd_ndevs));
- /*
- * Only allow one at a time
- */
+ /* Only allow one at a time */
if (periph->periph_flags & PERIPH_OPEN) {
- aprint_error_dev(&st->sc_dev, "already open\n");
- return (EBUSY);
+ aprint_error_dev(st->sc_dev, "already open\n");
+ return EBUSY;
}
if ((error = scsipi_adapter_addref(adapt)) != 0)
- return (error);
+ return error;
- /*
- * clear any latched errors.
- */
+ /* clear any latched errors. */
st->mt_resid = 0;
st->mt_erreg = 0;
st->asc = 0;
@@ -575,12 +563,10 @@
* try up to ST_MOUNT_DELAY times with a rest interval of
* one second between each try.
*/
-
- if ((st->flags & ST_MOUNTED) || ST_MOUNT_DELAY == 0) {
+ if ((st->flags & ST_MOUNTED) || ST_MOUNT_DELAY == 0)
ntries = 1;
- } else {
+ else
ntries = ST_MOUNT_DELAY;
- }
for (error = tries = 0; tries < ntries; tries++) {
int slpintr, oflags;
@@ -589,11 +575,9 @@
* If we had no error, or we're opening the control mode
* device, we jump out right away.
*/
-
error = scsipi_test_unit_ready(periph, sflags);
- if (error == 0 || stmode == CTRL_MODE) {
+ if (error == 0 || stmode == CTRL_MODE)
break;
- }
/*
* We had an error.
@@ -607,9 +591,7 @@
goto bad;
}
- /*
- * clear any latched errors.
- */
+ /* clear any latched errors. */
st->mt_resid = 0;
st->mt_erreg = 0;
st->asc = 0;
@@ -619,7 +601,6 @@
* Fake that we have the device open so
* we block other apps from getting in.
*/
-
oflags = periph->periph_flags;
periph->periph_flags |= PERIPH_OPEN;
@@ -642,7 +623,7 @@
*/
if (stmode == CTRL_MODE && st->mt_key == SKEY_NOT_READY) {
periph->periph_flags |= PERIPH_OPEN;
- return (0);
+ return 0;
}
/*
@@ -650,14 +631,10 @@
* to pass the 'test unit ready' test for the non-controlmode device,
* so we bounce the open.
*/
-
if (error)
- return (error);
+ return error;
- /*
- * Else, we're now committed to saying we're open.
- */
-
+ /* Else, we're now committed to saying we're open. */
periph->periph_flags |= PERIPH_OPEN; /* unit attn are now errors */
/*
@@ -684,19 +661,15 @@
}
SC_DEBUG(periph, SCSIPI_DB2, ("open complete\n"));
- return (0);
+ return 0;
bad:
st_unmount(st, NOEJECT);
scsipi_adapter_delref(adapt);
periph->periph_flags &= ~PERIPH_OPEN;
- return (error);
+ return error;
}
-/*
- * close the device.. only called if we are the LAST
- * occurence of an open device
- */
static int
stclose(dev_t dev, int flags, int mode, struct lwp *l)
{
@@ -729,9 +702,7 @@
error = st_check_eod(st, FALSE, &nm, 0);
}
- /*
- * Allow robots to eject tape if needed.
- */
+ /* Allow robots to eject tape if needed. */
scsipi_prevent(periph, SPAMR_ALLOW,
XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_NOT_READY);
@@ -784,7 +755,7 @@
scsipi_adapter_delref(adapt);
periph->periph_flags &= ~PERIPH_OPEN;
- return (error);
+ return error;
}
/*
@@ -807,7 +778,7 @@
periph = st->sc_periph;
if (st->flags & ST_MOUNTED)
- return (0);
Home |
Main Index |
Thread Index |
Old Index