Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - Use device_printf() instead of aprint_error_de...
details: https://anonhg.NetBSD.org/src/rev/cd238dd318b2
branches: trunk
changeset: 825404:cd238dd318b2
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Thu Jul 13 07:50:49 2017 +0000
description:
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Add debug printf.
- Rename variables.
diffstat:
sys/dev/pci/if_wm.c | 284 +++++++++++++++++++++++++--------------------------
1 files changed, 137 insertions(+), 147 deletions(-)
diffs (truncated from 717 to 300 lines):
diff -r 8e7d7283168b -r cd238dd318b2 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Thu Jul 13 03:25:38 2017 +0000
+++ b/sys/dev/pci/if_wm.c Thu Jul 13 07:50:49 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.520 2017/07/12 08:18:36 msaitoh Exp $ */
+/* $NetBSD: if_wm.c,v 1.521 2017/07/13 07:50:49 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.520 2017/07/12 08:18:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.521 2017/07/13 07:50:49 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -9012,6 +9012,9 @@
mii_readreg_t new_readreg;
mii_writereg_t new_writereg;
+ DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+ device_xname(sc->sc_dev), __func__));
+
if (mii->mii_readreg == NULL) {
/*
* This is the first call of this function. For ICH and PCH
@@ -9570,9 +9573,9 @@
* Read a PHY register on the GMII (i82543 version).
*/
static int
-wm_gmii_i82543_readreg(device_t self, int phy, int reg)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i82543_readreg(device_t dev, int phy, int reg)
+{
+ struct wm_softc *sc = device_private(dev);
int rv;
wm_i82543_mii_sendbits(sc, 0xffffffffU, 32);
@@ -9581,7 +9584,7 @@
rv = wm_i82543_mii_recvbits(sc) & 0xffff;
DPRINTF(WM_DEBUG_GMII, ("%s: GMII: read phy %d reg %d -> 0x%04x\n",
- device_xname(sc->sc_dev), phy, reg, rv));
+ device_xname(dev), phy, reg, rv));
return rv;
}
@@ -9592,9 +9595,9 @@
* Write a PHY register on the GMII (i82543 version).
*/
static void
-wm_gmii_i82543_writereg(device_t self, int phy, int reg, int val)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i82543_writereg(device_t dev, int phy, int reg, int val)
+{
+ struct wm_softc *sc = device_private(dev);
wm_i82543_mii_sendbits(sc, 0xffffffffU, 32);
wm_i82543_mii_sendbits(sc, val | (MII_COMMAND_ACK << 16) |
@@ -9608,9 +9611,9 @@
* Read a PHY register on the GMII.
*/
static int
-wm_gmii_mdic_readreg(device_t self, int phy, int reg)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_mdic_readreg(device_t dev, int phy, int reg)
+{
+ struct wm_softc *sc = device_private(dev);
uint32_t mdic = 0;
int i, rv;
@@ -9626,12 +9629,12 @@
if ((mdic & MDIC_READY) == 0) {
log(LOG_WARNING, "%s: MDIC read timed out: phy %d reg %d\n",
- device_xname(sc->sc_dev), phy, reg);
+ device_xname(dev), phy, reg);
rv = 0;
} else if (mdic & MDIC_E) {
#if 0 /* This is normal if no PHY is present. */
log(LOG_WARNING, "%s: MDIC read error: phy %d reg %d\n",
- device_xname(sc->sc_dev), phy, reg);
+ device_xname(dev), phy, reg);
#endif
rv = 0;
} else {
@@ -9649,9 +9652,9 @@
* Write a PHY register on the GMII.
*/
static void
-wm_gmii_mdic_writereg(device_t self, int phy, int reg, int val)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_mdic_writereg(device_t dev, int phy, int reg, int val)
+{
+ struct wm_softc *sc = device_private(dev);
uint32_t mdic = 0;
int i;
@@ -9667,10 +9670,10 @@
if ((mdic & MDIC_READY) == 0)
log(LOG_WARNING, "%s: MDIC write timed out: phy %d reg %d\n",
- device_xname(sc->sc_dev), phy, reg);
+ device_xname(dev), phy, reg);
else if (mdic & MDIC_E)
log(LOG_WARNING, "%s: MDIC write error: phy %d reg %d\n",
- device_xname(sc->sc_dev), phy, reg);
+ device_xname(dev), phy, reg);
}
/*
@@ -9679,17 +9682,16 @@
* Read a PHY register on the GMII.
*/
static int
-wm_gmii_i82544_readreg(device_t self, int phy, int reg)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i82544_readreg(device_t dev, int phy, int reg)
+{
+ struct wm_softc *sc = device_private(dev);
int rv;
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
- __func__);
+ device_printf(dev, "%s: failed to get semaphore\n", __func__);
return 0;
}
- rv = wm_gmii_mdic_readreg(self, phy, reg);
+ rv = wm_gmii_mdic_readreg(dev, phy, reg);
sc->phy.release(sc);
return rv;
@@ -9701,15 +9703,15 @@
* Write a PHY register on the GMII.
*/
static void
-wm_gmii_i82544_writereg(device_t self, int phy, int reg, int val)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i82544_writereg(device_t dev, int phy, int reg, int val)
+{
+ struct wm_softc *sc = device_private(dev);
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
- __func__);
- }
- wm_gmii_mdic_writereg(self, phy, reg, val);
+ device_printf(dev, "%s: failed to get semaphore\n", __func__);
+ return;
+ }
+ wm_gmii_mdic_writereg(dev, phy, reg, val);
sc->phy.release(sc);
}
@@ -9721,30 +9723,29 @@
* ressource ...
*/
static int
-wm_gmii_i80003_readreg(device_t self, int phy, int reg)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i80003_readreg(device_t dev, int phy, int reg)
+{
+ struct wm_softc *sc = device_private(dev);
int rv;
if (phy != 1) /* only one PHY on kumeran bus */
return 0;
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
- __func__);
+ device_printf(dev, "%s: failed to get semaphore\n", __func__);
return 0;
}
if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG) {
- wm_gmii_mdic_writereg(self, phy, GG82563_PHY_PAGE_SELECT,
+ wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT,
reg >> GG82563_PAGE_SHIFT);
} else {
- wm_gmii_mdic_writereg(self, phy, GG82563_PHY_PAGE_SELECT_ALT,
+ wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT_ALT,
reg >> GG82563_PAGE_SHIFT);
}
/* Wait more 200us for a bug of the ready bit in the MDIC register */
delay(200);
- rv = wm_gmii_mdic_readreg(self, phy, reg & MII_ADDRMASK);
+ rv = wm_gmii_mdic_readreg(dev, phy, reg & MII_ADDRMASK);
delay(200);
sc->phy.release(sc);
@@ -9759,29 +9760,28 @@
* ressource ...
*/
static void
-wm_gmii_i80003_writereg(device_t self, int phy, int reg, int val)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_i80003_writereg(device_t dev, int phy, int reg, int val)
+{
+ struct wm_softc *sc = device_private(dev);
if (phy != 1) /* only one PHY on kumeran bus */
return;
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
- __func__);
+ device_printf(dev, "%s: failed to get semaphore\n", __func__);
return;
}
if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG) {
- wm_gmii_mdic_writereg(self, phy, GG82563_PHY_PAGE_SELECT,
+ wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT,
reg >> GG82563_PAGE_SHIFT);
} else {
- wm_gmii_mdic_writereg(self, phy, GG82563_PHY_PAGE_SELECT_ALT,
+ wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT_ALT,
reg >> GG82563_PAGE_SHIFT);
}
/* Wait more 200us for a bug of the ready bit in the MDIC register */
delay(200);
- wm_gmii_mdic_writereg(self, phy, reg & MII_ADDRMASK, val);
+ wm_gmii_mdic_writereg(dev, phy, reg & MII_ADDRMASK, val);
delay(200);
sc->phy.release(sc);
@@ -9795,16 +9795,15 @@
* ressource ...
*/
static int
-wm_gmii_bm_readreg(device_t self, int phy, int reg)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_bm_readreg(device_t dev, int phy, int reg)
+{
+ struct wm_softc *sc = device_private(dev);
uint16_t page = reg >> BME1000_PAGE_SHIFT;
uint16_t val;
int rv;
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
- __func__);
+ device_printf(dev, "%s: failed to get semaphore\n", __func__);
return 0;
}
@@ -9813,7 +9812,7 @@
|| (reg == 31)) ? 1 : phy;
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
- wm_access_phy_wakeup_reg_bm(self, reg, &val, 1);
+ wm_access_phy_wakeup_reg_bm(dev, reg, &val, 1);
rv = val;
goto release;
}
@@ -9821,14 +9820,14 @@
if (reg > BME1000_MAX_MULTI_PAGE_REG) {
if ((phy == 1) && (sc->sc_type != WM_T_82574)
&& (sc->sc_type != WM_T_82583))
- wm_gmii_mdic_writereg(self, phy,
+ wm_gmii_mdic_writereg(dev, phy,
MII_IGPHY_PAGE_SELECT, page << BME1000_PAGE_SHIFT);
else
- wm_gmii_mdic_writereg(self, phy,
+ wm_gmii_mdic_writereg(dev, phy,
BME1000_PHY_PAGE_SELECT, page);
}
- rv = wm_gmii_mdic_readreg(self, phy, reg & MII_ADDRMASK);
+ rv = wm_gmii_mdic_readreg(dev, phy, reg & MII_ADDRMASK);
release:
sc->phy.release(sc);
@@ -9843,14 +9842,13 @@
* ressource ...
*/
static void
-wm_gmii_bm_writereg(device_t self, int phy, int reg, int val)
-{
- struct wm_softc *sc = device_private(self);
+wm_gmii_bm_writereg(device_t dev, int phy, int reg, int val)
+{
+ struct wm_softc *sc = device_private(dev);
uint16_t page = reg >> BME1000_PAGE_SHIFT;
if (sc->phy.acquire(sc)) {
- aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
Home |
Main Index |
Thread Index |
Old Index