summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2006-09-15 10:40:54 +0000
committerglebius <glebius@FreeBSD.org>2006-09-15 10:40:54 +0000
commitaeb9aeaa73fe735ddc4a606776072563dd9b6b43 (patch)
treeae382d23f768d8bc206d445054d2cee99c94d544 /sys/dev
parent6b78b3a81dfd58cd5838b6fae2c4f76e95a5f930 (diff)
downloadFreeBSD-src-aeb9aeaa73fe735ddc4a606776072563dd9b6b43.zip
FreeBSD-src-aeb9aeaa73fe735ddc4a606776072563dd9b6b43.tar.gz
Consistently use if_printf() only in interface methods: if_start,
if_ioctl, if_watchdog, etc, or in functions that are used by these methods only. In all other cases use device_printf(). This also fixes several panics, when if_printf() is called before softc->ifp was initialized. Submitted by: Alex Lyashkov <umka sevcity.net>
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sf/if_sf.c7
-rw-r--r--sys/dev/sf/if_sfreg.h1
-rw-r--r--sys/dev/vr/if_vr.c20
-rw-r--r--sys/dev/vr/if_vrreg.h1
4 files changed, 17 insertions, 12 deletions
diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c
index 498aba3..a308e40 100644
--- a/sys/dev/sf/if_sf.c
+++ b/sys/dev/sf/if_sf.c
@@ -616,7 +616,7 @@ sf_reset(sc)
}
if (i == SF_TIMEOUT)
- if_printf(sc->sf_ifp, "reset never completed!\n");
+ device_printf(sc->sf_dev, "reset never completed!\n");
/* Wait a little while for the chip to get its brains in order. */
DELAY(1000);
@@ -690,6 +690,7 @@ sf_attach(dev)
u_char eaddr[6];
sc = device_get_softc(dev);
+ sc->sf_dev = dev;
mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
@@ -1081,7 +1082,7 @@ sf_txthresh_adjust(sc)
txfctl &= ~SF_TXFRMCTL_TXTHRESH;
txfctl |= txthresh;
#ifdef DIAGNOSTIC
- if_printf(sc->sf_ifp, "tx underrun, increasing "
+ device_printf(sc->sf_dev, "tx underrun, increasing "
"tx threshold to %d bytes\n",
txthresh * 4);
#endif
@@ -1243,7 +1244,7 @@ sf_init_locked(sc)
sf_setperf(sc, 0, IF_LLADDR(sc->sf_ifp));
if (sf_init_rx_ring(sc) == ENOBUFS) {
- if_printf(sc->sf_ifp,
+ device_printf(sc->sf_dev,
"initialization failed: no memory for rx buffers\n");
return;
}
diff --git a/sys/dev/sf/if_sfreg.h b/sys/dev/sf/if_sfreg.h
index 9b3826d..1f6618d 100644
--- a/sys/dev/sf/if_sfreg.h
+++ b/sys/dev/sf/if_sfreg.h
@@ -1032,6 +1032,7 @@ struct sf_list_data {
struct sf_softc {
struct ifnet *sf_ifp; /* interface info */
+ device_t sf_dev; /* device info */
bus_space_handle_t sf_bhandle; /* bus space handle */
bus_space_tag_t sf_btag; /* bus space tag */
void *sf_intrhand; /* interrupt handler cookie */
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c
index 18de6f1..be38015 100644
--- a/sys/dev/vr/if_vr.c
+++ b/sys/dev/vr/if_vr.c
@@ -603,10 +603,10 @@ vr_reset(struct vr_softc *sc)
}
if (i == VR_TIMEOUT) {
if (sc->vr_revid < REV_ID_VT3065_A)
- if_printf(sc->vr_ifp, "reset never completed!\n");
+ device_printf(sc->vr_dev, "reset never completed!\n");
else {
/* Use newer force reset command */
- if_printf(sc->vr_ifp, "Using force reset command.\n");
+ device_printf(sc->vr_dev, "Using force reset command.\n");
VR_SETBIT(sc, VR_MISC_CR1, VR_MISCCR1_FORSRST);
}
}
@@ -651,6 +651,7 @@ vr_attach(dev)
int unit, error = 0, rid;
sc = device_get_softc(dev);
+ sc->vr_dev = dev;
unit = device_get_unit(dev);
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
@@ -973,7 +974,8 @@ vr_rxeof(struct vr_softc *sc)
*/
if (rxstat & VR_RXSTAT_RXERR) {
ifp->if_ierrors++;
- if_printf(ifp, "rx error (%02x):", rxstat & 0x000000ff);
+ device_printf(sc->vr_dev,
+ "rx error (%02x):", rxstat & 0x000000ff);
if (rxstat & VR_RXSTAT_CRCERR)
printf(" crc error");
if (rxstat & VR_RXSTAT_FRAMEALIGNERR)
@@ -1042,7 +1044,7 @@ vr_rxeoc(struct vr_softc *sc)
}
if (!i) {
- if_printf(ifp, "rx shutdown error!\n");
+ device_printf(sc->vr_dev, "rx shutdown error!\n");
sc->vr_flags |= VR_F_RESTART;
return;
}
@@ -1084,7 +1086,7 @@ vr_txeof(struct vr_softc *sc)
i--)
; /* Wait for chip to shutdown */
if (!i) {
- if_printf(ifp, "tx shutdown timeout\n");
+ device_printf(sc->vr_dev, "tx shutdown timeout\n");
sc->vr_flags |= VR_F_RESTART;
break;
}
@@ -1127,7 +1129,7 @@ vr_tick(void *xsc)
VR_LOCK_ASSERT(sc);
if (sc->vr_flags & VR_F_RESTART) {
- if_printf(sc->vr_ifp, "restarting\n");
+ device_printf(sc->vr_dev, "restarting\n");
vr_stop(sc);
vr_reset(sc);
vr_init_locked(sc);
@@ -1261,13 +1263,13 @@ vr_intr(void *arg)
vr_rxeof(sc);
if (status & VR_ISR_RX_DROPPED) {
- if_printf(ifp, "rx packet lost\n");
+ device_printf(sc->vr_dev, "rx packet lost\n");
ifp->if_ierrors++;
}
if ((status & VR_ISR_RX_ERR) || (status & VR_ISR_RX_NOBUF) ||
(status & VR_ISR_RX_NOBUF) || (status & VR_ISR_RX_OFLOW)) {
- if_printf(ifp, "receive error (%04x)", status);
+ device_printf(sc->vr_dev, "receive error (%04x)", status);
if (status & VR_ISR_RX_NOBUF)
printf(" no buffers");
if (status & VR_ISR_RX_OFLOW)
@@ -1469,7 +1471,7 @@ vr_init_locked(struct vr_softc *sc)
/* Init circular RX list. */
if (vr_list_rx_init(sc) == ENOBUFS) {
- if_printf(ifp,
+ device_printf(sc->vr_dev,
"initialization failed: no memory for rx buffers\n");
vr_stop(sc);
return;
diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h
index 7caab56..d5a1023 100644
--- a/sys/dev/vr/if_vrreg.h
+++ b/sys/dev/vr/if_vrreg.h
@@ -453,6 +453,7 @@ struct vr_mii_frame {
struct vr_softc {
struct ifnet *vr_ifp; /* interface info */
+ device_t vr_dev;
bus_space_handle_t vr_bhandle; /* bus space handle */
bus_space_tag_t vr_btag; /* bus space tag */
struct resource *vr_res;
OpenPOWER on IntegriCloud