Module Name: src
Committed By: tsutsui
Date: Mon Sep 21 08:12:47 UTC 2009
Modified Files:
src/sys/dev/ic: aha.c ahavar.h
src/sys/dev/isa: aha_isa.c
src/sys/dev/isapnp: aha_isapnp.c
src/sys/dev/mca: aha_mca.c
Log Message:
Split device_t/softc. Tested on AHA-1542CF.
To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/ic/aha.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/ahavar.h
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/isa/aha_isa.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/isapnp/aha_isapnp.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/mca/aha_mca.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/aha.c
diff -u src/sys/dev/ic/aha.c:1.58 src/sys/dev/ic/aha.c:1.59
--- src/sys/dev/ic/aha.c:1.58 Sat Mar 14 15:36:17 2009
+++ src/sys/dev/ic/aha.c Mon Sep 21 08:12:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: aha.c,v 1.58 2009/03/14 15:36:17 dsl Exp $ */
+/* $NetBSD: aha.c,v 1.59 2009/09/21 08:12:47 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aha.c,v 1.58 2009/03/14 15:36:17 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aha.c,v 1.59 2009/09/21 08:12:47 tsutsui Exp $");
#include "opt_ddb.h"
@@ -134,7 +134,7 @@
u_char opcode = ibuf[0];
if (sc != NULL)
- name = device_xname(&sc->sc_dev);
+ name = device_xname(sc->sc_dev);
else
name = "(aha probe)";
@@ -250,7 +250,7 @@
* Fill in the scsipi_adapter.
*/
memset(adapt, 0, sizeof(*adapt));
- adapt->adapt_dev = &sc->sc_dev;
+ adapt->adapt_dev = sc->sc_dev;
adapt->adapt_nchannels = 1;
/* adapt_openings initialized below */
/* adapt_max_periph initialized below */
@@ -277,7 +277,7 @@
/*
* ask the adapter what subunits are present
*/
- config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
+ config_found(sc->sc_dev, &sc->sc_channel, scsiprint);
}
static void
@@ -297,7 +297,7 @@
for (i = 0; i < AHA_MBX_SIZE; i++) {
if (wmbi->stat != AHA_MBI_FREE) {
printf("%s: mbi not in round-robin order\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
goto AGAIN;
}
aha_nextmbx(wmbi, wmbx, mbi);
@@ -307,7 +307,7 @@
}
#ifdef AHADIAGnot
printf("%s: mbi interrupt with no full mailboxes\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
#endif
return;
}
@@ -317,7 +317,7 @@
ccb = aha_ccb_phys_kv(sc, phystol(wmbi->ccb_addr));
if (!ccb) {
printf("%s: bad mbi ccb pointer; skipping\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
goto next;
}
@@ -362,7 +362,7 @@
default:
printf("%s: bad mbi status %02x; skipping\n",
- device_xname(&sc->sc_dev), wmbi->stat);
+ device_xname(sc->sc_dev), wmbi->stat);
goto next;
}
@@ -395,7 +395,7 @@
u_char sts;
#ifdef AHADEBUG
- printf("%s: aha_intr ", device_xname(&sc->sc_dev));
+ printf("%s: aha_intr ", device_xname(sc->sc_dev));
#endif /*AHADEBUG */
/*
@@ -464,7 +464,8 @@
error = bus_dmamap_create(dmat, AHA_MAXXFER, AHA_NSEG, AHA_MAXXFER,
0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &ccb->dmamap_xfer);
if (error) {
- aprint_error_dev(&sc->sc_dev, "unable to create ccb DMA map, error = %d\n",
+ aprint_error_dev(sc->sc_dev,
+ "unable to create ccb DMA map, error = %d\n",
error);
return (error);
}
@@ -496,7 +497,8 @@
for (i = 0; i < count; i++) {
ccb = &ccbstore[i];
if ((error = aha_init_ccb(sc, ccb)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to initialize ccb, error = %d\n",
+ aprint_error_dev(sc->sc_dev,
+ "unable to initialize ccb, error = %d\n",
error);
goto out;
}
@@ -679,13 +681,15 @@
*/
#ifdef AHADIAG
if (ccb->flags & CCB_SENDING) {
- printf("%s: exiting ccb still in transit!\n", device_xname(&sc->sc_dev));
+ printf("%s: exiting ccb still in transit!\n",
+ device_xname(sc->sc_dev));
Debugger();
return;
}
#endif
if ((ccb->flags & CCB_ALLOC) == 0) {
- printf("%s: exiting ccb not allocated!\n", device_xname(&sc->sc_dev));
+ printf("%s: exiting ccb not allocated!\n",
+ device_xname(sc->sc_dev));
Debugger();
return;
}
@@ -697,7 +701,7 @@
break;
default: /* Other scsi protocol messes */
printf("%s: host_stat %x\n",
- device_xname(&sc->sc_dev), ccb->host_stat);
+ device_xname(sc->sc_dev), ccb->host_stat);
xs->error = XS_DRIVER_STUFFUP;
break;
}
@@ -715,7 +719,7 @@
break;
default:
printf("%s: target_stat %x\n",
- device_xname(&sc->sc_dev), ccb->target_stat);
+ device_xname(sc->sc_dev), ccb->target_stat);
xs->error = XS_DRIVER_STUFFUP;
break;
}
@@ -860,7 +864,8 @@
struct aha_extbios extbios;
struct aha_unlock unlock;
- printf("%s: unlocking mailbox interface\n", device_xname(&sc->sc_dev));
+ printf("%s: unlocking mailbox interface\n",
+ device_xname(sc->sc_dev));
extbios.cmd.opcode = AHA_EXT_BIOS;
aha_cmd(iot, ioh, sc,
sizeof(extbios.cmd), (u_char *)&extbios.cmd,
@@ -868,7 +873,7 @@
#ifdef AHADEBUG
printf("%s: flags=%02x, mailboxlock=%02x\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
extbios.reply.flags, extbios.reply.mailboxlock);
#endif /* AHADEBUG */
@@ -916,7 +921,7 @@
sizeof(setup.reply), (u_char *)&setup.reply);
printf("%s: %s, %s\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
setup.reply.sync_neg ? "sync" : "async",
setup.reply.parity ? "parity" : "no parity");
@@ -925,7 +930,7 @@
(!setup.reply.sync[i].offset && !setup.reply.sync[i].period))
continue;
printf("%s targ %d: sync, offset %d, period %dnsec\n",
- device_xname(&sc->sc_dev), i,
+ device_xname(sc->sc_dev), i,
setup.reply.sync[i].offset, setup.reply.sync[i].period * 50 + 200);
}
@@ -934,14 +939,16 @@
*/
if ((error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct aha_control),
PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to allocate control structures, "
+ aprint_error_dev(sc->sc_dev,
+ "unable to allocate control structures, "
"error = %d\n", error);
return (error);
}
if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
sizeof(struct aha_control), (void **)&sc->sc_control,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to map control structures, error = %d\n", error);
+ aprint_error_dev(sc->sc_dev,
+ "unable to map control structures, error = %d\n", error);
return (error);
}
@@ -952,14 +959,16 @@
if ((error = bus_dmamap_create(sc->sc_dmat, sizeof(struct aha_control),
1, sizeof(struct aha_control), 0, BUS_DMA_NOWAIT,
&sc->sc_dmamap_control)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to create control DMA map, error = %d\n",
+ aprint_error_dev(sc->sc_dev,
+ "unable to create control DMA map, error = %d\n",
error);
return (error);
}
if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_control,
sc->sc_control, sizeof(struct aha_control), NULL,
BUS_DMA_NOWAIT)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to load control DMA map, error = %d\n",
+ aprint_error_dev(sc->sc_dev,
+ "unable to load control DMA map, error = %d\n",
error);
return (error);
}
@@ -969,11 +978,12 @@
*/
i = aha_create_ccbs(sc, sc->sc_control->ac_ccbs, initial_ccbs);
if (i == 0) {
- aprint_error_dev(&sc->sc_dev, "unable to create control blocks\n");
+ aprint_error_dev(sc->sc_dev,
+ "unable to create control blocks\n");
return (ENOMEM);
} else if (i != initial_ccbs) {
printf("%s: WARNING: only %d of %d control blocks created\n",
- device_xname(&sc->sc_dev), i, initial_ccbs);
+ device_xname(sc->sc_dev), i, initial_ccbs);
}
sc->sc_adapter.adapt_openings = i;
@@ -1053,7 +1063,7 @@
#ifdef AHADEBUG
printf("%s: inquire %x, %x, %x, %x\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
revision.reply.boardid, revision.reply.spec_opts,
revision.reply.revision_1, revision.reply.revision_2);
#endif /* AHADEBUG */
@@ -1092,7 +1102,7 @@
noinquire:
printf("%s: model AHA-%s, firmware %s\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
sc->sc_model, sc->sc_firmware);
}
@@ -1116,7 +1126,7 @@
{
struct scsipi_xfer *xs;
struct scsipi_periph *periph;
- struct aha_softc *sc = (void *)chan->chan_adapter->adapt_dev;
+ struct aha_softc *sc = device_private(chan->chan_adapter->adapt_dev);
bus_dma_tag_t dmat = sc->sc_dmat;
struct aha_ccb *ccb;
int error, seg, flags, s;
@@ -1157,7 +1167,7 @@
/* can't use S/G if zero length */
if (xs->cmdlen > sizeof(ccb->scsi_cmd)) {
printf("%s: cmdlen %d too large for CCB\n",
- device_xname(&sc->sc_dev), xs->cmdlen);
+ device_xname(sc->sc_dev), xs->cmdlen);
xs->error = XS_DRIVER_STUFFUP;
goto out_bad;
}
@@ -1205,9 +1215,10 @@
if (error == EFBIG) {
printf("%s: aha_scsi_cmd, more than %d"
" DMA segments\n",
- device_xname(&sc->sc_dev), AHA_NSEG);
+ device_xname(sc->sc_dev), AHA_NSEG);
} else {
- aprint_error_dev(&sc->sc_dev, "error %d loading DMA map\n",
+ aprint_error_dev(sc->sc_dev,
+ "error %d loading DMA map\n",
error);
}
out_bad:
@@ -1323,7 +1334,7 @@
struct scsipi_xfer *xs = ccb->xs;
struct scsipi_periph *periph = xs->xs_periph;
struct aha_softc *sc =
- (void *)periph->periph_channel->chan_adapter->adapt_dev;
+ device_private(periph->periph_channel->chan_adapter->adapt_dev);
int s;
scsipi_printaddr(periph);
@@ -1337,7 +1348,7 @@
*/
aha_collect_mbo(sc);
if (ccb->flags & CCB_SENDING) {
- aprint_error_dev(&sc->sc_dev, "not taking commands!\n");
+ aprint_error_dev(sc->sc_dev, "not taking commands!\n");
Debugger();
}
#endif
Index: src/sys/dev/ic/ahavar.h
diff -u src/sys/dev/ic/ahavar.h:1.14 src/sys/dev/ic/ahavar.h:1.15
--- src/sys/dev/ic/ahavar.h:1.14 Mon Apr 28 20:23:49 2008
+++ src/sys/dev/ic/ahavar.h Mon Sep 21 08:12:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: ahavar.h,v 1.14 2008/04/28 20:23:49 martin Exp $ */
+/* $NetBSD: ahavar.h,v 1.15 2009/09/21 08:12:47 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
};
struct aha_softc {
- struct device sc_dev;
+ device_t sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
Index: src/sys/dev/isa/aha_isa.c
diff -u src/sys/dev/isa/aha_isa.c:1.27 src/sys/dev/isa/aha_isa.c:1.28
--- src/sys/dev/isa/aha_isa.c:1.27 Tue May 12 09:10:15 2009
+++ src/sys/dev/isa/aha_isa.c Mon Sep 21 08:12:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: aha_isa.c,v 1.27 2009/05/12 09:10:15 cegger Exp $ */
+/* $NetBSD: aha_isa.c,v 1.28 2009/09/21 08:12:47 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aha_isa.c,v 1.27 2009/05/12 09:10:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aha_isa.c,v 1.28 2009/09/21 08:12:47 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,7 +54,7 @@
int aha_isa_probe(device_t, cfdata_t, void *);
void aha_isa_attach(device_t, device_t, void *);
-CFATTACH_DECL(aha_isa, sizeof(struct aha_softc),
+CFATTACH_DECL_NEW(aha_isa, sizeof(struct aha_softc),
aha_isa_probe, aha_isa_attach, NULL, NULL);
/*
@@ -121,17 +121,19 @@
aha_isa_attach(device_t parent, device_t self, void *aux)
{
struct isa_attach_args *ia = aux;
- struct aha_softc *sc = (void *)self;
+ struct aha_softc *sc = device_private(self);
bus_space_tag_t iot = ia->ia_iot;
bus_space_handle_t ioh;
struct aha_probe_data apd;
isa_chipset_tag_t ic = ia->ia_ic;
int error;
+ sc->sc_dev = self;
+
printf("\n");
if (bus_space_map(iot, ia->ia_io[0].ir_addr, AHA_ISA_IOSIZE, 0, &ioh)) {
- aprint_error_dev(&sc->sc_dev, "can't map i/o space\n");
+ aprint_error_dev(self, "can't map i/o space\n");
return;
}
@@ -139,13 +141,14 @@
sc->sc_ioh = ioh;
sc->sc_dmat = ia->ia_dmat;
if (!aha_find(iot, ioh, &apd)) {
- aprint_error_dev(&sc->sc_dev, "aha_find failed\n");
+ aprint_error_dev(self, "aha_find failed\n");
return;
}
if (apd.sc_drq != -1) {
if ((error = isa_dmacascade(ic, apd.sc_drq)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to cascade DRQ, error = %d\n", error);
+ aprint_error_dev(self,
+ "unable to cascade DRQ, error = %d\n", error);
return;
}
}
@@ -153,7 +156,7 @@
sc->sc_ih = isa_intr_establish(ic, apd.sc_irq, IST_EDGE, IPL_BIO,
aha_intr, sc);
if (sc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n");
+ aprint_error_dev(self, "couldn't establish interrupt\n");
return;
}
Index: src/sys/dev/isapnp/aha_isapnp.c
diff -u src/sys/dev/isapnp/aha_isapnp.c:1.17 src/sys/dev/isapnp/aha_isapnp.c:1.18
--- src/sys/dev/isapnp/aha_isapnp.c:1.17 Tue May 12 10:16:35 2009
+++ src/sys/dev/isapnp/aha_isapnp.c Mon Sep 21 08:12:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: aha_isapnp.c,v 1.17 2009/05/12 10:16:35 cegger Exp $ */
+/* $NetBSD: aha_isapnp.c,v 1.18 2009/09/21 08:12:47 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aha_isapnp.c,v 1.17 2009/05/12 10:16:35 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aha_isapnp.c,v 1.18 2009/09/21 08:12:47 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -56,7 +56,7 @@
int aha_isapnp_probe(device_t, cfdata_t, void *);
void aha_isapnp_attach(device_t, device_t, void *);
-CFATTACH_DECL(aha_isapnp, sizeof(struct aha_softc),
+CFATTACH_DECL_NEW(aha_isapnp, sizeof(struct aha_softc),
aha_isapnp_probe, aha_isapnp_attach, NULL, NULL);
int
@@ -77,10 +77,12 @@
struct aha_probe_data apd;
struct isapnp_attach_args *ipa = aux;
+ sc->sc_dev = self;
+
printf("\n");
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
- aprint_error_dev(&sc->sc_dev, "error in region allocation\n");
+ aprint_error_dev(self, "error in region allocation\n");
return;
}
@@ -89,32 +91,32 @@
sc->sc_dmat = ipa->ipa_dmat;
if (!aha_find(sc->sc_iot, sc->sc_ioh, &apd)) {
- aprint_error_dev(&sc->sc_dev, "aha_find failed\n");
+ aprint_error_dev(self, "aha_find failed\n");
return;
}
if (ipa->ipa_ndrq == 0) {
if (apd.sc_drq != -1) {
printf("%s: no PnP drq, but card has one\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
} else if (apd.sc_drq != ipa->ipa_drq[0].num) {
printf("%s: card drq # (%d) != PnP # (%d)\n",
- device_xname(&sc->sc_dev), apd.sc_drq, ipa->ipa_drq[0].num);
+ device_xname(self), apd.sc_drq, ipa->ipa_drq[0].num);
return;
} else {
int error = isa_dmacascade(ipa->ipa_ic, ipa->ipa_drq[0].num);
if (error) {
- aprint_error_dev(&sc->sc_dev, "unable to cascade DRQ, error = %d\n",
- error);
+ aprint_error_dev(self,
+ "unable to cascade DRQ, error = %d\n", error);
return;
}
}
if (apd.sc_irq != ipa->ipa_irq[0].num) {
printf("%s: card irq # (%d) != PnP # (%d)\n",
- device_xname(&sc->sc_dev), apd.sc_irq, ipa->ipa_irq[0].num);
+ device_xname(self), apd.sc_irq, ipa->ipa_irq[0].num);
return;
}
@@ -123,7 +125,7 @@
ipa->ipa_irq[0].type, IPL_BIO, aha_intr, sc);
if (sc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n");
+ aprint_error_dev(self, "couldn't establish interrupt\n");
return;
}
Index: src/sys/dev/mca/aha_mca.c
diff -u src/sys/dev/mca/aha_mca.c:1.20 src/sys/dev/mca/aha_mca.c:1.21
--- src/sys/dev/mca/aha_mca.c:1.20 Tue May 12 14:31:00 2009
+++ src/sys/dev/mca/aha_mca.c Mon Sep 21 08:12:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: aha_mca.c,v 1.20 2009/05/12 14:31:00 cegger Exp $ */
+/* $NetBSD: aha_mca.c,v 1.21 2009/09/21 08:12:47 tsutsui Exp $ */
/*
* Copyright (c) 2000-2002 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aha_mca.c,v 1.20 2009/05/12 14:31:00 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aha_mca.c,v 1.21 2009/09/21 08:12:47 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -80,12 +80,11 @@
int aha_mca_probe(device_t, cfdata_t, void *);
void aha_mca_attach(device_t, device_t, void *);
-CFATTACH_DECL(aha_mca, sizeof(struct aha_softc),
+CFATTACH_DECL_NEW(aha_mca, sizeof(struct aha_softc),
aha_mca_probe, aha_mca_attach, NULL, NULL);
int
-aha_mca_probe(device_t parent, cfdata_t match,
- void *aux)
+aha_mca_probe(device_t parent, cfdata_t match, void *aux)
{
register struct mca_attach_args *ma = aux;
@@ -107,6 +106,8 @@
mca_chipset_tag_t mc = ma->ma_mc;
bus_addr_t iobase;
+ sc->sc_dev =self;
+
/*
* POS registers differ much between 8003 and 8013, so they are
* divided to two sections.
@@ -151,7 +152,7 @@
((ma->ma_pos[3] & 0x40) >> 4);
if (bus_space_map(iot, iobase, AHA_ISA_IOSIZE, 0, &ioh)) {
- aprint_error_dev(&sc->sc_dev, "can't map i/o space\n");
+ aprint_error_dev(self, "can't map i/o space\n");
return;
}
@@ -166,7 +167,7 @@
sc->sc_ih = mca_intr_establish(mc, apd.sc_irq, IPL_BIO, aha_intr, sc);
if (sc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n");
+ aprint_error_dev(self, "couldn't establish interrupt\n");
return;
}