Module Name: src Committed By: tsutsui Date: Tue Sep 22 14:55:20 UTC 2009
Modified Files: src/sys/arch/acorn32/eb7500atx: if_cs.c src/sys/arch/evbarm/smdk2xx0: if_cs_smdk24x0.c src/sys/arch/evbppc/pmppc/dev: if_cs_mainbus.c src/sys/dev/ic: cs89x0.c cs89x0var.h src/sys/dev/isa: if_cs_isa.c if_tscs_isa.c src/sys/dev/isapnp: if_cs_isapnp.c src/sys/dev/ofisa: if_cs_ofisa.c Log Message: Split device_t/softc. Tested only on cs at ofisa on shark. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/acorn32/eb7500atx/if_cs.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/cs89x0.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/cs89x0var.h cvs rdiff -u -r1.23 -r1.24 src/sys/dev/isa/if_cs_isa.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/isa/if_tscs_isa.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/isapnp/if_cs_isapnp.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ofisa/if_cs_ofisa.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/arch/acorn32/eb7500atx/if_cs.c diff -u src/sys/arch/acorn32/eb7500atx/if_cs.c:1.5 src/sys/arch/acorn32/eb7500atx/if_cs.c:1.6 --- src/sys/arch/acorn32/eb7500atx/if_cs.c:1.5 Tue May 12 06:57:51 2009 +++ src/sys/arch/acorn32/eb7500atx/if_cs.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs.c,v 1.5 2009/05/12 06:57:51 cegger Exp $ */ +/* $NetBSD: if_cs.c,v 1.6 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright (c) 2004 Christopher Gilbert @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.5 2009/05/12 06:57:51 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.6 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -116,12 +116,12 @@ */ static struct bus_space cs_rsbus_bs_tag; -int cs_rsbus_probe(struct device *, struct cfdata *, void *); -void cs_rsbus_attach(struct device *, struct device *, void *); +int cs_rsbus_probe(device_t, cfdata_t, void *); +void cs_rsbus_attach(device_t, device_t, void *); static u_int8_t cs_rbus_read_1(struct cs_softc *, bus_size_t); -CFATTACH_DECL(cs_rsbus, sizeof(struct cs_softc), +CFATTACH_DECL_NEW(cs_rsbus, sizeof(struct cs_softc), cs_rsbus_probe, cs_rsbus_attach, NULL, NULL); /* Available media */ @@ -131,19 +131,21 @@ }; int -cs_rsbus_probe(struct device *parent, struct cfdata *cf, void *aux) +cs_rsbus_probe(device_t parent, cfdata_t cf, void *aux) { /* for now it'll always attach */ return 1; } void -cs_rsbus_attach(struct device *parent, struct device *self, void *aux) +cs_rsbus_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = (struct cs_softc *)self; - struct rsbus_attach_args *rs = (void *)aux; + struct cs_softc *sc = device_private(self); + struct rsbus_attach_args *rs = aux; u_int iobase; + sc->sc_dev = self; + /* member copy */ cs_rsbus_bs_tag = *rs->sa_iot; @@ -152,13 +154,12 @@ sc->sc_iot = sc->sc_memt = &cs_rsbus_bs_tag; - /* - * Do DMA later +#if 0 /* Do DMA later */ if (ia->ia_ndrq > 0) isc->sc_drq = ia->ia_drq[0].ir_drq; else isc->sc_drq = -1; - */ +#endif /* device always interrupts on 3 but that routes to IRQ 5 */ sc->sc_irq = 3; @@ -171,15 +172,14 @@ iobase = 0x03010600; if (bus_space_map(sc->sc_iot, iobase, CS8900_IOSIZE * 4, 0, &sc->sc_ioh)) { - printf("%s: unable to map i/o space\n", device_xname(&sc->sc_dev)); + printf("%s: unable to map i/o space\n", device_xname(self)); return; } #if 0 if (bus_space_map(sc->sc_memt, iobase + 0x3A00, CS8900_MEMSIZE * 4, 0, &sc->sc_memh)) { - printf("%s: unable to map memory space\n", - device_xname(&sc->sc_dev)); + printf("%s: unable to map memory space\n", device_xname(self)); } else { sc->sc_cfgflags |= CFGFLG_MEM_MODE | CFGFLG_USE_SA; sc->sc_pktpgaddr = 1<<23; @@ -189,7 +189,7 @@ sc->sc_ih = intr_claim(IRQ_INT5, IPL_NET, "cs", cs_intr, sc); if (sc->sc_ih == NULL) { printf("%s: unable to establish interrupt\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); return; } Index: src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c diff -u src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c:1.2 src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c:1.3 --- src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c:1.2 Sun Dec 11 12:17:09 2005 +++ src/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_smdk24x0.c,v 1.2 2005/12/11 12:17:09 christos Exp $ */ +/* $NetBSD: if_cs_smdk24x0.c,v 1.3 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright (c) 2003 Genetec corporation. All rights reserved. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_smdk24x0.c,v 1.2 2005/12/11 12:17:09 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_smdk24x0.c,v 1.3 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -100,8 +100,8 @@ #include "locators.h" #include "opt_smdk2xx0.h" /* SMDK24X0_ETHER_ADDR_FIXED */ -int cs_ssextio_probe(struct device *, struct cfdata *, void *); -void cs_ssextio_attach(struct device *, struct device *, void *); +int cs_ssextio_probe(device_t, cfdata_t, void *); +void cs_ssextio_attach(device_t, device_t, void *); /* * I/O access is done when A24==1. @@ -109,11 +109,11 @@ */ #define IOADDR(base) (base + (1<<24) + 0x0300) -CFATTACH_DECL(cs_ssextio, sizeof(struct cs_softc), +CFATTACH_DECL_NEW(cs_ssextio, sizeof(struct cs_softc), cs_ssextio_probe, cs_ssextio_attach, NULL, NULL); int -cs_ssextio_probe(struct device *parent, struct cfdata *cf, void *aux) +cs_ssextio_probe(device_t parent, cfdata_t cf, void *aux) { struct s3c2xx0_attach_args *sa = aux; bus_space_tag_t iot = sa->sa_iot; @@ -182,9 +182,9 @@ }; void -cs_ssextio_attach(struct device *parent, struct device *self, void *aux) +cs_ssextio_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = (struct cs_softc *) self; + struct cs_softc *sc = device_private(self); struct s3c2xx0_attach_args *sa = aux; vaddr_t ioaddr; #ifdef SMDK24X0_ETHER_ADDR_FIXED @@ -193,6 +193,7 @@ #define enaddr NULL #endif + sc->sc_dev = self; sc->sc_iot = sc->sc_memt = sa->sa_iot; /* sc_irq is an IRQ number in ISA world. set 10 for INTRQ0 of CS8900A */ sc->sc_irq = 10; Index: src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c diff -u src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c:1.3 src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c:1.4 --- src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c:1.3 Mon Apr 28 20:23:17 2008 +++ src/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_mainbus.c,v 1.3 2008/04/28 20:23:17 martin Exp $ */ +/* $NetBSD: if_cs_mainbus.c,v 1.4 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_mainbus.c,v 1.3 2008/04/28 20:23:17 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_mainbus.c,v 1.4 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -68,11 +68,11 @@ static int cs_mainbus_match(struct device *, struct cfdata *, void *); static void cs_mainbus_attach(struct device *, struct device *, void *); -CFATTACH_DECL(cs_mainbus, sizeof(struct cs_softc), +CFATTACH_DECL_NEW(cs_mainbus, sizeof(struct cs_softc), cs_mainbus_match, cs_mainbus_attach, NULL, NULL); int -cs_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) +cs_mainbus_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *maa = aux; @@ -238,21 +238,22 @@ } void -cs_mainbus_attach(struct device *parent, struct device *self, void *aux) +cs_mainbus_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = (struct cs_softc *)self; + struct cs_softc *sc = device_private(self); struct mainbus_attach_args *maa = aux; int media[1] = { IFM_ETHER | IFM_10_T }; printf("\n"); + sc->sc_dev = self; sc->sc_iot = maa->mb_bt; sc->sc_memt = maa->mb_bt; sc->sc_irq = maa->mb_irq; if (bus_space_map(sc->sc_iot, PMPPC_CS_IO, CS8900_IOSIZE*4, 0, &sc->sc_ioh)) { - printf("%s: failed to map io\n", self->dv_xname); + printf("%s: failed to map io\n", device_xname(self)); return; } @@ -261,7 +262,7 @@ sc->sc_ih = intr_establish(sc->sc_irq, IST_LEVEL, IPL_NET, cs_intr, sc); if (!sc->sc_ih) { printf("%s: unable to establish interrupt\n", - self->dv_xname); + device_xname(self)); goto fail; } @@ -285,7 +286,7 @@ /* Use half duplex 10baseT. */ if (cs_attach(sc, NULL, media, 1, IFM_ETHER | IFM_10_T)) { - printf("%s: unable to attach\n", self->dv_xname); + printf("%s: unable to attach\n", device_xname(self)); goto fail; } @@ -348,7 +349,8 @@ /* Check to make sure EEPROM is ready. */ if (!cs_wait_eeprom_ready(sc)) { - printf("%s: write EEPROM not ready\n", sc->sc_dev.dv_xname); + printf("%s: write EEPROM not ready\n", + device_xname(sc->sc_dev)); return; } @@ -357,7 +359,8 @@ /* Wait for WRITE_ENABLE command to complete. */ if (!cs_wait_eeprom_ready(sc)) { - printf("%s: EEPROM WRITE_ENABLE timeout", sc->sc_dev.dv_xname); + printf("%s: EEPROM WRITE_ENABLE timeout", + device_xname(sc->sc_dev)); } else { /* Write data into EEPROM_DATA register. */ cs_writereg(sc, PKTPG_EEPROM_DATA, data); @@ -367,7 +370,7 @@ /* Wait for WRITE_REGISTER command to complete. */ if (!cs_wait_eeprom_ready(sc)) { printf("%s: EEPROM WRITE_REGISTER timeout\n", - sc->sc_dev.dv_xname); + device_xname(sc->sc_dev)); } } @@ -376,7 +379,7 @@ /* Wait for WRITE_DISABLE command to complete. */ if (!cs_wait_eeprom_ready(sc)) { - printf("%s: WRITE_DISABLE timeout\n", sc->sc_dev.dv_xname); + printf("%s: WRITE_DISABLE timeout\n", device_xname(sc->sc_dev)); } } @@ -385,13 +388,13 @@ { if (!cs_wait_eeprom_ready(sc)) { - printf("%s: read EEPROM not ready\n", sc->sc_dev.dv_xname); + printf("%s: read EEPROM not ready\n", device_xname(sc->sc_dev)); return 0; } cs_writereg(sc, PKTPG_EEPROM_CMD, EEPROM_CMD_READ | offset); if (!cs_wait_eeprom_ready(sc)) { - printf("%s: EEPROM_READ timeout\n", sc->sc_dev.dv_xname); + printf("%s: EEPROM_READ timeout\n", device_xname(sc->sc_dev)); return 0; } return cs_readreg(sc, PKTPG_EEPROM_DATA); @@ -410,10 +413,10 @@ */ if (cs_readreg(sc, PKTPG_SELF_ST) & SELF_ST_EEP_OK) { printf("%s: EEPROM OK, skipping initialization\n", - sc->sc_dev.dv_xname); + device_xname(sc->sc_dev)); return; } - printf("%s: updating EEPROM\n", sc->sc_dev.dv_xname); + printf("%s: updating EEPROM\n", device_xname(sc->sc_dev)); /* * Calculate the size (in bytes) of the default config array and write Index: src/sys/dev/ic/cs89x0.c diff -u src/sys/dev/ic/cs89x0.c:1.25 src/sys/dev/ic/cs89x0.c:1.26 --- src/sys/dev/ic/cs89x0.c:1.25 Tue Sep 22 13:31:26 2009 +++ src/sys/dev/ic/cs89x0.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cs89x0.c,v 1.25 2009/09/22 13:31:26 tsutsui Exp $ */ +/* $NetBSD: cs89x0.c,v 1.26 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright (c) 2004 Christopher Gilbert @@ -212,7 +212,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.25 2009/09/22 13:31:26 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.26 2009/09/22 14:55:19 tsutsui Exp $"); #include "opt_inet.h" @@ -354,7 +354,7 @@ } } if (i == 10000) { - aprint_error_dev(&sc->sc_dev, "wrong id(0x%x)\n", reg); + aprint_error_dev(sc->sc_dev, "wrong id(0x%x)\n", reg); return 1; /* XXX should panic? */ } @@ -389,7 +389,7 @@ if (MCLBYTES < ETHER_MAX_LEN + 1 + ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header)) { printf("%s: MCLBYTES too small for Ethernet frame\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); return 1; } @@ -401,7 +401,7 @@ sc->sc_xe_togo = cs_xmit_early_table[sc->sc_xe_ent].better_count; /* Initialize ifnet structure. */ - strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); + strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); ifp->if_softc = sc; ifp->if_start = cs_start_output; ifp->if_init = cs_init; @@ -429,7 +429,7 @@ if (sc->sc_cfgflags & CFGFLG_PARSE_EEPROM) { if (cs_scan_eeprom(sc) == CS_ERROR) { /* failed to scan the eeprom, pretend there isn't an eeprom */ - aprint_error_dev(&sc->sc_dev, "unable to scan EEPROM\n"); + aprint_error_dev(sc->sc_dev, "unable to scan EEPROM\n"); sc->sc_cfgflags |= CFGFLG_NOT_EEPROM; } } @@ -437,7 +437,8 @@ if ((sc->sc_cfgflags & CFGFLG_NOT_EEPROM) == 0) { /* Get parameters from the EEPROM */ if (cs_get_params(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "unable to get settings from EEPROM\n"); + aprint_error_dev(sc->sc_dev, + "unable to get settings from EEPROM\n"); return 1; } } @@ -447,7 +448,8 @@ else if ((sc->sc_cfgflags & CFGFLG_NOT_EEPROM) == 0) { /* Get and store the Ethernet address */ if (cs_get_enaddr(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "unable to read Ethernet address\n"); + aprint_error_dev(sc->sc_dev, + "unable to read Ethernet address\n"); return 1; } } else { @@ -461,7 +463,7 @@ sc->sc_enaddr[j + 1] = v >> 8; } #else - printf("%s: no Ethernet address!\n", device_xname(&sc->sc_dev)); + printf("%s: no Ethernet address!\n", device_xname(sc->sc_dev)); return 1; #endif } @@ -482,7 +484,8 @@ default: panic("cs_attach: impossible"); } - printf("%s: %s rev. %c, address %s, media %s\n", device_xname(&sc->sc_dev), + printf("%s: %s rev. %c, address %s, media %s\n", + device_xname(sc->sc_dev), chipname, sc->sc_prodrev + 'A', ether_sprintf(sc->sc_enaddr), medname); @@ -494,20 +497,20 @@ ether_ifattach(ifp, sc->sc_enaddr); #if NRND > 0 - rnd_attach_source(&sc->rnd_source, device_xname(&sc->sc_dev), + rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev), RND_TYPE_NET, 0); #endif sc->sc_cfgflags |= CFGFLG_ATTACHED; - if (pmf_device_register1(&sc->sc_dev, NULL, NULL, cs_shutdown)) - pmf_class_network_register(&sc->sc_dev, ifp); + if (pmf_device_register1(sc->sc_dev, NULL, NULL, cs_shutdown)) + pmf_class_network_register(sc->sc_dev, ifp); else - aprint_error_dev(&sc->sc_dev, + aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); /* Reset the chip */ if (cs_reset_chip(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "reset failed\n"); + aprint_error_dev(sc->sc_dev, "reset failed\n"); cs_detach(sc); return 1; } @@ -541,7 +544,7 @@ } #endif - pmf_device_deregister(&sc->sc_dev); + pmf_device_deregister(sc->sc_dev); return 0; } @@ -563,17 +566,20 @@ u_int16_t adp_cfg, xmit_ctl; if (cs_verify_eeprom(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "cs_get_default_media: EEPROM missing or bad\n"); + aprint_error_dev(sc->sc_dev, + "cs_get_default_media: EEPROM missing or bad\n"); goto fakeit; } if (cs_read_eeprom(sc, EEPROM_ADPTR_CFG, &adp_cfg) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "unable to read adapter config from EEPROM\n"); + aprint_error_dev(sc->sc_dev, + "unable to read adapter config from EEPROM\n"); goto fakeit; } if (cs_read_eeprom(sc, EEPROM_XMIT_CTL, &xmit_ctl) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "unable to read transmit control from EEPROM\n"); + aprint_error_dev(sc->sc_dev, + "unable to read transmit control from EEPROM\n"); goto fakeit; } @@ -595,7 +601,8 @@ return; fakeit: - aprint_error_dev(&sc->sc_dev, "WARNING: default media setting may be inaccurate\n"); + aprint_error_dev(sc->sc_dev, + "WARNING: default media setting may be inaccurate\n"); /* XXX Arbitrary... */ ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_10_T); } @@ -618,7 +625,8 @@ u_int8_t checksum = 0; if (cs_verify_eeprom(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "cs_scan_params: EEPROM missing or bad\n"); + aprint_error_dev(sc->sc_dev, + "cs_scan_params: EEPROM missing or bad\n"); return (CS_ERROR); } @@ -661,7 +669,7 @@ * sum to that point. */ if (checksum != 0) { - aprint_error_dev(&sc->sc_dev, "eeprom checksum failure\n"); + aprint_error_dev(sc->sc_dev, "eeprom checksum failure\n"); return (CS_ERROR); } @@ -741,7 +749,8 @@ u_int16_t adapterConfig; if (cs_verify_eeprom(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "cs_get_params: EEPROM missing or bad\n"); + aprint_error_dev(sc->sc_dev, + "cs_get_params: EEPROM missing or bad\n"); return (CS_ERROR); } @@ -795,7 +804,8 @@ return (CS_OK); eeprom_bad: - aprint_error_dev(&sc->sc_dev, "cs_get_params: unable to read from EEPROM\n"); + aprint_error_dev(sc->sc_dev, + "cs_get_params: unable to read from EEPROM\n"); return (CS_ERROR); } @@ -805,7 +815,8 @@ u_int16_t *myea; if (cs_verify_eeprom(sc) == CS_ERROR) { - aprint_error_dev(&sc->sc_dev, "cs_get_enaddr: EEPROM missing or bad\n"); + aprint_error_dev(sc->sc_dev, + "cs_get_enaddr: EEPROM missing or bad\n"); return (CS_ERROR); } @@ -835,7 +846,8 @@ return (CS_OK); eeprom_bad: - aprint_error_dev(&sc->sc_dev, "cs_get_enaddr: unable to read from EEPROM\n"); + aprint_error_dev(sc->sc_dev, + "cs_get_enaddr: unable to read from EEPROM\n"); return (CS_ERROR); } @@ -1101,7 +1113,8 @@ * chip in memory mode. */ if (isaId != EISA_NUM_CRYSTAL) { - aprint_error_dev(&sc->sc_dev, "failed to enable memory mode\n"); + aprint_error_dev(sc->sc_dev, + "failed to enable memory mode\n"); sc->sc_memorymode = FALSE; } else { /* @@ -1188,7 +1201,7 @@ /* Assume we have carrier until we are told otherwise. */ sc->sc_carrier = 1; } else { - aprint_error_dev(&sc->sc_dev, "unable to reset chip\n"); + aprint_error_dev(sc->sc_dev, "unable to reset chip\n"); } splx(intState); @@ -1310,7 +1323,7 @@ cs_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct cs_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *) data; + struct ifreq *ifr = data; int state; int result; @@ -1387,7 +1400,7 @@ /* Ignore any interrupts that happen while the chip is being reset */ if (sc->sc_resetting) { printf("%s: cs_intr: reset in progress\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); return 1; } @@ -1423,7 +1436,7 @@ break; default: printf("%s: unknown interrupt event 0x%x\n", - device_xname(&sc->sc_dev), Event); + device_xname(sc->sc_dev), Event); break; } @@ -1503,7 +1516,7 @@ (*sc->sc_dma_process_rx)(sc); else /* should panic? */ - aprint_error_dev(&sc->sc_dev, "unexpected DMA event\n"); + aprint_error_dev(sc->sc_dev, "unexpected DMA event\n"); } if (bufEvent & BUF_EVENT_TX_UNDR) { @@ -1513,7 +1526,7 @@ * about. */ printf("%s: transmit underrun (%d -> %d)\n", - device_xname(&sc->sc_dev), sc->sc_xe_ent, + device_xname(sc->sc_dev), sc->sc_xe_ent, cs_xmit_early_table[sc->sc_xe_ent].worse); #endif sc->sc_xe_ent = cs_xmit_early_table[sc->sc_xe_ent].worse; @@ -1526,7 +1539,7 @@ if (bufEvent & BUF_EVENT_SW_INT) { printf("%s: software initiated interrupt\n", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); } } @@ -1548,19 +1561,20 @@ /* If debugging is enabled then log error messages */ if (ifp->if_flags & IFF_DEBUG) { if (txEvent & TX_EVENT_LOSS_CRS) { - aprint_error_dev(&sc->sc_dev, "lost carrier\n"); + aprint_error_dev(sc->sc_dev, "lost carrier\n"); } if (txEvent & TX_EVENT_SQE_ERR) { - aprint_error_dev(&sc->sc_dev, "SQE error\n"); + aprint_error_dev(sc->sc_dev, "SQE error\n"); } if (txEvent & TX_EVENT_OUT_WIN) { - aprint_error_dev(&sc->sc_dev, "out-of-window collision\n"); + aprint_error_dev(sc->sc_dev, + "out-of-window collision\n"); } if (txEvent & TX_EVENT_JABBER) { - aprint_error_dev(&sc->sc_dev, "jabber\n"); + aprint_error_dev(sc->sc_dev, "jabber\n"); } if (txEvent & TX_EVENT_16_COLL) { - aprint_error_dev(&sc->sc_dev, "16 collisions\n"); + aprint_error_dev(sc->sc_dev, "16 collisions\n"); } } } @@ -1596,19 +1610,19 @@ { if (rxEvent & RX_EVENT_RUNT) - aprint_error_dev(&sc->sc_dev, "runt\n"); + aprint_error_dev(sc->sc_dev, "runt\n"); if (rxEvent & RX_EVENT_X_DATA) - aprint_error_dev(&sc->sc_dev, "extra data\n"); + aprint_error_dev(sc->sc_dev, "extra data\n"); if (rxEvent & RX_EVENT_CRC_ERR) { if (rxEvent & RX_EVENT_DRIBBLE) - aprint_error_dev(&sc->sc_dev, "alignment error\n"); + aprint_error_dev(sc->sc_dev, "alignment error\n"); else - aprint_error_dev(&sc->sc_dev, "CRC error\n"); + aprint_error_dev(sc->sc_dev, "CRC error\n"); } else { if (rxEvent & RX_EVENT_DRIBBLE) - aprint_error_dev(&sc->sc_dev, "dribble bits\n"); + aprint_error_dev(sc->sc_dev, "dribble bits\n"); } } @@ -1640,7 +1654,7 @@ CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG) | RX_CFG_SKIP); } else { - aprint_error_dev(&sc->sc_dev, "implied skip\n"); + aprint_error_dev(sc->sc_dev, "implied skip\n"); } } } else { @@ -1708,7 +1722,7 @@ } if (totlen > ETHER_MAX_LEN) { - aprint_error_dev(&sc->sc_dev, "invalid packet length %d\n", + aprint_error_dev(sc->sc_dev, "invalid packet length %d\n", totlen); /* skip the received frame */ @@ -1719,7 +1733,8 @@ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == 0) { - aprint_error_dev(&sc->sc_dev, "cs_process_receive: unable to allocate mbuf\n"); + aprint_error_dev(sc->sc_dev, + "cs_process_receive: unable to allocate mbuf\n"); ifp->if_ierrors++; /* * couldn't allocate an mbuf so things are not good, may as @@ -1747,7 +1762,9 @@ MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { /* couldn't allocate an mbuf cluster */ - aprint_error_dev(&sc->sc_dev, "cs_process_receive: unable to allocate a cluster\n"); + aprint_error_dev(sc->sc_dev, + "cs_process_receive: " + "unable to allocate a cluster\n"); m_freem(m); /* skip the received frame */ @@ -1798,7 +1815,8 @@ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == 0) { - aprint_error_dev(&sc->sc_dev, "cs_process_rx_early: unable to allocate mbuf\n"); + aprint_error_dev(sc->sc_dev, + "cs_process_rx_early: unable to allocate mbuf\n"); ifp->if_ierrors++; /* * couldn't allocate an mbuf so things are not good, may as @@ -1819,7 +1837,8 @@ MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { /* couldn't allocate an mbuf cluster */ - aprint_error_dev(&sc->sc_dev, "cs_process_rx_early: unable to allocate a cluster\n"); + aprint_error_dev(sc->sc_dev, + "cs_process_rx_early: unable to allocate a cluster\n"); m_freem(m); /* skip the frame */ CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CFG, @@ -1970,7 +1989,8 @@ * corrupt. */ if (BusStatus & BUS_ST_TX_BID_ERR) { - aprint_error_dev(&sc->sc_dev, "transmit bid error (too big)"); + aprint_error_dev(sc->sc_dev, + "transmit bid error (too big)"); /* Discard the bad mbuf chain */ m_freem(pMbufChain); @@ -2174,7 +2194,7 @@ int cs_activate(device_t self, enum devact act) { - struct cs_softc *sc = (void *)self; + struct cs_softc *sc = device_private(self); int s, error = 0; s = splnet(); Index: src/sys/dev/ic/cs89x0var.h diff -u src/sys/dev/ic/cs89x0var.h:1.13 src/sys/dev/ic/cs89x0var.h:1.14 --- src/sys/dev/ic/cs89x0var.h:1.13 Tue Sep 22 13:31:26 2009 +++ src/sys/dev/ic/cs89x0var.h Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cs89x0var.h,v 1.13 2009/09/22 13:31:26 tsutsui Exp $ */ +/* $NetBSD: cs89x0var.h,v 1.14 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright 1997 @@ -66,7 +66,7 @@ * its address, ... */ struct cs_softc { - struct device sc_dev; /* base device glue */ + device_t sc_dev; /* base device glue */ struct ethercom sc_ethercom; /* Ethernet common */ struct ifmedia sc_media; /* media control structures */ Index: src/sys/dev/isa/if_cs_isa.c diff -u src/sys/dev/isa/if_cs_isa.c:1.23 src/sys/dev/isa/if_cs_isa.c:1.24 --- src/sys/dev/isa/if_cs_isa.c:1.23 Tue Sep 22 14:04:56 2009 +++ src/sys/dev/isa/if_cs_isa.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_isa.c,v 1.23 2009/09/22 14:04:56 tsutsui Exp $ */ +/* $NetBSD: if_cs_isa.c,v 1.24 2009/09/22 14:55:19 tsutsui Exp $ */ /* * Copyright 1997 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_isa.c,v 1.23 2009/09/22 14:04:56 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_isa.c,v 1.24 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,7 +64,7 @@ int cs_isa_probe(device_t, cfdata_t, void *); void cs_isa_attach(device_t, device_t, void *); -CFATTACH_DECL(cs_isa, sizeof(struct cs_softc_isa), +CFATTACH_DECL_NEW(cs_isa, sizeof(struct cs_softc_isa), cs_isa_probe, cs_isa_attach, NULL, NULL); int @@ -215,10 +215,11 @@ void cs_isa_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = (struct cs_softc *) self; - struct cs_softc_isa *isc = (void *) self; + struct cs_softc_isa *isc = device_private(self); + struct cs_softc *sc = &isc->sc_cs; struct isa_attach_args *ia = aux; + sc->sc_dev = self; isc->sc_ic = ia->ia_ic; sc->sc_iot = ia->ia_iot; sc->sc_memt = ia->ia_memt; @@ -237,7 +238,7 @@ */ if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, CS8900_IOSIZE, 0, &sc->sc_ioh)) { - aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n"); + aprint_error_dev(self, "unable to map i/o space\n"); return; } @@ -245,7 +246,7 @@ * Validate IRQ. */ if (CS8900_IRQ_ISVALID(sc->sc_irq) == 0) { - aprint_error_dev(&sc->sc_dev, "invalid IRQ %d\n", sc->sc_irq); + aprint_error_dev(self, "invalid IRQ %d\n", sc->sc_irq); return; } @@ -259,7 +260,7 @@ CS8900_MEMBASE_ISVALID(ia->ia_iomem[0].ir_addr)) { if (bus_space_map(sc->sc_memt, ia->ia_iomem[0].ir_addr, CS8900_MEMSIZE, 0, &sc->sc_memh)) { - aprint_error_dev(&sc->sc_dev, "unable to map memory space\n"); + aprint_error_dev(self, "unable to map memory space\n"); } else { sc->sc_cfgflags |= CFGFLG_MEM_MODE; sc->sc_pktpgaddr = ia->ia_iomem[0].ir_addr; @@ -269,7 +270,7 @@ sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE, IPL_NET, cs_intr, sc); if (sc->sc_ih == NULL) { - aprint_error_dev(&sc->sc_dev, "unable to establish interrupt\n"); + aprint_error_dev(self, "unable to establish interrupt\n"); return; } Index: src/sys/dev/isa/if_tscs_isa.c diff -u src/sys/dev/isa/if_tscs_isa.c:1.12 src/sys/dev/isa/if_tscs_isa.c:1.13 --- src/sys/dev/isa/if_tscs_isa.c:1.12 Tue Sep 22 14:04:56 2009 +++ src/sys/dev/isa/if_tscs_isa.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tscs_isa.c,v 1.12 2009/09/22 14:04:56 tsutsui Exp $ */ +/* $NetBSD: if_tscs_isa.c,v 1.13 2009/09/22 14:55:19 tsutsui Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tscs_isa.c,v 1.12 2009/09/22 14:04:56 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tscs_isa.c,v 1.13 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -60,7 +60,7 @@ int tscs_isa_probe(device_t, cfdata_t, void *); void tscs_isa_attach(device_t, device_t, void *); -CFATTACH_DECL(tscs_isa, sizeof(struct cs_softc_isa), +CFATTACH_DECL_NEW(tscs_isa, sizeof(struct cs_softc_isa), tscs_isa_probe, tscs_isa_attach, NULL, NULL); int @@ -170,10 +170,11 @@ void tscs_isa_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = (struct cs_softc *) self; - struct cs_softc_isa *isc = (void *) self; + struct cs_softc_isa *isc = device_private(self); + struct cs_softc *sc = &isc->sc_cs; struct isa_attach_args *ia = aux; + sc->sc_dev = self; isc->sc_ic = ia->ia_ic; sc->sc_iot = ia->ia_iot; sc->sc_memt = ia->ia_memt; @@ -188,14 +189,14 @@ */ if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, CS8900_IOSIZE, 0, &sc->sc_ioh)) { - aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n"); + aprint_error_dev(self, "unable to map i/o space\n"); return; } sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE, IPL_NET, cs_intr, sc); if (sc->sc_ih == NULL) { - aprint_error_dev(&sc->sc_dev, "unable to establish interrupt\n"); + aprint_error_dev(self, "unable to establish interrupt\n"); return; } Index: src/sys/dev/isapnp/if_cs_isapnp.c diff -u src/sys/dev/isapnp/if_cs_isapnp.c:1.15 src/sys/dev/isapnp/if_cs_isapnp.c:1.16 --- src/sys/dev/isapnp/if_cs_isapnp.c:1.15 Tue May 12 10:16:35 2009 +++ src/sys/dev/isapnp/if_cs_isapnp.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_isapnp.c,v 1.15 2009/05/12 10:16:35 cegger Exp $ */ +/* $NetBSD: if_cs_isapnp.c,v 1.16 2009/09/22 14:55:19 tsutsui Exp $ */ /*- * Copyright (c)2001 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_isapnp.c,v 1.15 2009/05/12 10:16:35 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_isapnp.c,v 1.16 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -55,13 +55,18 @@ #include <dev/isapnp/isapnpvar.h> #include <dev/isapnp/isapnpdevs.h> -#define DEVNAME(sc) device_xname(&((sc)->sc_dev)) +#define DEVNAME(sc) device_xname((sc)->sc_dev) int cs_isapnp_match(device_t, cfdata_t, void *); void cs_isapnp_attach(device_t, device_t, void *); -CFATTACH_DECL(cs_isapnp, sizeof(struct cs_softc), +#ifdef notyet +CFATTACH_DECL_NEW(cs_isapnp, sizeof(struct cs_softc_isa), + cs_isapnp_match, cs_isapnp_attach, NULL, NULL); +#else +CFATTACH_DECL_NEW(cs_isapnp, sizeof(struct cs_softc), cs_isapnp_match, cs_isapnp_attach, NULL, NULL); +#endif int cs_isapnp_match(device_t parent, cfdata_t match, void *aux) @@ -77,13 +82,19 @@ void cs_isapnp_attach(device_t parent, device_t self, void *aux) { +#ifdef notyet + struct cs_softc_isa *isc = device_private(sc); + struct cs_softc *sc = &sc->sc_cs; +#else struct cs_softc *sc = device_private(self); +#endif struct isapnp_attach_args *ipa = aux; #ifdef notyet - struct cs_softc_isa *isc = (void *)sc; int i; #endif + sc->sc_dev = self; + printf("\n"); if (ipa->ipa_nio != 1 || ipa->ipa_nirq != 1 || ipa->ipa_ndrq) { Index: src/sys/dev/ofisa/if_cs_ofisa.c diff -u src/sys/dev/ofisa/if_cs_ofisa.c:1.22 src/sys/dev/ofisa/if_cs_ofisa.c:1.23 --- src/sys/dev/ofisa/if_cs_ofisa.c:1.22 Tue May 12 14:38:56 2009 +++ src/sys/dev/ofisa/if_cs_ofisa.c Tue Sep 22 14:55:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_ofisa.c,v 1.22 2009/05/12 14:38:56 cegger Exp $ */ +/* $NetBSD: if_cs_ofisa.c,v 1.23 2009/09/22 14:55:19 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa.c,v 1.22 2009/05/12 14:38:56 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa.c,v 1.23 2009/09/22 14:55:19 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -66,7 +66,7 @@ int cs_ofisa_match(device_t, cfdata_t, void *); void cs_ofisa_attach(device_t, device_t, void *); -CFATTACH_DECL(cs_ofisa, sizeof(struct cs_softc_isa), +CFATTACH_DECL_NEW(cs_ofisa, sizeof(struct cs_softc_isa), cs_ofisa_match, cs_ofisa_attach, NULL, NULL); int @@ -93,8 +93,8 @@ void cs_ofisa_attach(device_t parent, device_t self, void *aux) { - struct cs_softc *sc = device_private(self); - struct cs_softc_isa *isc = (void *)sc; + struct cs_softc_isa *isc = device_private(self); + struct cs_softc *sc = &isc->sc_cs; struct ofisa_attach_args *aa = aux; struct ofisa_reg_desc reg[2]; struct ofisa_intr_desc intr; @@ -105,6 +105,7 @@ const char *message = NULL; u_int8_t enaddr[6]; + sc->sc_dev = self; isc->sc_ic = aa->ic; sc->sc_iot = aa->iot; sc->sc_memt = aa->memt; @@ -232,17 +233,17 @@ printf("\n"); if (message != NULL) - printf("%s: %s\n", device_xname(&sc->sc_dev), message); + printf("%s: %s\n", device_xname(self), message); if (defmedia == -1) { - aprint_error_dev(&sc->sc_dev, "unable to get default media\n"); + aprint_error_dev(self, "unable to get default media\n"); defmedia = media[0]; /* XXX What to do? */ } sc->sc_ih = isa_intr_establish(isc->sc_ic, sc->sc_irq, intr.share, IPL_NET, cs_intr, sc); if (sc->sc_ih == NULL) { - aprint_error_dev(&sc->sc_dev, "unable to establish interrupt\n"); + aprint_error_dev(self, "unable to establish interrupt\n"); return; }