Module Name: src Committed By: tsutsui Date: Tue Sep 22 12:56:06 UTC 2009
Modified Files: src/sys/dev/ic: aic6360.c aic6360var.h src/sys/dev/isa: aic_isa.c src/sys/dev/isapnp: aic_isapnp.c src/sys/dev/pcmcia: aic_pcmcia.c Log Message: Split device_t/softc. Tested on AHA-1520B at ISA and ISAPnP. XXX: ISA attachment shouldn't match cards in ISAPnP mode. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/dev/ic/aic6360.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/aic6360var.h cvs rdiff -u -r1.23 -r1.24 src/sys/dev/isa/aic_isa.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/isapnp/aic_isapnp.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pcmcia/aic_pcmcia.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/aic6360.c diff -u src/sys/dev/ic/aic6360.c:1.96 src/sys/dev/ic/aic6360.c:1.97 --- src/sys/dev/ic/aic6360.c:1.96 Tue May 12 14:25:17 2009 +++ src/sys/dev/ic/aic6360.c Tue Sep 22 12:56:06 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: aic6360.c,v 1.96 2009/05/12 14:25:17 cegger Exp $ */ +/* $NetBSD: aic6360.c,v 1.97 2009/09/22 12:56:06 tsutsui Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Charles M. Hannum. All rights reserved. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aic6360.c,v 1.96 2009/05/12 14:25:17 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aic6360.c,v 1.97 2009/09/22 12:56:06 tsutsui Exp $"); #include "opt_ddb.h" @@ -261,7 +261,7 @@ /* * Fill in the scsipi_adapter. */ - adapt->adapt_dev = &sc->sc_dev; + adapt->adapt_dev = sc->sc_dev; adapt->adapt_nchannels = 1; adapt->adapt_openings = 8; adapt->adapt_max_periph = 1; @@ -283,7 +283,7 @@ * config_found() to make sure the adatper is disabled. */ if (scsipi_adapter_addref(adapt) != 0) { - aprint_error_dev(&sc->sc_dev, "unable to enable controller\n"); + aprint_error_dev(sc->sc_dev, "unable to enable controller\n"); return; } @@ -292,14 +292,14 @@ /* * Ask the adapter what subunits are present */ - sc->sc_child = config_found(&sc->sc_dev, &sc->sc_channel, scsiprint); + sc->sc_child = config_found(sc->sc_dev, &sc->sc_channel, scsiprint); scsipi_adapter_delref(adapt); } int aic_activate(device_t self, enum devact act) { - struct aic_softc *sc = (struct aic_softc *) self; + struct aic_softc *sc = device_private(self); int s, rv = 0; s = splhigh(); @@ -321,7 +321,7 @@ int aic_detach(device_t self, int flags) { - struct aic_softc *sc = (struct aic_softc *) self; + struct aic_softc *sc = device_private(self); int rv = 0; if (sc->sc_child != NULL) @@ -506,7 +506,7 @@ { struct scsipi_xfer *xs; struct scsipi_periph *periph; - struct aic_softc *sc = (void *)chan->chan_adapter->adapt_dev; + struct aic_softc *sc = device_private(chan->chan_adapter->adapt_dev); struct aic_acb *acb; int s, flags; @@ -520,7 +520,7 @@ AIC_CMDS(("[0x%x, %d]->%d ", (int)xs->cmd->opcode, xs->cmdlen, periph->periph_target)); - if (! device_is_active(&sc->sc_dev)) { + if (!device_is_active(sc->sc_dev)) { xs->error = XS_DRIVER_STUFFUP; scsipi_done(xs); return; @@ -756,7 +756,8 @@ */ selid = sc->sc_selid & ~(1 << sc->sc_initiator); if (selid & (selid - 1)) { - aprint_error_dev(&sc->sc_dev, "reselect with invalid selid %02x; " + aprint_error_dev(sc->sc_dev, + "reselect with invalid selid %02x; " "sending DEVICE RESET\n", selid); AIC_BREAK(); goto reset; @@ -778,7 +779,7 @@ } if (acb == NULL) { printf("%s: reselect from target %d lun %d with no nexus; " - "sending ABORT\n", device_xname(&sc->sc_dev), target, lun); + "sending ABORT\n", device_xname(sc->sc_dev), target, lun); AIC_BREAK(); goto abort; } @@ -828,7 +829,7 @@ bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; - if (! device_is_active(&sc->sc_dev)) + if (!device_is_active(sc->sc_dev)) return; /* @@ -1084,7 +1085,8 @@ if (sc->sc_dleft < 0) { periph = acb->xs->xs_periph; printf("%s: %ld extra bytes from %d:%d\n", - device_xname(&sc->sc_dev), (long)-sc->sc_dleft, + device_xname(sc->sc_dev), + (long)-sc->sc_dleft, periph->periph_target, periph->periph_lun); sc->sc_dleft = 0; } @@ -1194,7 +1196,8 @@ default: printf("%s: unrecognized MESSAGE EXTENDED; " - "sending REJECT\n", device_xname(&sc->sc_dev)); + "sending REJECT\n", + device_xname(sc->sc_dev)); AIC_BREAK(); goto reject; } @@ -1202,7 +1205,7 @@ default: printf("%s: unrecognized MESSAGE; sending REJECT\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); AIC_BREAK(); reject: aic_sched_msgout(sc, SEND_REJECT); @@ -1213,7 +1216,7 @@ case AIC_RESELECTED: if (!MSG_ISIDENTIFY(sc->sc_imess[0])) { printf("%s: reselect without IDENTIFY; " - "sending DEVICE RESET\n", device_xname(&sc->sc_dev)); + "sending DEVICE RESET\n", device_xname(sc->sc_dev)); AIC_BREAK(); goto reset; } @@ -1222,7 +1225,8 @@ break; default: - aprint_error_dev(&sc->sc_dev, "unexpected MESSAGE IN; sending DEVICE RESET\n"); + aprint_error_dev(sc->sc_dev, + "unexpected MESSAGE IN; sending DEVICE RESET\n"); AIC_BREAK(); reset: aic_sched_msgout(sc, SEND_DEV_RESET); @@ -1369,7 +1373,8 @@ break; default: - aprint_error_dev(&sc->sc_dev, "unexpected MESSAGE OUT; sending NOOP\n"); + aprint_error_dev(sc->sc_dev, + "unexpected MESSAGE OUT; sending NOOP\n"); AIC_BREAK(); sc->sc_omess[0] = MSG_NOOP; n = 1; @@ -1720,7 +1725,7 @@ struct aic_tinfo *ti; int n; - if (! device_is_active(&sc->sc_dev)) + if (!device_is_active(sc->sc_dev)) return (0); /* @@ -1739,7 +1744,7 @@ AIC_MISC(("sstat1:0x%02x ", sstat1)); if ((sstat1 & SCSIRSTI) != 0) { - printf("%s: SCSI bus reset\n", device_xname(&sc->sc_dev)); + printf("%s: SCSI bus reset\n", device_xname(sc->sc_dev)); goto reset; } @@ -1747,7 +1752,7 @@ * Check for less serious errors. */ if ((sstat1 & SCSIPERR) != 0) { - printf("%s: SCSI bus parity error\n", device_xname(&sc->sc_dev)); + printf("%s: SCSI bus parity error\n", device_xname(sc->sc_dev)); bus_space_write_1(iot, ioh, CLRSINT1, CLRSCSIPERR); if (sc->sc_prevphase == PH_MSGIN) { sc->sc_flags |= AIC_DROP_MSGIN; @@ -1777,7 +1782,7 @@ * We don't currently support target mode. */ printf("%s: target mode selected; going to BUS FREE\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); bus_space_write_1(iot, ioh, SCSISIG, 0); goto sched; @@ -1810,7 +1815,7 @@ */ if (sc->sc_state != AIC_SELECTING) { printf("%s: selection out while idle; " - "resetting\n", device_xname(&sc->sc_dev)); + "resetting\n", device_xname(sc->sc_dev)); AIC_BREAK(); goto reset; } @@ -1855,7 +1860,7 @@ if (sc->sc_state != AIC_SELECTING) { printf("%s: selection timeout while idle; " - "resetting\n", device_xname(&sc->sc_dev)); + "resetting\n", device_xname(sc->sc_dev)); AIC_BREAK(); goto reset; } @@ -1873,7 +1878,7 @@ if (sc->sc_state != AIC_IDLE) { printf("%s: BUS FREE while not idle; " "state=%d\n", - device_xname(&sc->sc_dev), sc->sc_state); + device_xname(sc->sc_dev), sc->sc_state); AIC_BREAK(); goto out; } @@ -1949,7 +1954,8 @@ * disconnecting, and this is necessary to * clean up their state. */ - aprint_error_dev(&sc->sc_dev, "unexpected disconnect; " + aprint_error_dev(sc->sc_dev, + "unexpected disconnect; " "sending REQUEST SENSE\n"); AIC_BREAK(); aic_sense(sc, acb); @@ -2055,7 +2061,7 @@ goto loop; } - aprint_error_dev(&sc->sc_dev, "unexpected bus phase; resetting\n"); + aprint_error_dev(sc->sc_dev, "unexpected bus phase; resetting\n"); AIC_BREAK(); reset: aic_init(sc, 1); @@ -2106,7 +2112,7 @@ struct scsipi_xfer *xs = acb->xs; struct scsipi_periph *periph = xs->xs_periph; struct aic_softc *sc = - (void *)periph->periph_channel->chan_adapter->adapt_dev; + device_private(periph->periph_channel->chan_adapter->adapt_dev); int s; scsipi_printaddr(periph); Index: src/sys/dev/ic/aic6360var.h diff -u src/sys/dev/ic/aic6360var.h:1.14 src/sys/dev/ic/aic6360var.h:1.15 --- src/sys/dev/ic/aic6360var.h:1.14 Tue May 12 14:25:17 2009 +++ src/sys/dev/ic/aic6360var.h Tue Sep 22 12:56:06 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: aic6360var.h,v 1.14 2009/05/12 14:25:17 cegger Exp $ */ +/* $NetBSD: aic6360var.h,v 1.15 2009/09/22 12:56:06 tsutsui Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Charles M. Hannum. All rights reserved. @@ -115,7 +115,7 @@ }; struct aic_softc { - struct device sc_dev; + device_t sc_dev; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; @@ -199,7 +199,7 @@ #define AIC_ASSERT(x) do { \ if (! (x)) { \ printf("%s at line %d: assertion failed\n", \ - device_xname(&sc->sc_dev), __LINE__); \ + device_xname(sc->sc_dev), __LINE__); \ Debugger(); \ } } while (/* CONSTCOND */ 0) #else Index: src/sys/dev/isa/aic_isa.c diff -u src/sys/dev/isa/aic_isa.c:1.23 src/sys/dev/isa/aic_isa.c:1.24 --- src/sys/dev/isa/aic_isa.c:1.23 Tue May 12 09:10:15 2009 +++ src/sys/dev/isa/aic_isa.c Tue Sep 22 12:56:06 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: aic_isa.c,v 1.23 2009/05/12 09:10:15 cegger Exp $ */ +/* $NetBSD: aic_isa.c,v 1.24 2009/09/22 12:56:06 tsutsui Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Charles M. Hannum. All rights reserved. @@ -51,7 +51,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aic_isa.c,v 1.23 2009/05/12 09:10:15 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aic_isa.c,v 1.24 2009/09/22 12:56:06 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -85,7 +85,7 @@ void *sc_ih; /* interrupt handler */ }; -CFATTACH_DECL(aic_isa, sizeof(struct aic_isa_softc), +CFATTACH_DECL_NEW(aic_isa, sizeof(struct aic_isa_softc), aic_isa_probe, aic_isa_attach, NULL, NULL); @@ -144,30 +144,32 @@ aic_isa_attach(device_t parent, device_t self, void *aux) { struct isa_attach_args *ia = aux; - struct aic_isa_softc *isc = (void *)self; + struct aic_isa_softc *isc = device_private(self); struct aic_softc *sc = &isc->sc_aic; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; isa_chipset_tag_t ic = ia->ia_ic; + sc->sc_dev = self; + printf("\n"); if (bus_space_map(iot, ia->ia_io[0].ir_addr, AIC_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; } sc->sc_iot = iot; sc->sc_ioh = ioh; if (!aic_find(iot, ioh)) { - aprint_error_dev(&sc->sc_dev, "aic_find failed"); + aprint_error_dev(self, "aic_find failed\n"); return; } isc->sc_ih = isa_intr_establish(ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_BIO, aicintr, sc); if (isc->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/aic_isapnp.c diff -u src/sys/dev/isapnp/aic_isapnp.c:1.19 src/sys/dev/isapnp/aic_isapnp.c:1.20 --- src/sys/dev/isapnp/aic_isapnp.c:1.19 Tue May 12 10:16:35 2009 +++ src/sys/dev/isapnp/aic_isapnp.c Tue Sep 22 12:56:06 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: aic_isapnp.c,v 1.19 2009/05/12 10:16:35 cegger Exp $ */ +/* $NetBSD: aic_isapnp.c,v 1.20 2009/09/22 12:56:06 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aic_isapnp.c,v 1.19 2009/05/12 10:16:35 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aic_isapnp.c,v 1.20 2009/09/22 12:56:06 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -60,7 +60,7 @@ int aic_isapnp_match(device_t, cfdata_t, void *); void aic_isapnp_attach(device_t, device_t, void *); -CFATTACH_DECL(aic_isapnp, sizeof(struct aic_isapnp_softc), +CFATTACH_DECL_NEW(aic_isapnp, sizeof(struct aic_isapnp_softc), aic_isapnp_match, aic_isapnp_attach, NULL, NULL); int @@ -81,10 +81,12 @@ struct aic_softc *sc = &isc->sc_aic; 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; } @@ -92,7 +94,7 @@ sc->sc_ioh = ipa->ipa_io[0].h; if (!aic_find(sc->sc_iot, sc->sc_ioh)) { - aprint_error_dev(&sc->sc_dev, "couldn't find device\n"); + aprint_error_dev(self, "couldn't find device\n"); return; } @@ -102,5 +104,5 @@ isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num, ipa->ipa_irq[0].type, IPL_BIO, aicintr, sc); if (isc->sc_ih == NULL) - aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n"); + aprint_error_dev(self, "couldn't establish interrupt\n"); } Index: src/sys/dev/pcmcia/aic_pcmcia.c diff -u src/sys/dev/pcmcia/aic_pcmcia.c:1.40 src/sys/dev/pcmcia/aic_pcmcia.c:1.41 --- src/sys/dev/pcmcia/aic_pcmcia.c:1.40 Tue May 12 14:42:18 2009 +++ src/sys/dev/pcmcia/aic_pcmcia.c Tue Sep 22 12:56:06 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: aic_pcmcia.c,v 1.40 2009/05/12 14:42:18 cegger Exp $ */ +/* $NetBSD: aic_pcmcia.c,v 1.41 2009/09/22 12:56:06 tsutsui Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aic_pcmcia.c,v 1.40 2009/05/12 14:42:18 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aic_pcmcia.c,v 1.41 2009/09/22 12:56:06 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -68,7 +68,7 @@ int aic_pcmcia_detach(device_t, int); int aic_pcmcia_enable(device_t, int); -CFATTACH_DECL(aic_pcmcia, sizeof(struct aic_pcmcia_softc), +CFATTACH_DECL_NEW(aic_pcmcia, sizeof(struct aic_pcmcia_softc), aic_pcmcia_match, aic_pcmcia_attach, aic_pcmcia_detach, aic_activate); const struct pcmcia_product aic_pcmcia_products[] = { @@ -85,8 +85,7 @@ sizeof(aic_pcmcia_products) / sizeof(aic_pcmcia_products[0]); int -aic_pcmcia_match(device_t parent, cfdata_t match, - void *aux) +aic_pcmcia_match(device_t parent, cfdata_t match, void *aux) { struct pcmcia_attach_args *pa = aux; @@ -107,16 +106,16 @@ } void -aic_pcmcia_attach(device_t parent, device_t self, - void *aux) +aic_pcmcia_attach(device_t parent, device_t self, void *aux) { - struct aic_pcmcia_softc *psc = (void *)self; + struct aic_pcmcia_softc *psc = device_private(self); struct aic_softc *sc = &psc->sc_aic; struct pcmcia_attach_args *pa = aux; struct pcmcia_config_entry *cfe; struct pcmcia_function *pf = pa->pf; int error; + sc->sc_dev = self; psc->sc_pf = pf; error = pcmcia_function_configure(pf, aic_pcmcia_validate_config); @@ -157,17 +156,17 @@ int aic_pcmcia_detach(device_t self, int flags) { - struct aic_pcmcia_softc *sc = (void *)self; + struct aic_pcmcia_softc *psc = device_private(self); int error; - if (sc->sc_state != AIC_PCMCIA_ATTACHED) + if (psc->sc_state != AIC_PCMCIA_ATTACHED) return (0); error = aic_detach(self, flags); if (error) return (error); - pcmcia_function_unconfigure(sc->sc_pf); + pcmcia_function_unconfigure(psc->sc_pf); return (0); } @@ -175,29 +174,30 @@ int aic_pcmcia_enable(device_t self, int onoff) { - struct aic_pcmcia_softc *sc = (void *)self; + struct aic_pcmcia_softc *psc = device_private(self); + struct aic_softc *sc = &psc->sc_aic; int error; if (onoff) { /* Establish the interrupt handler. */ - sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO, - aicintr, &sc->sc_aic); - if (!sc->sc_ih) + psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_BIO, + aicintr, sc); + if (!psc->sc_ih) return (EIO); - error = pcmcia_function_enable(sc->sc_pf); + error = pcmcia_function_enable(psc->sc_pf); if (error) { - pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); - sc->sc_ih = 0; + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); + psc->sc_ih = 0; return (error); } /* Initialize only chip. */ - aic_init(&sc->sc_aic, 0); + aic_init(sc, 0); } else { - pcmcia_function_disable(sc->sc_pf); - pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); - sc->sc_ih = 0; + pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); + psc->sc_ih = 0; } return (0);