summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>2008-06-08 18:18:33 +0000
committertsutsui <tsutsui@NetBSD.org>2008-06-08 18:18:33 +0000
commit887a89aa5cc60665e9fbadd97160f17f1f40425d (patch)
tree777bd81a7545bbf4de158138933caef0ecb4dc84 /sys/dev
parentc9a8620b99e07b2fd1817090c76f836642bee7ec (diff)
Use device_lookup_private() rather than using cd_devs[] directly to get softc.
XXX maybe we should change a type of cd_devs[] in struct cfdriver from (void *) to device_t.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/audio.c6
-rw-r--r--sys/dev/pci/bktr/bktr_os.c17
-rw-r--r--sys/dev/pci/if_tlp_pci.c6
-rw-r--r--sys/dev/radio.c15
-rw-r--r--sys/dev/scsipi/ch.c18
-rw-r--r--sys/dev/scsipi/if_se.c12
-rw-r--r--sys/dev/scsipi/scsiconf.c18
-rw-r--r--sys/dev/scsipi/sd.c23
-rw-r--r--sys/dev/scsipi/ses.c14
-rw-r--r--sys/dev/scsipi/ss.c20
-rw-r--r--sys/dev/scsipi/st.c20
-rw-r--r--sys/dev/scsipi/uk.c12
12 files changed, 84 insertions, 97 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index b08d464767a..971628f034a 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.241 2008/06/03 06:21:17 bjs Exp $ */
+/* $NetBSD: audio.c,v 1.242 2008/06/08 18:18:33 tsutsui Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.241 2008/06/03 06:21:17 bjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.242 2008/06/08 18:18:33 tsutsui Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -1197,7 +1197,7 @@ audiokqfilter(dev_t dev, struct knote *kn)
struct audio_softc *sc;
int rv;
- sc = audio_cd.cd_devs[AUDIOUNIT(dev)];
+ sc = device_lookup_private(&audio_cd, AUDIOUNIT(dev));
if (sc->sc_dying)
return 1;
diff --git a/sys/dev/pci/bktr/bktr_os.c b/sys/dev/pci/bktr/bktr_os.c
index 408a3508187..2419346524d 100644
--- a/sys/dev/pci/bktr/bktr_os.c
+++ b/sys/dev/pci/bktr/bktr_os.c
@@ -1,6 +1,6 @@
/* $SourceForge: bktr_os.c,v 1.5 2003/03/11 23:11:25 thomasklausner Exp $ */
-/* $NetBSD: bktr_os.c,v 1.51 2008/04/10 19:13:38 cegger Exp $ */
+/* $NetBSD: bktr_os.c,v 1.52 2008/06/08 18:18:34 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/bktr/bktr_os.c,v 1.20 2000/10/20 08:16:53 roger Exp$ */
/*
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bktr_os.c,v 1.51 2008/04/10 19:13:38 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bktr_os.c,v 1.52 2008/06/08 18:18:34 tsutsui Exp $");
#ifdef __FreeBSD__
#include "bktr.h"
@@ -1660,11 +1660,10 @@ bktr_open(dev_t dev, int flags, int fmt,
unit = UNIT(dev);
/* unit out of range */
- if ((unit >= bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
+ bktr = device_lookup_private(&bktr_cd, unit);
+ if (bktr == NULL)
return(ENXIO);
- bktr = bktr_cd.cd_devs[unit];
-
if (!(bktr->flags & METEOR_INITIALIZED)) /* device not found */
return(ENXIO);
@@ -1693,7 +1692,7 @@ bktr_close(dev_t dev, int flags, int fmt,
unit = UNIT(dev);
- bktr = bktr_cd.cd_devs[unit];
+ bktr = device_lookup_private(&bktr_cd, unit);
switch (FUNCTION(dev)) {
case VIDEO_DEV:
@@ -1718,7 +1717,7 @@ bktr_read(dev_t dev, struct uio *uio, int ioflag)
unit = UNIT(dev);
- bktr = bktr_cd.cd_devs[unit];
+ bktr = device_lookup_private(&bktr_cd, unit);
switch (FUNCTION(dev)) {
case VIDEO_DEV:
@@ -1753,7 +1752,7 @@ bktr_ioctl(dev_t dev, ioctl_cmd_t cmd, void *arg, int flag,
unit = UNIT(dev);
- bktr = bktr_cd.cd_devs[unit];
+ bktr = device_lookup_private(&bktr_cd, unit);
if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */
return(ENOMEM);
@@ -1782,7 +1781,7 @@ bktr_mmap(dev_t dev, off_t offset, int nprot)
if (FUNCTION(dev) > 0) /* only allow mmap on /dev/bktr[n] */
return(-1);
- bktr = bktr_cd.cd_devs[unit];
+ bktr = device_lookup_private(&bktr_cd, unit);
if ((vaddr_t)offset >= bktr->alloc_pages * PAGE_SIZE)
return(-1);
diff --git a/sys/dev/pci/if_tlp_pci.c b/sys/dev/pci/if_tlp_pci.c
index ae73341ba44..e5248174392 100644
--- a/sys/dev/pci/if_tlp_pci.c
+++ b/sys/dev/pci/if_tlp_pci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tlp_pci.c,v 1.105 2008/04/28 20:23:55 martin Exp $ */
+/* $NetBSD: if_tlp_pci.c,v 1.106 2008/06/08 18:18:34 tsutsui Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.105 2008/04/28 20:23:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.106 2008/06/08 18:18:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -308,7 +308,7 @@ tlp_pci_check_slaved(struct tulip_pci_softc *psc, int shared, int slaved)
* bus marked as shared. That should be our master.
*/
for (i = 0; i < tlp_cd.cd_ndevs; i++) {
- if ((cur = tlp_cd.cd_devs[i]) == NULL)
+ if ((cur = device_lookup_private(&tlp_cd, i)) == NULL)
continue;
if (device_parent(&cur->sc_tulip.sc_dev) !=
device_parent(&sc->sc_dev))
diff --git a/sys/dev/radio.c b/sys/dev/radio.c
index 9c3fcb1b019..1e0cf8f4047 100644
--- a/sys/dev/radio.c
+++ b/sys/dev/radio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: radio.c,v 1.20 2007/03/04 06:01:43 christos Exp $ */
+/* $NetBSD: radio.c,v 1.21 2008/06/08 18:18:33 tsutsui Exp $ */
/* $OpenBSD: radio.c,v 1.2 2001/12/05 10:27:06 mickey Exp $ */
/* $RuOBSD: radio.c,v 1.7 2001/12/04 06:03:05 tm Exp $ */
@@ -30,7 +30,7 @@
/* This is the /dev/radio driver from OpenBSD */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radio.c,v 1.20 2007/03/04 06:01:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radio.c,v 1.21 2008/06/08 18:18:33 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -93,9 +93,8 @@ radioopen(dev_t dev, int flags, int fmt, struct lwp *l)
struct radio_softc *sc;
unit = RADIOUNIT(dev);
- if (unit >= radio_cd.cd_ndevs ||
- (sc = radio_cd.cd_devs[unit]) == NULL ||
- sc->hw_if == NULL)
+ sc = device_lookup_private(&radio_cd, unit);
+ if (sc == NULL || sc->hw_if == NULL)
return (ENXIO);
if (sc->hw_if->open != NULL)
@@ -109,7 +108,7 @@ radioclose(dev_t dev, int flags, int fmt, struct lwp *l)
{
struct radio_softc *sc;
- sc = radio_cd.cd_devs[RADIOUNIT(dev)];
+ sc = device_lookup_private(&radio_cd, RADIOUNIT(dev));
if (sc->hw_if->close != NULL)
return (sc->hw_if->close(sc->hw_hdl, flags, fmt, l->l_proc));
@@ -125,8 +124,8 @@ radioioctl(dev_t dev, u_long cmd, void *data, int flags,
int unit, error;
unit = RADIOUNIT(dev);
- if (unit >= radio_cd.cd_ndevs ||
- (sc = radio_cd.cd_devs[unit]) == NULL || sc->hw_if == NULL)
+ sc = device_lookup_private(&radio_cd, unit);
+ if (sc == NULL || sc->hw_if == NULL)
return (ENXIO);
error = EOPNOTSUPP;
diff --git a/sys/dev/scsipi/ch.c b/sys/dev/scsipi/ch.c
index ad95c7e2a56..4eb079757ff 100644
--- a/sys/dev/scsipi/ch.c
+++ b/sys/dev/scsipi/ch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ch.c,v 1.81 2008/04/28 20:23:57 martin Exp $ */
+/* $NetBSD: ch.c,v 1.82 2008/06/08 18:18:34 tsutsui Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ch.c,v 1.81 2008/04/28 20:23:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ch.c,v 1.82 2008/06/08 18:18:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -257,8 +257,8 @@ chopen(dev_t dev, int flags, int fmt, struct lwp *l)
int unit, error;
unit = CHUNIT(dev);
- if ((unit >= ch_cd.cd_ndevs) ||
- ((sc = ch_cd.cd_devs[unit]) == NULL))
+ sc = device_lookup_private(&ch_cd, unit);
+ if (sc == NULL)
return (ENXIO);
periph = sc->sc_periph;
@@ -304,7 +304,7 @@ chopen(dev_t dev, int flags, int fmt, struct lwp *l)
static int
chclose(dev_t dev, int flags, int fmt, struct lwp *l)
{
- struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev));
struct scsipi_periph *periph = sc->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
@@ -321,7 +321,7 @@ chclose(dev_t dev, int flags, int fmt, struct lwp *l)
static int
chread(dev_t dev, struct uio *uio, int flags)
{
- struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev));
int error;
if (uio->uio_resid != CHANGER_EVENT_SIZE)
@@ -340,7 +340,7 @@ chread(dev_t dev, struct uio *uio, int flags)
static int
chioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
{
- struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev));
int error = 0;
/*
@@ -440,7 +440,7 @@ chioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
static int
chpoll(dev_t dev, int events, struct lwp *l)
{
- struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev));
int revents;
revents = events & (POLLOUT | POLLWRNORM);
@@ -484,7 +484,7 @@ static const struct filterops chwrite_filtops =
static int
chkqfilter(dev_t dev, struct knote *kn)
{
- struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev));
struct klist *klist;
switch (kn->kn_filter) {
diff --git a/sys/dev/scsipi/if_se.c b/sys/dev/scsipi/if_se.c
index 283be539b40..06edb68036c 100644
--- a/sys/dev/scsipi/if_se.c
+++ b/sys/dev/scsipi/if_se.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_se.c,v 1.71 2008/04/05 15:47:00 cegger Exp $ */
+/* $NetBSD: if_se.c,v 1.72 2008/06/08 18:18:34 tsutsui Exp $ */
/*
* Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au>
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.71 2008/04/05 15:47:00 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.72 2008/06/08 18:18:34 tsutsui Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@@ -1137,9 +1137,7 @@ seopen(dev, flag, fmt, l)
struct scsipi_adapter *adapt;
unit = SEUNIT(dev);
- if (unit >= se_cd.cd_ndevs)
- return (ENXIO);
- sc = se_cd.cd_devs[unit];
+ sc = device_lookup_private(&se_cd, unit);
if (sc == NULL)
return (ENXIO);
@@ -1169,7 +1167,7 @@ seclose(dev, flag, fmt, l)
int flag, fmt;
struct lwp *l;
{
- struct se_softc *sc = se_cd.cd_devs[SEUNIT(dev)];
+ struct se_softc *sc = device_lookup_private(&se_cd, SEUNIT(dev));
struct scsipi_periph *periph = sc->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
@@ -1195,7 +1193,7 @@ seioctl(dev, cmd, addr, flag, l)
int flag;
struct lwp *l;
{
- struct se_softc *sc = se_cd.cd_devs[SEUNIT(dev)];
+ struct se_softc *sc = device_lookup_private(&se_cd, SEUNIT(dev));
return (scsipi_do_ioctl(sc->sc_periph, dev, cmd, addr, flag, l));
}
diff --git a/sys/dev/scsipi/scsiconf.c b/sys/dev/scsipi/scsiconf.c
index c05bc957081..a6ff36de31c 100644
--- a/sys/dev/scsipi/scsiconf.c
+++ b/sys/dev/scsipi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.c,v 1.247 2008/04/28 20:23:57 martin Exp $ */
+/* $NetBSD: scsiconf.c,v 1.248 2008/06/08 18:18:34 tsutsui Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.247 2008/04/28 20:23:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.248 2008/06/08 18:18:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -974,8 +974,8 @@ scsibusopen(dev_t dev, int flag, int fmt,
struct scsibus_softc *sc;
int error, unit = minor(dev);
- if (unit >= scsibus_cd.cd_ndevs ||
- (sc = scsibus_cd.cd_devs[unit]) == NULL)
+ sc = device_lookup_private(&scsibus_cd, unit);
+ if (sc == NULL)
return (ENXIO);
if (sc->sc_flags & SCSIBUSF_OPEN)
@@ -993,8 +993,9 @@ static int
scsibusclose(dev_t dev, int flag, int fmt,
struct lwp *l)
{
- struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
+ struct scsibus_softc *sc;
+ sc = device_lookup_private(&scsibus_cd, minor(dev));
scsipi_adapter_delref(sc->sc_channel->chan_adapter);
sc->sc_flags &= ~SCSIBUSF_OPEN;
@@ -1005,10 +1006,13 @@ scsibusclose(dev_t dev, int flag, int fmt,
static int
scsibusioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- struct scsibus_softc *sc = scsibus_cd.cd_devs[minor(dev)];
- struct scsipi_channel *chan = sc->sc_channel;
+ struct scsibus_softc *sc;
+ struct scsipi_channel *chan;
int error;
+ sc = device_lookup_private(&scsibus_cd, minor(dev));
+ chan = sc->sc_channel;
+
/*
* Enforce write permission for ioctls that change the
* state of the bus. Host adapter specific ioctls must
diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c
index 3435ff1f335..3fdc90b9e51 100644
--- a/sys/dev/scsipi/sd.c
+++ b/sys/dev/scsipi/sd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.273 2008/04/28 20:23:58 martin Exp $ */
+/* $NetBSD: sd.c,v 1.274 2008/06/08 18:18:34 tsutsui Exp $ */
/*-
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.273 2008/04/28 20:23:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.274 2008/06/08 18:18:34 tsutsui Exp $");
#include "opt_scsi.h"
#include "rnd.h"
@@ -411,9 +411,7 @@ sdopen(dev_t dev, int flag, int fmt, struct lwp *l)
int error;
unit = SDUNIT(dev);
- if (unit >= sd_cd.cd_ndevs)
- return (ENXIO);
- sd = sd_cd.cd_devs[unit];
+ sd = device_lookup_private(&sd_cd, unit);
if (sd == NULL)
return (ENXIO);
@@ -592,7 +590,7 @@ sdopen(dev_t dev, int flag, int fmt, struct lwp *l)
static int
sdclose(dev_t dev, int flag, int fmt, struct lwp *l)
{
- struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = device_lookup_private(&sd_cd, SDUNIT(dev));
struct scsipi_periph *periph = sd->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
int part = SDPART(dev);
@@ -648,7 +646,7 @@ sdclose(dev_t dev, int flag, int fmt, struct lwp *l)
static void
sdstrategy(struct buf *bp)
{
- struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = device_lookup_private(&sd_cd, SDUNIT(bp->b_dev));
struct scsipi_periph *periph = sd->sc_periph;
struct disklabel *lp;
daddr_t blkno;
@@ -952,7 +950,7 @@ sddone(struct scsipi_xfer *xs, int error)
static void
sdminphys(struct buf *bp)
{
- struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = device_lookup_private(&sd_cd, SDUNIT(bp->b_dev));
long xmax;
/*
@@ -999,7 +997,7 @@ sdwrite(dev_t dev, struct uio *uio, int ioflag)
static int
sdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = device_lookup_private(&sd_cd, SDUNIT(dev));
struct scsipi_periph *periph = sd->sc_periph;
int part = SDPART(dev);
int error = 0;
@@ -1448,9 +1446,7 @@ sdsize(dev_t dev)
int size;
unit = SDUNIT(dev);
- if (unit >= sd_cd.cd_ndevs)
- return (-1);
- sd = sd_cd.cd_devs[unit];
+ sd = device_lookup_private(&sd_cd, unit);
if (sd == NULL)
return (-1);
@@ -1509,7 +1505,8 @@ sddump(dev_t dev, daddr_t blkno, void *va, size_t size)
part = SDPART(dev);
/* Check for acceptable drive number. */
- if (unit >= sd_cd.cd_ndevs || (sd = sd_cd.cd_devs[unit]) == NULL)
+ sd = device_lookup_private(&sd_cd, unit);
+ if (sd == NULL)
return (ENXIO);
if (!device_is_active(&sd->sc_dev))
diff --git a/sys/dev/scsipi/ses.c b/sys/dev/scsipi/ses.c
index 8a904b8eca7..6dd8332c896 100644
--- a/sys/dev/scsipi/ses.c
+++ b/sys/dev/scsipi/ses.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ses.c,v 1.39 2008/04/05 15:47:01 cegger Exp $ */
+/* $NetBSD: ses.c,v 1.40 2008/06/08 18:18:34 tsutsui Exp $ */
/*
* Copyright (C) 2000 National Aeronautics & Space Administration
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ses.c,v 1.39 2008/04/05 15:47:01 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ses.c,v 1.40 2008/06/08 18:18:34 tsutsui Exp $");
#include "opt_scsi.h"
@@ -296,9 +296,7 @@ sesopen(dev_t dev, int flags, int fmt, struct lwp *l)
int error, unit;
unit = SESUNIT(dev);
- if (unit >= ses_cd.cd_ndevs)
- return (ENXIO);
- softc = ses_cd.cd_devs[unit];
+ softc = device_lookup_private(&ses_cd, unit);
if (softc == NULL)
return (ENXIO);
@@ -341,9 +339,7 @@ sesclose(dev_t dev, int flags, int fmt,
int unit;
unit = SESUNIT(dev);
- if (unit >= ses_cd.cd_ndevs)
- return (ENXIO);
- softc = ses_cd.cd_devs[unit];
+ softc = device_lookup_private(&ses_cd, unit);
if (softc == NULL)
return (ENXIO);
@@ -359,7 +355,7 @@ sesioctl(dev_t dev, u_long cmd, void *arg_addr, int flag, struct lwp *l)
ses_encstat tmp;
ses_objstat objs;
ses_object obj, *uobj;
- struct ses_softc *ssc = ses_cd.cd_devs[SESUNIT(dev)];
+ struct ses_softc *ssc = device_lookup_private(&ses_cd, SESUNIT(dev));
void *addr;
int error, i;
diff --git a/sys/dev/scsipi/ss.c b/sys/dev/scsipi/ss.c
index 906a636ce3d..ee11e972553 100644
--- a/sys/dev/scsipi/ss.c
+++ b/sys/dev/scsipi/ss.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ss.c,v 1.73 2008/04/05 15:47:01 cegger Exp $ */
+/* $NetBSD: ss.c,v 1.74 2008/06/08 18:18:34 tsutsui Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.73 2008/04/05 15:47:01 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.74 2008/06/08 18:18:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -249,10 +249,8 @@ ssopen(dev_t dev, int flag, int mode, struct lwp *l)
struct scsipi_adapter *adapt;
unit = SSUNIT(dev);
- if (unit >= ss_cd.cd_ndevs)
- return (ENXIO);
- ss = ss_cd.cd_devs[unit];
- if (!ss)
+ ss = device_lookup_private(&ss_cd, unit);
+ if (ss == NULL)
return (ENXIO);
if (!device_is_active(&ss->sc_dev))
@@ -313,7 +311,7 @@ bad:
static int
ssclose(dev_t dev, int flag, int mode, struct lwp *l)
{
- struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(dev));
struct scsipi_periph *periph = ss->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
int error;
@@ -350,7 +348,7 @@ ssclose(dev_t dev, int flag, int mode, struct lwp *l)
static void
ssminphys(struct buf *bp)
{
- struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
+ struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(bp->b_dev));
struct scsipi_periph *periph = ss->sc_periph;
scsipi_adapter_minphys(periph->periph_channel, bp);
@@ -373,7 +371,7 @@ ssminphys(struct buf *bp)
static int
ssread(dev_t dev, struct uio *uio, int flag)
{
- struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(dev));
int error;
if (!device_is_active(&ss->sc_dev))
@@ -400,7 +398,7 @@ ssread(dev_t dev, struct uio *uio, int flag)
static void
ssstrategy(struct buf *bp)
{
- struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
+ struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(bp->b_dev));
struct scsipi_periph *periph = ss->sc_periph;
int s;
@@ -535,7 +533,7 @@ ssdone(struct scsipi_xfer *xs, int error)
int
ssioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(dev));
int error = 0;
struct scan_io *sio;
diff --git a/sys/dev/scsipi/st.c b/sys/dev/scsipi/st.c
index 54d97a9f30f..cd9511bef78 100644
--- a/sys/dev/scsipi/st.c
+++ b/sys/dev/scsipi/st.c
@@ -1,4 +1,4 @@
-/* $NetBSD: st.c,v 1.204 2008/04/28 20:23:58 martin Exp $ */
+/* $NetBSD: st.c,v 1.205 2008/06/08 18:18:34 tsutsui 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.204 2008/04/28 20:23:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.205 2008/06/08 18:18:34 tsutsui Exp $");
#include "opt_scsi.h"
@@ -538,9 +538,7 @@ stopen(dev_t dev, int flags, int mode, struct lwp *l)
struct scsipi_adapter *adapt;
unit = STUNIT(dev);
- if (unit >= st_cd.cd_ndevs)
- return (ENXIO);
- st = st_cd.cd_devs[unit];
+ st = device_lookup_private(&st_cd, unit);
if (st == NULL)
return (ENXIO);
@@ -719,7 +717,7 @@ static int
stclose(dev_t dev, int flags, int mode, struct lwp *l)
{
int stxx, error = 0;
- struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = device_lookup_private(&st_cd, STUNIT(dev));
struct scsipi_periph *periph = st->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
@@ -821,7 +819,7 @@ st_mount_tape(dev_t dev, int flags)
unit = STUNIT(dev);
dsty = STDSTY(dev);
- st = st_cd.cd_devs[unit];
+ st = device_lookup_private(&st_cd, unit);
periph = st->sc_periph;
if (st->flags & ST_MOUNTED)
@@ -1067,7 +1065,7 @@ done:
static void
ststrategy(struct buf *bp)
{
- struct st_softc *st = st_cd.cd_devs[STUNIT(bp->b_dev)];
+ struct st_softc *st = device_lookup_private(&st_cd, STUNIT(bp->b_dev));
int s;
SC_DEBUG(st->sc_periph, SCSIPI_DB1,
@@ -1357,7 +1355,7 @@ stdone(struct scsipi_xfer *xs, int error)
static int
stread(dev_t dev, struct uio *uio, int iomode)
{
- struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = device_lookup_private(&st_cd, STUNIT(dev));
return (physio(ststrategy, NULL, dev, B_READ,
st->sc_periph->periph_channel->chan_adapter->adapt_minphys, uio));
@@ -1366,7 +1364,7 @@ stread(dev_t dev, struct uio *uio, int iomode)
static int
stwrite(dev_t dev, struct uio *uio, int iomode)
{
- struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = device_lookup_private(&st_cd, STUNIT(dev));
return (physio(ststrategy, NULL, dev, B_WRITE,
st->sc_periph->periph_channel->chan_adapter->adapt_minphys, uio));
@@ -1394,7 +1392,7 @@ stioctl(dev_t dev, u_long cmd, void *arg, int flag, struct lwp *l)
flags = 0; /* give error messages, act on errors etc. */
unit = STUNIT(dev);
dsty = STDSTY(dev);
- st = st_cd.cd_devs[unit];
+ st = device_lookup_private(&st_cd, unit);
hold_blksize = st->blksize;
hold_density = st->density;
diff --git a/sys/dev/scsipi/uk.c b/sys/dev/scsipi/uk.c
index e2fe0129a98..473792ba1c2 100644
--- a/sys/dev/scsipi/uk.c
+++ b/sys/dev/scsipi/uk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uk.c,v 1.54 2008/04/28 20:23:58 martin Exp $ */
+/* $NetBSD: uk.c,v 1.55 2008/06/08 18:18:34 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uk.c,v 1.54 2008/04/28 20:23:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uk.c,v 1.55 2008/06/08 18:18:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -155,9 +155,7 @@ ukopen(dev_t dev, int flag, int fmt, struct lwp *l)
struct scsipi_adapter *adapt;
unit = UKUNIT(dev);
- if (unit >= uk_cd.cd_ndevs)
- return (ENXIO);
- uk = uk_cd.cd_devs[unit];
+ uk = device_lookup_private(&uk_cd, unit);
if (uk == NULL)
return (ENXIO);
@@ -191,7 +189,7 @@ ukopen(dev_t dev, int flag, int fmt, struct lwp *l)
static int
ukclose(dev_t dev, int flag, int fmt, struct lwp *l)
{
- struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
+ struct uk_softc *uk = device_lookup_private(&uk_cd, UKUNIT(dev));
struct scsipi_periph *periph = uk->sc_periph;
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
@@ -212,7 +210,7 @@ ukclose(dev_t dev, int flag, int fmt, struct lwp *l)
static int
ukioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
- register struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
+ struct uk_softc *uk = device_lookup_private(&uk_cd, UKUNIT(dev));
return (scsipi_do_ioctl(uk->sc_periph, dev, cmd, addr, flag, l));
}