split device/softc for scsibus

This commit is contained in:
drochner 2008-07-16 18:50:58 +00:00
parent 8b720093a8
commit a3df0dfc03
4 changed files with 22 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.227 2008/02/12 17:30:58 joerg Exp $ */
/* $NetBSD: autoconf.c,v 1.228 2008/07/16 18:50:58 drochner Exp $ */
/*
* Copyright (c) 1996
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.227 2008/02/12 17:30:58 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.228 2008/07/16 18:50:58 drochner Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -1767,12 +1767,12 @@ device_register(struct device *dev, void *aux)
struct scsipi_periph *periph = sa->sa_periph;
struct scsipi_channel *chan = periph->periph_channel;
struct scsibus_softc *sbsc =
(struct scsibus_softc *)device_parent(dev);
devive_private(device_parent(dev));
u_int target = bp->val[0];
u_int lun = bp->val[1];
/* Check the controller that this scsibus is on */
if ((bp-1)->dev != device_parent(&sbsc->sc_dev))
if ((bp-1)->dev != device_parent(sbsc->sc_dev))
return;
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.56 2008/06/25 08:14:59 isaki Exp $ */
/* $NetBSD: autoconf.c,v 1.57 2008/07/16 18:50:58 drochner Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2008/06/25 08:14:59 isaki Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2008/07/16 18:50:58 drochner Exp $");
#include "opt_compat_netbsd.h"
#include "scsibus.h"
@ -259,7 +259,7 @@ scsi_find(dev_t bdev)
}
if (!scsibus)
return NULL;
sbsc = (struct scsibus_softc *) scsibus;
sbsc = device_private(scsibus);
periph = scsipi_lookup_periph(sbsc->sc_channel,
B_X68K_SCSI_ID(bdev), B_X68K_SCSI_LUN(bdev));

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.249 2008/07/03 13:22:31 hannken Exp $ */
/* $NetBSD: scsiconf.c,v 1.250 2008/07/16 18:50:58 drochner 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.249 2008/07/03 13:22:31 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.250 2008/07/16 18:50:58 drochner Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -94,7 +94,7 @@ static int scsibusdetach(struct device *, int flags);
static int scsibusrescan(struct device *, const char *, const int *);
static void scsidevdetached(struct device *, struct device *);
CFATTACH_DECL2(scsibus, sizeof(struct scsibus_softc),
CFATTACH_DECL2_NEW(scsibus, sizeof(struct scsibus_softc),
scsibusmatch, scsibusattach, scsibusdetach, scsibusactivate,
scsibusrescan, scsidevdetached);
@ -162,8 +162,9 @@ scsibusattach(struct device *parent, struct device *self, void *aux)
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
sc->sc_dev = self;
sc->sc_channel = chan;
chan->chan_name = device_xname(&sc->sc_dev);
chan->chan_name = device_xname(sc->sc_dev);
aprint_naive(": SCSI bus\n");
aprint_normal(": %d target%s, %d lun%s per target\n",
@ -184,7 +185,7 @@ scsibusattach(struct device *parent, struct device *self, void *aux)
TAILQ_INSERT_TAIL(&scsi_initq_head, scsi_initq, scsi_initq);
config_pending_incr();
if (scsipi_channel_init(chan)) {
aprint_error_dev(&sc->sc_dev, "failed to init channel\n");
aprint_error_dev(sc->sc_dev, "failed to init channel\n");
return;
}
}
@ -200,7 +201,7 @@ scsibus_config(struct scsipi_channel *chan, void *arg)
#endif
if ((chan->chan_flags & SCSIPI_CHAN_NOSETTLE) == 0 &&
SCSI_DELAY > 0) {
aprint_normal_dev(&sc->sc_dev,
aprint_normal_dev(sc->sc_dev,
"waiting %d seconds for devices to settle...\n",
SCSI_DELAY);
/* ...an identifier we know no one will use... */
@ -384,14 +385,14 @@ scsibusrescan(struct device *sc, const char *ifattr,
KASSERT(ifattr && !strcmp(ifattr, "scsibus"));
KASSERT(locators);
return (scsi_probe_bus((struct scsibus_softc *)sc,
return (scsi_probe_bus(device_private(sc),
locators[SCSIBUSCF_TARGET], locators[SCSIBUSCF_LUN]));
}
static void
scsidevdetached(struct device *sc, struct device *dev)
{
struct scsibus_softc *ssc = (struct scsibus_softc *)sc;
struct scsibus_softc *ssc = device_private(sc);
struct scsipi_channel *chan = ssc->sc_channel;
struct scsipi_periph *periph;
int target, lun;
@ -745,7 +746,7 @@ scsi_probe_device(struct scsibus_softc *sc, int target, int lun)
periph = scsipi_alloc_periph(M_NOWAIT);
if (periph == NULL) {
#ifdef DIAGNOSTIC
aprint_error_dev(&sc->sc_dev,
aprint_error_dev(sc->sc_dev,
"cannot allocate periph for target %d lun %d\n",
target, lun);
#endif
@ -944,7 +945,7 @@ scsi_probe_device(struct scsibus_softc *sc, int target, int lun)
locs[SCSIBUSCF_TARGET] = target;
locs[SCSIBUSCF_LUN] = lun;
if ((cf = config_search_loc(config_stdsubmatch, &sc->sc_dev,
if ((cf = config_search_loc(config_stdsubmatch, sc->sc_dev,
"scsibus", locs, &sa)) != NULL) {
scsipi_insert_periph(chan, periph);
/*
@ -952,10 +953,10 @@ scsi_probe_device(struct scsibus_softc *sc, int target, int lun)
* XXX need it before config_attach() returns. Must
* XXX assign it in periph driver.
*/
chld = config_attach_loc(&sc->sc_dev, cf, locs, &sa,
chld = config_attach_loc(sc->sc_dev, cf, locs, &sa,
scsibusprint);
} else {
scsibusprint(&sa, device_xname(&sc->sc_dev));
scsibusprint(&sa, device_xname(sc->sc_dev));
aprint_normal(" not configured\n");
goto bad;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.h,v 1.55 2008/04/28 20:23:57 martin Exp $ */
/* $NetBSD: scsiconf.h,v 1.56 2008/07/16 18:50:58 drochner Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@ -55,7 +55,7 @@
int scsiprint(void *, const char *);
struct scsibus_softc {
struct device sc_dev;
device_t sc_dev;
struct scsipi_channel *sc_channel; /* our scsipi_channel */
int sc_flags;
};