Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci convert to device_t.
details: https://anonhg.NetBSD.org/src/rev/d159f88f273b
branches: trunk
changeset: 777478:d159f88f273b
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Feb 20 02:14:34 2012 +0000
description:
convert to device_t.
been running on my inspiron 8500 for a couple of months.
diffstat:
sys/dev/pci/if_bce.c | 55 +++++++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 26 deletions(-)
diffs (204 lines):
diff -r d5e521308bf5 -r d159f88f273b sys/dev/pci/if_bce.c
--- a/sys/dev/pci/if_bce.c Mon Feb 20 01:12:42 2012 +0000
+++ b/sys/dev/pci/if_bce.c Mon Feb 20 02:14:34 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bce.c,v 1.35 2012/02/02 19:43:05 tls Exp $ */
+/* $NetBSD: if_bce.c,v 1.36 2012/02/20 02:14:34 mrg Exp $ */
/*
* Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.35 2012/02/02 19:43:05 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.36 2012/02/20 02:14:34 mrg Exp $");
#include "vlan.h"
@@ -114,7 +114,7 @@
#define BCE_TIMEOUT 100 /* # 10us for mii read/write */
struct bce_softc {
- struct device bce_dev;
+ device_t bce_dev;
bus_space_tag_t bce_btag;
bus_space_handle_t bce_bhandle;
bus_dma_tag_t bce_dmatag;
@@ -179,7 +179,8 @@
static void bce_statchg(device_t);
static void bce_tick(void *);
-CFATTACH_DECL(bce, sizeof(struct bce_softc), bce_probe, bce_attach, NULL, NULL);
+CFATTACH_DECL_NEW(bce, sizeof(struct bce_softc),
+ bce_probe, bce_attach, NULL, NULL);
static const struct bce_product {
pci_vendor_id_t bp_vendor;
@@ -251,6 +252,8 @@
int error, i, pmreg, rseg;
struct ifnet *ifp;
+ sc->bce_dev = self;
+
bp = bce_lookup(pa);
KASSERT(bp != NULL);
@@ -419,7 +422,7 @@
sc->ethercom.ec_mii = &sc->bce_mii;
ifmedia_init(&sc->bce_mii.mii_media, 0, ether_mediachange,
ether_mediastatus);
- mii_attach(&sc->bce_dev, &sc->bce_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->bce_dev, &sc->bce_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, MIIF_FORCEANEG|MIIF_DOPAUSE);
if (LIST_FIRST(&sc->bce_mii.mii_phys) == NULL) {
ifmedia_add(&sc->bce_mii.mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
@@ -433,11 +436,11 @@
* Enable activity led.
* XXX This should be in a phy driver, but not currently.
*/
- bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
- bce_mii_read(&sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
+ bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
+ bce_mii_read(sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
/* enable traffic meter led mode */
- bce_mii_write(&sc->bce_dev, 1, 27, /* MAGIC */
- bce_mii_read(&sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
+ bce_mii_write(sc->bce_dev, 1, 27, /* MAGIC */
+ bce_mii_read(sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
/* Attach the interface */
if_attach(ifp);
@@ -537,7 +540,7 @@
error = bus_dmamap_load_mbuf(sc->bce_dmatag, dmamap, m0,
BUS_DMA_WRITE | BUS_DMA_NOWAIT);
if (error == EFBIG) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"Tx packet consumes too many DMA segments, "
"dropping...\n");
IFQ_DEQUEUE(&ifp->if_snd, m0);
@@ -546,7 +549,7 @@
continue;
} else if (error) {
/* short on resources, come back later */
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"unable to load Tx buffer, error = %d\n",
error);
break;
@@ -637,7 +640,7 @@
{
struct bce_softc *sc = ifp->if_softc;
- aprint_error_dev(&sc->bce_dev, "device timeout\n");
+ aprint_error_dev(sc->bce_dev, "device timeout\n");
ifp->if_oerrors++;
(void) bce_init(ifp);
@@ -699,7 +702,7 @@
if (intstatus & I_TO)
msg = "general purpose timeout";
if (msg != NULL)
- aprint_error_dev(&sc->bce_dev, "%s\n", msg);
+ aprint_error_dev(sc->bce_dev, "%s\n", msg);
wantinit = 1;
}
}
@@ -954,7 +957,7 @@
for (i = 0; i < BCE_NRXDESC; i++) {
if (sc->bce_cdata.bce_rx_chain[i] == NULL) {
if ((error = bce_add_rxbuf(sc, i)) != 0) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"unable to allocate or map rx(%d) "
"mbuf, error = %d\n", i, error);
bce_rxdrain(sc);
@@ -1015,7 +1018,7 @@
delay(10);
}
if (i == 100) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"timed out writing pkt filter ctl\n");
}
}
@@ -1152,7 +1155,7 @@
delay(10);
}
if (i == 200) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"timed out disabling ethernet mac\n");
}
@@ -1169,7 +1172,7 @@
delay(10);
}
if (i == 100) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"receive dma did not go idle after"
" error\n");
}
@@ -1188,7 +1191,7 @@
delay(10);
}
if (i == 200) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"timed out resetting ethernet mac\n");
}
} else {
@@ -1234,7 +1237,7 @@
delay(1);
}
if (i == 200) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"while resetting core, reject did not set\n");
}
/* wait until busy is clear */
@@ -1246,7 +1249,7 @@
delay(1);
}
if (i == 200) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"while resetting core, busy did not clear\n");
}
/* set reset and reject while enabling the clocks */
@@ -1386,7 +1389,7 @@
}
val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MI_COMM);
if (i == BCE_TIMEOUT) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"PHY read timed out reading phy %d, reg %d, val = "
"0x%08x\n", phy, reg, val);
return (0);
@@ -1422,7 +1425,7 @@
}
rval = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MI_COMM);
if (i == BCE_TIMEOUT) {
- aprint_error_dev(&sc->bce_dev,
+ aprint_error_dev(sc->bce_dev,
"PHY timed out writing phy %d, reg %d, val = 0x%08x\n", phy,
reg, val);
}
@@ -1448,11 +1451,11 @@
* Enable activity led.
* XXX This should be in a phy driver, but not currently.
*/
- bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
- bce_mii_read(&sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
+ bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
+ bce_mii_read(sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
/* enable traffic meter led mode */
- bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
- bce_mii_read(&sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
+ bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
+ bce_mii_read(sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
}
/* One second timer, checks link status */
Home |
Main Index |
Thread Index |
Old Index