Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Fix mii_statchg to take a 'struct ifnet *' instead of de...
details: https://anonhg.NetBSD.org/src/rev/2e32afb6cd9c
branches: trunk
changeset: 780383:2e32afb6cd9c
user: matt <matt%NetBSD.org@localhost>
date: Sun Jul 22 14:32:49 2012 +0000
description:
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
diffstat:
sys/arch/arm/at91/at91emac.c | 21 +++--
sys/arch/arm/ep93xx/epe.c | 56 +++++++-------
sys/arch/arm/ep93xx/epevar.h | 4 +-
sys/arch/arm/gemini/if_gmc.c | 8 +-
sys/arch/arm/xscale/ixp425_if_npe.c | 129 ++++++++++++++++++---------------
sys/arch/evbppc/virtex/dev/if_temac.c | 10 +-
sys/arch/macppc/dev/if_bm.c | 10 +-
sys/arch/macppc/dev/if_gm.c | 10 +-
sys/arch/mips/alchemy/dev/if_aumac.c | 10 +-
sys/arch/mips/atheros/dev/if_ae.c | 10 +-
sys/arch/mips/ralink/ralink_eth.c | 10 +-
sys/arch/mips/sibyte/dev/sbmac.c | 10 +-
sys/arch/powerpc/ibm4xx/dev/if_emac.c | 15 +--
sys/arch/sgimips/mace/if_mec.c | 10 +-
sys/dev/ic/aic6915.c | 14 +-
sys/dev/ic/ax88190.c | 8 +-
sys/dev/ic/dl10019.c | 12 +-
sys/dev/ic/elink3.c | 10 +-
sys/dev/ic/elinkxl.c | 10 +-
sys/dev/ic/gem.c | 10 +-
sys/dev/ic/hme.c | 10 +-
sys/dev/ic/i82557.c | 8 +-
sys/dev/ic/lan9118.c | 10 +-
sys/dev/ic/mtd803.c | 8 +-
sys/dev/ic/rtl8169.c | 8 +-
sys/dev/ic/rtl81x9.c | 8 +-
sys/dev/ic/smc83c170.c | 12 +-
sys/dev/ic/smc91cxx.c | 10 +-
sys/dev/ic/tulip.c | 38 +++++-----
sys/dev/ic/tulipvar.h | 4 +-
sys/dev/marvell/if_gfe.c | 10 +-
sys/dev/marvell/if_mvgbe.c | 8 +-
sys/dev/mii/mii_physubr.c | 6 +-
sys/dev/mii/miivar.h | 5 +-
sys/dev/pci/if_age.c | 15 +--
sys/dev/pci/if_alc.c | 11 +-
sys/dev/pci/if_ale.c | 15 +--
sys/dev/pci/if_bce.c | 10 +-
sys/dev/pci/if_bge.c | 10 +-
sys/dev/pci/if_bnx.c | 10 +-
sys/dev/pci/if_cas.c | 10 +-
sys/dev/pci/if_et.c | 10 +-
sys/dev/pci/if_jme.c | 10 +-
sys/dev/pci/if_lii.c | 10 +-
sys/dev/pci/if_msk.c | 12 +-
sys/dev/pci/if_nfe.c | 10 +-
sys/dev/pci/if_pcn.c | 10 +-
sys/dev/pci/if_sip.c | 24 +++---
sys/dev/pci/if_sk.c | 16 ++--
sys/dev/pci/if_ste.c | 10 +-
sys/dev/pci/if_stge.c | 10 +-
sys/dev/pci/if_tl.c | 10 +-
sys/dev/pci/if_vge.c | 17 +--
sys/dev/pci/if_vr.c | 10 +-
sys/dev/pci/if_vte.c | 17 +--
sys/dev/pci/if_wm.c | 14 +-
sys/dev/pcmcia/if_xi.c | 8 +-
sys/dev/sbus/be.c | 12 +-
sys/dev/usb/if_aue.c | 16 ++--
sys/dev/usb/if_axe.c | 10 +-
sys/dev/usb/if_udav.c | 14 +--
sys/dev/usb/if_url.c | 15 +--
62 files changed, 430 insertions(+), 438 deletions(-)
diffs (truncated from 3126 to 300 lines):
diff -r 83da7a66ab2f -r 2e32afb6cd9c sys/arch/arm/at91/at91emac.c
--- a/sys/arch/arm/at91/at91emac.c Sun Jul 22 14:27:35 2012 +0000
+++ b/sys/arch/arm/at91/at91emac.c Sun Jul 22 14:32:49 2012 +0000
@@ -1,5 +1,5 @@
-/* $Id: at91emac.c,v 1.10 2011/07/01 19:31:17 dyoung Exp $ */
-/* $NetBSD: at91emac.c,v 1.10 2011/07/01 19:31:17 dyoung Exp $ */
+/* $Id: at91emac.c,v 1.11 2012/07/22 14:32:49 matt Exp $ */
+/* $NetBSD: at91emac.c,v 1.11 2012/07/22 14:32:49 matt Exp $ */
/*
* Copyright (c) 2007 Embedtronics Oy
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.10 2011/07/01 19:31:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.11 2012/07/22 14:32:49 matt Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -109,7 +109,7 @@
static void emac_mediastatus(struct ifnet *, struct ifmediareq *);
int emac_mii_readreg (device_t, int, int);
void emac_mii_writereg (device_t, int, int, int);
-void emac_statchg (device_t );
+void emac_statchg (struct ifnet *);
void emac_tick (void *);
static int emac_ifioctl (struct ifnet *, u_long, void *);
static void emac_ifstart (struct ifnet *);
@@ -118,7 +118,7 @@
static void emac_ifstop (struct ifnet *, int);
static void emac_setaddr (struct ifnet *);
-CFATTACH_DECL(at91emac, sizeof(struct emac_softc),
+CFATTACH_DECL_NEW(at91emac, sizeof(struct emac_softc),
emac_match, emac_attach, NULL, NULL);
#ifdef EMAC_DEBUG
@@ -526,7 +526,8 @@
{
struct emac_softc *sc;
- sc = (struct emac_softc *)self;
+ sc = device_private(self);
+
EMAC_WRITE(ETH_MAN, (ETH_MAN_HIGH | ETH_MAN_RW_RD
| ((phy << ETH_MAN_PHYA_SHIFT) & ETH_MAN_PHYA)
| ((reg << ETH_MAN_REGA_SHIFT) & ETH_MAN_REGA)
@@ -539,7 +540,9 @@
emac_mii_writereg(device_t self, int phy, int reg, int val)
{
struct emac_softc *sc;
- sc = (struct emac_softc *)self;
+
+ sc = device_private(self);
+
EMAC_WRITE(ETH_MAN, (ETH_MAN_HIGH | ETH_MAN_RW_WR
| ((phy << ETH_MAN_PHYA_SHIFT) & ETH_MAN_PHYA)
| ((reg << ETH_MAN_REGA_SHIFT) & ETH_MAN_REGA)
@@ -550,9 +553,9 @@
void
-emac_statchg(device_t self)
+emac_statchg(struct ifnet *ifp)
{
- struct emac_softc *sc = (struct emac_softc *)self;
+ struct emac_softc *sc = ifp->if_softc;
u_int32_t reg;
/*
diff -r 83da7a66ab2f -r 2e32afb6cd9c sys/arch/arm/ep93xx/epe.c
--- a/sys/arch/arm/ep93xx/epe.c Sun Jul 22 14:27:35 2012 +0000
+++ b/sys/arch/arm/ep93xx/epe.c Sun Jul 22 14:32:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: epe.c,v 1.26 2011/07/01 19:31:17 dyoung Exp $ */
+/* $NetBSD: epe.c,v 1.27 2012/07/22 14:32:50 matt Exp $ */
/*
* Copyright (c) 2004 Jesse Off
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.26 2011/07/01 19:31:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.27 2012/07/22 14:32:50 matt Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -98,15 +98,15 @@
#define CTRLPAGE_DMASYNC(x, y, z)
#endif /* ! EPE_FAST */
-static int epe_match(struct device *, struct cfdata *, void *);
-static void epe_attach(struct device *, struct device *, void *);
+static int epe_match(device_t , cfdata_t, void *);
+static void epe_attach(device_t, device_t, void *);
static void epe_init(struct epe_softc *);
static int epe_intr(void* arg);
static int epe_gctx(struct epe_softc *);
static int epe_mediachange(struct ifnet *);
-int epe_mii_readreg (struct device *, int, int);
-void epe_mii_writereg (struct device *, int, int, int);
-void epe_statchg (struct device *);
+int epe_mii_readreg (device_t, int, int);
+void epe_mii_writereg (device_t, int, int, int);
+void epe_statchg (struct ifnet *);
void epe_tick (void *);
static int epe_ifioctl (struct ifnet *, u_long, void *);
static void epe_ifstart (struct ifnet *);
@@ -119,21 +119,21 @@
epe_match, epe_attach, NULL, NULL);
static int
-epe_match(struct device *parent, struct cfdata *match, void *aux)
+epe_match(device_t parent, cfdata_t match, void *aux)
{
return 2;
}
static void
-epe_attach(struct device *parent, struct device *self, void *aux)
+epe_attach(device_t parent, device_t self, void *aux)
{
- struct epe_softc *sc;
+ struct epe_softc *sc = device_private(self);
struct epsoc_attach_args *sa;
prop_data_t enaddr;
- printf("\n");
- sc = (struct epe_softc*) self;
+ aprint_normal("\n");
sa = aux;
+ sc->sc_dev = self;
sc->sc_iot = sa->sa_iot;
sc->sc_intr = sa->sa_intr;
sc->sc_dmat = sa->sa_dmat;
@@ -303,7 +303,7 @@
/* Read ethernet MAC, should already be set by bootrom */
bus_space_read_region_1(sc->sc_iot, sc->sc_ioh, EPE_IndAd,
sc->sc_enaddr, ETHER_ADDR_LEN);
- printf("%s: MAC address %s\n", sc->sc_dev.dv_xname,
+ aprint_normal_dev(sc->sc_dev, "MAC address %s\n",
ether_sprintf(sc->sc_enaddr));
/* Soft Reset the MAC */
@@ -334,7 +334,7 @@
sc->ctrlpage, PAGE_SIZE, NULL, BUS_DMA_WAITOK);
}
if (err != 0) {
- panic("%s: Cannot get DMA memory", sc->sc_dev.dv_xname);
+ panic("%s: Cannot get DMA memory", device_xname(sc->sc_dev));
}
sc->ctrlpage_dsaddr = sc->ctrlpage_dmamap->dm_segs[0].ds_addr;
memset(sc->ctrlpage, 0, PAGE_SIZE);
@@ -402,8 +402,8 @@
}
/* Divide HCLK by 32 for MDC clock */
- if (device_cfdata(&sc->sc_dev)->cf_flags)
- mdcdiv = device_cfdata(&sc->sc_dev)->cf_flags;
+ if (device_cfdata(sc->sc_dev)->cf_flags)
+ mdcdiv = device_cfdata(sc->sc_dev)->cf_flags;
EPE_WRITE(SelfCtl, (SelfCtl_MDCDIV(mdcdiv)|SelfCtl_PSPRS));
sc->sc_mii.mii_ifp = ifp;
@@ -413,7 +413,7 @@
sc->sc_ec.ec_mii = &sc->sc_mii;
ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, epe_mediachange,
ether_mediastatus);
- mii_attach((struct device *)sc, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
@@ -434,7 +434,7 @@
*/
sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU;
- strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
+ strcpy(ifp->if_xname, device_xname(sc->sc_dev));
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST;
ifp->if_ioctl = epe_ifioctl;
ifp->if_start = epe_ifstart;
@@ -457,12 +457,13 @@
}
int
-epe_mii_readreg(struct device *self, int phy, int reg)
+epe_mii_readreg(device_t self, int phy, int reg)
{
+ struct epe_softc *sc;
u_int32_t d, v;
- struct epe_softc *sc;
- sc = (struct epe_softc *)self;
+ sc = device_private(self);
+
d = EPE_READ(SelfCtl);
EPE_WRITE(SelfCtl, d & ~SelfCtl_PSPRS); /* no preamble suppress */
EPE_WRITE(MIICmd, (MIICmd_READ | (phy << 5) | reg));
@@ -473,12 +474,13 @@
}
void
-epe_mii_writereg(struct device *self, int phy, int reg, int val)
+epe_mii_writereg(device_t self, int phy, int reg, int val)
{
struct epe_softc *sc;
u_int32_t d;
- sc = (struct epe_softc *)self;
+ sc = device_private(self);
+
d = EPE_READ(SelfCtl);
EPE_WRITE(SelfCtl, d & ~SelfCtl_PSPRS); /* no preamble suppress */
EPE_WRITE(MIIData, val);
@@ -489,9 +491,9 @@
void
-epe_statchg(struct device *self)
+epe_statchg(struct ifnet *ifp)
{
- struct epe_softc *sc = (struct epe_softc *)self;
+ struct epe_softc *sc = ifp->if_softc;
u_int32_t reg;
/*
@@ -518,7 +520,7 @@
/* These misses are ok, they will happen if the RAM/CPU can't keep up */
misses = EPE_READ(RXMissCnt);
if (misses > 0)
- printf("%s: %d rx misses\n", sc->sc_dev.dv_xname, misses);
+ printf("%s: %d rx misses\n", device_xname(sc->sc_dev), misses);
s = splnet();
if (epe_gctx(sc) > 0 && IFQ_IS_EMPTY(&ifp->if_snd) == 0) {
@@ -666,7 +668,7 @@
if ((ifp->if_flags & IFF_RUNNING) == 0)
return;
printf("%s: device timeout, BMCtl = 0x%08x, BMSts = 0x%08x\n",
- sc->sc_dev.dv_xname, EPE_READ(BMCtl), EPE_READ(BMSts));
+ device_xname(sc->sc_dev), EPE_READ(BMCtl), EPE_READ(BMSts));
}
static int
diff -r 83da7a66ab2f -r 2e32afb6cd9c sys/arch/arm/ep93xx/epevar.h
--- a/sys/arch/arm/ep93xx/epevar.h Sun Jul 22 14:27:35 2012 +0000
+++ b/sys/arch/arm/ep93xx/epevar.h Sun Jul 22 14:32:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: epevar.h,v 1.5 2009/10/23 00:39:30 snj Exp $ */
+/* $NetBSD: epevar.h,v 1.6 2012/07/22 14:32:50 matt Exp $ */
/*-
* Copyright (c) 2004 Jesse Off
* All rights reserved
@@ -38,7 +38,7 @@
};
struct epe_softc {
- struct device sc_dev;
+ device_t sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_dma_tag_t sc_dmat;
diff -r 83da7a66ab2f -r 2e32afb6cd9c sys/arch/arm/gemini/if_gmc.c
--- a/sys/arch/arm/gemini/if_gmc.c Sun Jul 22 14:27:35 2012 +0000
+++ b/sys/arch/arm/gemini/if_gmc.c Sun Jul 22 14:32:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gmc.c,v 1.4 2011/07/01 19:32:28 dyoung Exp $ */
+/* $NetBSD: if_gmc.c,v 1.5 2012/07/22 14:32:50 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -47,7 +47,7 @@
#include <net/if_ether.h>
#include <net/if_dl.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.4 2011/07/01 19:32:28 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.5 2012/07/22 14:32:50 matt Exp $");
#define MAX_TXSEG 32
@@ -307,9 +307,9 @@
}
static void
-gmc_mii_statchg(device_t self)
+gmc_mii_statchg(struct ifnet *ifp)
{
- struct gmc_softc * const sc = device_private(self);
+ struct gmc_softc * const sc = ifp->if_softc;
uint32_t gmac_status;
gmac_status = sc->sc_gmac_status;
diff -r 83da7a66ab2f -r 2e32afb6cd9c sys/arch/arm/xscale/ixp425_if_npe.c
--- a/sys/arch/arm/xscale/ixp425_if_npe.c Sun Jul 22 14:27:35 2012 +0000
+++ b/sys/arch/arm/xscale/ixp425_if_npe.c Sun Jul 22 14:32:49 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixp425_if_npe.c,v 1.22 2012/02/02 19:42:58 tls Exp $ */
Home |
Main Index |
Thread Index |
Old Index