Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Split device_t/softc. Tested only on cs at ofisa on shark.



details:   https://anonhg.NetBSD.org/src/rev/297cdddc1e75
branches:  trunk
changeset: 747594:297cdddc1e75
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue Sep 22 14:55:19 2009 +0000

description:
Split device_t/softc.  Tested only on cs at ofisa on shark.

diffstat:

 sys/arch/acorn32/eb7500atx/if_cs.c        |   32 +++---
 sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c |   17 ++-
 sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c |   37 ++++----
 sys/dev/ic/cs89x0.c                       |  124 +++++++++++++++++------------
 sys/dev/ic/cs89x0var.h                    |    4 +-
 sys/dev/isa/if_cs_isa.c                   |   19 ++--
 sys/dev/isa/if_tscs_isa.c                 |   15 +-
 sys/dev/isapnp/if_cs_isapnp.c             |   21 +++-
 sys/dev/ofisa/if_cs_ofisa.c               |   17 ++-
 9 files changed, 162 insertions(+), 124 deletions(-)

diffs (truncated from 1012 to 300 lines):

diff -r a31808ff987a -r 297cdddc1e75 sys/arch/acorn32/eb7500atx/if_cs.c
--- a/sys/arch/acorn32/eb7500atx/if_cs.c        Tue Sep 22 14:49:46 2009 +0000
+++ b/sys/arch/acorn32/eb7500atx/if_cs.c        Tue Sep 22 14:55:19 2009 +0000
@@ -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;
        }
 
diff -r a31808ff987a -r 297cdddc1e75 sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c
--- a/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c Tue Sep 22 14:49:46 2009 +0000
+++ b/sys/arch/evbarm/smdk2xx0/if_cs_smdk24x0.c Tue Sep 22 14:55:19 2009 +0000
@@ -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;
diff -r a31808ff987a -r 297cdddc1e75 sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c
--- a/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c Tue Sep 22 14:49:46 2009 +0000
+++ b/sys/arch/evbppc/pmppc/dev/if_cs_mainbus.c Tue Sep 22 14:55:19 2009 +0000
@@ -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", 



Home | Main Index | Thread Index | Old Index