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 uk(4) to device_t. While here, clean...
details: https://anonhg.NetBSD.org/src/rev/5352b65d6e6d
branches: trunk
changeset: 773595:5352b65d6e6d
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Wed Feb 08 12:22:00 2012 +0000
description:
Convert uk(4) to device_t. While here, clean up the code a bit.
releng ok (ack 3, nak 0, wait no more)
diffstat:
sys/dev/scsipi/uk.c | 67 ++++++++++++++++++++++------------------------------
1 files changed, 29 insertions(+), 38 deletions(-)
diffs (171 lines):
diff -r d64f426a4828 -r 5352b65d6e6d sys/dev/scsipi/uk.c
--- a/sys/dev/scsipi/uk.c Wed Feb 08 12:10:17 2012 +0000
+++ b/sys/dev/scsipi/uk.c Wed Feb 08 12:22:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uk.c,v 1.59 2009/12/06 22:48:17 dyoung Exp $ */
+/* $NetBSD: uk.c,v 1.60 2012/02/08 12:22:00 mbalmer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uk.c,v 1.59 2009/12/06 22:48:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uk.c,v 1.60 2012/02/08 12:22:00 mbalmer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,10 +50,8 @@
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
-#define UKUNIT(z) (minor(z))
-
struct uk_softc {
- struct device sc_dev;
+ device_t sc_dev;
struct scsipi_periph *sc_periph; /* all the inter level info */
};
@@ -62,8 +60,14 @@
static void ukattach(device_t, device_t, void *);
static int ukdetach(device_t, int);
-
-CFATTACH_DECL(uk, sizeof(struct uk_softc), ukmatch, ukattach, ukdetach, NULL);
+CFATTACH_DECL_NEW(
+ uk,
+ sizeof(struct uk_softc),
+ ukmatch,
+ ukattach,
+ ukdetach,
+ NULL
+);
extern struct cfdriver uk_cd;
@@ -77,11 +81,9 @@
};
static int
-ukmatch(device_t parent, cfdata_t match,
- void *aux)
+ukmatch(device_t parent, cfdata_t match, void *aux)
{
-
- return (1);
+ return 1;
}
/*
@@ -96,12 +98,11 @@
struct scsipi_periph *periph = sa->sa_periph;
SC_DEBUG(periph, SCSIPI_DB2, ("ukattach: "));
+ uk->sc_dev = self;
- /*
- * Store information needed to contact our base driver
- */
+ /* Store information needed to contact our base driver */
uk->sc_periph = periph;
- periph->periph_dev = &uk->sc_dev;
+ periph->periph_dev = uk->sc_dev;
printf("\n");
}
@@ -109,7 +110,6 @@
static int
ukdetach(device_t self, int flags)
{
- /*struct uk_softc *uk = device_private(self);*/
int cmaj, mn;
/* locate the major number */
@@ -119,12 +119,9 @@
mn = device_unit(self);
vdevgone(cmaj, mn, mn, VCHR);
- return (0);
+ return 0;
}
-/*
- * open the device.
- */
static int
ukopen(dev_t dev, int flag, int fmt, struct lwp *l)
{
@@ -133,10 +130,10 @@
struct scsipi_periph *periph;
struct scsipi_adapter *adapt;
- unit = UKUNIT(dev);
+ unit = minor(dev);
uk = device_lookup_private(&uk_cd, unit);
if (uk == NULL)
- return (ENXIO);
+ return ENXIO;
periph = uk->sc_periph;
adapt = periph->periph_channel->chan_adapter;
@@ -145,30 +142,24 @@
("ukopen: dev=0x%"PRIx64" (unit %d (of %d))\n", dev, unit,
uk_cd.cd_ndevs));
- /*
- * Only allow one at a time
- */
+ /* Only allow one at a time */
if (periph->periph_flags & PERIPH_OPEN) {
- aprint_error_dev(&uk->sc_dev, "already open\n");
- return (EBUSY);
+ aprint_error_dev(uk->sc_dev, "already open\n");
+ return EBUSY;
}
if ((error = scsipi_adapter_addref(adapt)) != 0)
- return (error);
+ return error;
periph->periph_flags |= PERIPH_OPEN;
SC_DEBUG(periph, SCSIPI_DB3, ("open complete\n"));
- return (0);
+ return 0;
}
-/*
- * close the device.. only called if we are the LAST
- * occurence of an open device
- */
static int
ukclose(dev_t dev, int flag, int fmt, struct lwp *l)
{
- struct uk_softc *uk = device_lookup_private(&uk_cd, UKUNIT(dev));
+ struct uk_softc *uk = device_lookup_private(&uk_cd, minor(dev));
struct scsipi_periph *periph = uk->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
@@ -179,17 +170,17 @@
scsipi_adapter_delref(adapt);
periph->periph_flags &= ~PERIPH_OPEN;
- return (0);
+ return 0;
}
/*
- * Perform special action on behalf of the user
+ * Perform special action on behalf of the user.
* Only does generic scsi ioctls.
*/
static int
ukioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- struct uk_softc *uk = device_lookup_private(&uk_cd, UKUNIT(dev));
+ struct uk_softc *uk = device_lookup_private(&uk_cd, minor(dev));
- return (scsipi_do_ioctl(uk->sc_periph, dev, cmd, addr, flag, l));
+ return scsipi_do_ioctl(uk->sc_periph, dev, cmd, addr, flag, l);
}
Home |
Main Index |
Thread Index |
Old Index