Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Split device_t/softc.
details: https://anonhg.NetBSD.org/src/rev/0bb88019ad1c
branches: trunk
changeset: 747257:0bb88019ad1c
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Mon Sep 07 13:39:19 2009 +0000
description:
Split device_t/softc.
Tested QLogic 1020 Fast Wide SCSI HBA at PCI.
Sbus attachment is untested, but not so much quirks in it.
diffstat:
sys/dev/ic/isp_netbsd.c | 23 +++++++++++++----------
sys/dev/ic/isp_netbsd.h | 8 ++++----
sys/dev/pci/isp_pci.c | 22 ++++++++++++----------
sys/dev/sbus/isp_sbus.c | 15 +++++++++------
4 files changed, 38 insertions(+), 30 deletions(-)
diffs (283 lines):
diff -r 3ad1893c0871 -r 0bb88019ad1c sys/dev/ic/isp_netbsd.c
--- a/sys/dev/ic/isp_netbsd.c Mon Sep 07 13:31:44 2009 +0000
+++ b/sys/dev/ic/isp_netbsd.c Mon Sep 07 13:39:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.80 2009/06/25 23:44:02 mjacob Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.81 2009/09/07 13:39:19 tsutsui Exp $ */
/*
* Platform (NetBSD) dependent common attachment code for Qlogic adapters.
*/
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.80 2009/06/25 23:44:02 mjacob Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.81 2009/09/07 13:39:19 tsutsui Exp $");
#include <dev/ic/isp_netbsd.h>
#include <dev/ic/isp_ioctl.h>
@@ -92,10 +92,12 @@
void
isp_attach(struct ispsoftc *isp)
{
+ device_t self = isp->isp_osinfo.dev;
int i;
+
isp->isp_state = ISP_RUNSTATE;
- isp->isp_osinfo.adapter.adapt_dev = &isp->isp_osinfo.dev;
+ isp->isp_osinfo.adapter.adapt_dev = self;
isp->isp_osinfo.adapter.adapt_openings = isp->isp_maxcmds;
isp->isp_osinfo.loop_down_limit = 300;
@@ -118,7 +120,8 @@
callout_setfunc(&isp->isp_osinfo.ldt, isp_ldt, isp);
if (IS_FC(isp)) {
if (kthread_create(PRI_NONE, 0, NULL, isp_fc_worker, isp,
- &isp->isp_osinfo.thread, "%s:fc_thrd", device_xname(&isp->isp_osinfo.dev))) {
+ &isp->isp_osinfo.thread, "%s:fc_thrd",
+ device_xname(self))) {
isp_prt(isp, ISP_LOGERR,
"unable to create FC worker thread");
return;
@@ -154,14 +157,14 @@
/*
* Defer enabling mailbox interrupts until later.
*/
- config_interrupts((device_t) isp, isp_config_interrupts);
+ config_interrupts(self, isp_config_interrupts);
}
static void
isp_config_interrupts(device_t self)
{
int i;
- struct ispsoftc *isp = (struct ispsoftc *) self;
+ struct ispsoftc *isp = device_private(self);
isp->isp_osinfo.mbox_sleep_ok = 1;
@@ -176,7 +179,7 @@
* And attach children (if any).
*/
for (i = 0; i < isp->isp_osinfo.adapter.adapt_nchannels; i++) {
- config_found((void *)isp, &isp->isp_osinfo.chan[i], scsiprint);
+ config_found(self, &isp->isp_osinfo.chan[i], scsiprint);
}
}
@@ -205,7 +208,7 @@
ispioctl(struct scsipi_channel *chan, u_long cmd, void *addr, int flag,
struct proc *p)
{
- struct ispsoftc *isp = (void *)chan->chan_adapter->adapt_dev;
+ struct ispsoftc *isp = device_private(chan->chan_adapter->adapt_dev);
int nr, bus, retval = ENOTTY;
switch (cmd) {
@@ -681,7 +684,7 @@
static void
isprequest(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg)
{
- struct ispsoftc *isp = (void *)chan->chan_adapter->adapt_dev;
+ struct ispsoftc *isp = device_private(chan->chan_adapter->adapt_dev);
switch (req) {
case ADAPTER_REQ_RUN_XFER:
@@ -1503,7 +1506,7 @@
if (level != ISP_LOGALL && (level & isp->isp_dblev) == 0) {
return;
}
- printf("%s: ", device_xname(&isp->isp_osinfo.dev));
+ printf("%s: ", device_xname(isp->isp_osinfo.dev));
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
diff -r 3ad1893c0871 -r 0bb88019ad1c sys/dev/ic/isp_netbsd.h
--- a/sys/dev/ic/isp_netbsd.h Mon Sep 07 13:31:44 2009 +0000
+++ b/sys/dev/ic/isp_netbsd.h Mon Sep 07 13:39:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.h,v 1.67 2009/06/25 23:44:02 mjacob Exp $ */
+/* $NetBSD: isp_netbsd.h,v 1.68 2009/09/07 13:39:19 tsutsui Exp $ */
/*
* NetBSD Specific definitions for the Qlogic ISP Host Adapter
*/
@@ -73,7 +73,7 @@
#define ISP_PLATFORM_VERSION_MINOR 0
struct isposinfo {
- struct device dev;
+ device_t dev;
struct scsipi_adapter adapter;
struct scsipi_channel * chan;
bus_dma_tag_t dmatag;
@@ -219,7 +219,7 @@
#define XS_CHANNEL(xs) \
((int) (xs)->xs_periph->periph_channel->chan_channel)
#define XS_ISP(xs) \
- ((void *)(xs)->xs_periph->periph_channel->chan_adapter->adapt_dev)
+ device_private((xs)->xs_periph->periph_channel->chan_adapter->adapt_dev)
#define XS_LUN(xs) ((int) (xs)->xs_periph->periph_lun)
#define XS_TGT(xs) ((int) (xs)->xs_periph->periph_target)
#define XS_CDBP(xs) ((uint8_t *) (xs)->cmd)
@@ -343,7 +343,7 @@
/*
* isp_osinfo definitions, extensions and shorthand.
*/
-#define isp_unit isp_osinfo.dev.dv_unit
+#define isp_unit device_unit(isp_osinfo.dev)
/*
diff -r 3ad1893c0871 -r 0bb88019ad1c sys/dev/pci/isp_pci.c
--- a/sys/dev/pci/isp_pci.c Mon Sep 07 13:31:44 2009 +0000
+++ b/sys/dev/pci/isp_pci.c Mon Sep 07 13:39:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_pci.c,v 1.109 2009/06/25 23:44:02 mjacob Exp $ */
+/* $NetBSD: isp_pci.c,v 1.110 2009/09/07 13:39:19 tsutsui Exp $ */
/*
* Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
* All rights reserved.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isp_pci.c,v 1.109 2009/06/25 23:44:02 mjacob Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_pci.c,v 1.110 2009/09/07 13:39:19 tsutsui Exp $");
#include <dev/ic/isp_netbsd.h>
#include <dev/pci/pcireg.h>
@@ -424,7 +424,7 @@
int16_t pci_poff[_NREG_BLKS];
};
-CFATTACH_DECL(isp_pci, sizeof (struct isp_pcisoftc),
+CFATTACH_DECL_NEW(isp_pci, sizeof (struct isp_pcisoftc),
isp_pci_probe, isp_pci_attach, NULL, NULL);
static int
@@ -493,6 +493,8 @@
int ioh_valid, memh_valid;
size_t mamt;
+ isp->isp_osinfo.dev = self;
+
ioh_valid = (pci_mapreg_map(pa, IO_MAP_REG,
PCI_MAPREG_TYPE_IO, 0,
&iot, &ioh, NULL, NULL) == 0);
@@ -684,7 +686,7 @@
isp->isp_param = malloc(mamt, M_DEVBUF, M_NOWAIT);
if (isp->isp_param == NULL) {
- printf(nomem, device_xname(&isp->isp_osinfo.dev));
+ printf(nomem, device_xname(self));
return;
}
memset(isp->isp_param, 0, mamt);
@@ -692,7 +694,7 @@
isp->isp_osinfo.chan = malloc(mamt, M_DEVBUF, M_NOWAIT);
if (isp->isp_osinfo.chan == NULL) {
free(isp->isp_param, M_DEVBUF);
- printf(nomem, device_xname(&isp->isp_osinfo.dev));
+ printf(nomem, device_xname(self));
return;
}
memset(isp->isp_osinfo.chan, 0, mamt);
@@ -752,7 +754,7 @@
pci_conf_write(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR, data);
if (pci_intr_map(pa, &ih)) {
- aprint_error_dev(&isp->isp_osinfo.dev, "couldn't map interrupt\n");
+ aprint_error_dev(self, "couldn't map interrupt\n");
free(isp->isp_param, M_DEVBUF);
free(isp->isp_osinfo.chan, M_DEVBUF);
return;
@@ -763,16 +765,16 @@
pcs->pci_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
isp_pci_intr, isp);
if (pcs->pci_ih == NULL) {
- aprint_error_dev(&isp->isp_osinfo.dev, "couldn't establish interrupt at %s\n",
+ aprint_error_dev(self, "couldn't establish interrupt at %s\n",
intrstr);
free(isp->isp_param, M_DEVBUF);
free(isp->isp_osinfo.chan, M_DEVBUF);
return;
}
- printf("%s: interrupting at %s\n", device_xname(&isp->isp_osinfo.dev), intrstr);
+ printf("%s: interrupting at %s\n", device_xname(self), intrstr);
- isp->isp_confopts = self->dv_cfdata->cf_flags;
+ isp->isp_confopts = device_cfdata(self)->cf_flags;
ISP_LOCK(isp);
isp_reset(isp, 1);
if (isp->isp_state != ISP_RESETSTATE) {
@@ -1436,7 +1438,7 @@
{
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
if (msg)
- printf("%s: %s\n", device_xname(&isp->isp_osinfo.dev), msg);
+ printf("%s: %s\n", device_xname(isp->isp_osinfo.dev), msg);
if (IS_SCSI(isp))
printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
else
diff -r 3ad1893c0871 -r 0bb88019ad1c sys/dev/sbus/isp_sbus.c
--- a/sys/dev/sbus/isp_sbus.c Mon Sep 07 13:31:44 2009 +0000
+++ b/sys/dev/sbus/isp_sbus.c Mon Sep 07 13:39:19 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_sbus.c,v 1.77 2009/06/25 23:44:02 mjacob Exp $ */
+/* $NetBSD: isp_sbus.c,v 1.78 2009/09/07 13:39:19 tsutsui Exp $ */
/*
* SBus specific probe and attach routines for Qlogic ISP SCSI adapters.
*
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isp_sbus.c,v 1.77 2009/06/25 23:44:02 mjacob Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_sbus.c,v 1.78 2009/09/07 13:39:19 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -96,7 +96,7 @@
static int isp_match(device_t, cfdata_t, void *);
static void isp_sbus_attach(device_t, device_t, void *);
-CFATTACH_DECL(isp_sbus, sizeof (struct isp_sbussoftc),
+CFATTACH_DECL_NEW(isp_sbus, sizeof (struct isp_sbussoftc),
isp_match, isp_sbus_attach, NULL, NULL);
static int
@@ -120,10 +120,12 @@
{
int freq, ispburst, sbusburst;
struct sbus_attach_args *sa = aux;
- struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) self;
+ struct isp_sbussoftc *sbc = device_private(self);
struct sbus_softc *sbsc = device_private(parent);
ispsoftc_t *isp = &sbc->sbus_isp;
+ isp->isp_osinfo.dev = self;
+
printf(" for %s\n", sa->sa_name);
isp->isp_nchan = isp->isp_osinfo.adapter.adapt_nchannels = 1;
@@ -200,7 +202,7 @@
/* Establish interrupt channel */
bus_intr_establish(sbc->sbus_bustag, sbc->sbus_pri, IPL_BIO,
isp_sbus_intr, sbc);
- sbus_establish(&sbc->sbus_sd, &sbc->sbus_isp.isp_osinfo.dev);
+ sbus_establish(&sbc->sbus_sd, self);
/*
* Set up logging levels.
@@ -539,7 +541,8 @@
dmap = sbc->sbus_dmamap[isp_handle_index(handle)];
if (dmap->dm_nsegs == 0) {
- panic("%s: DMA map not already allocated", device_xname(&isp->isp_osinfo.dev));
+ panic("%s: DMA map not already allocated",
+ device_xname(isp->isp_osinfo.dev));
/* NOTREACHED */
}
bus_dmamap_sync(isp->isp_dmatag, dmap, 0,
Home |
Main Index |
Thread Index |
Old Index