Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/usb Pull up following revision(s) (requested by n...
details: https://anonhg.NetBSD.org/src/rev/9255ded288ec
branches: netbsd-8
changeset: 434979:9255ded288ec
user: martin <martin%NetBSD.org@localhost>
date: Mon May 07 13:26:03 2018 +0000
description:
Pull up following revision(s) (requested by nonaka in ticket #782):
sys/dev/usb/if_axe.c: revision 1.85-1.89
propagate pullup-782 for NetBSD-8 to HEAD (gcc uninitialized)
It was not gcc's fault for correctly detecting an uninitialized variable.
Fix the uninitialized variable issues by error checking things.
downgrade error to debug.
merge duplicated code, back to logging error.
use the proper station nodeid read command.
diffstat:
sys/dev/usb/if_axe.c | 101 +++++++++++++++++++++++++++++++-------------------
1 files changed, 63 insertions(+), 38 deletions(-)
diffs (213 lines):
diff -r 8a816a4b385e -r 9255ded288ec sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c Mon May 07 05:09:40 2018 +0000
+++ b/sys/dev/usb/if_axe.c Mon May 07 13:26:03 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.82.6.2 2018/01/31 18:01:55 martin Exp $ */
+/* $NetBSD: if_axe.c,v 1.82.6.3 2018/05/07 13:26:03 martin Exp $ */
/* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
/*
@@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.2 2018/01/31 18:01:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.3 2018/05/07 13:26:03 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -303,7 +303,7 @@
KASSERT(mutex_owned(&sc->axe_mii_lock));
if (sc->axe_dying)
- return 0;
+ return -1;
DPRINTFN(20, "cmd %#jx index %#jx val %#jx", cmd, index, val, 0);
@@ -337,7 +337,7 @@
axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
- err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, (void *)&val);
+ err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, &val);
axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
if (err) {
aprint_error_dev(sc->axe_dev, "read PHY failed\n");
@@ -389,7 +389,7 @@
val = htole16(aval);
axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
- err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, (void *)&val);
+ err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, &val);
axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
if (err) {
@@ -477,7 +477,11 @@
return;
axe_lock_mii(sc);
- axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, (void *)&rxmode);
+ if (axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode)) {
+ axe_unlock_mii(sc);
+ aprint_error_dev(sc->axe_dev, "can't read rxmode");
+ return;
+ }
rxmode = le16toh(rxmode);
rxmode &=
@@ -507,7 +511,7 @@
ifp->if_flags &= ~IFF_ALLMULTI;
rxmode |= AXE_RXCMD_MULTICAST;
- axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *)&hashtbl);
+ axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, hashtbl);
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
axe_unlock_mii(sc);
return;
@@ -519,6 +523,30 @@
axe_unlock_mii(sc);
}
+static void
+axe_ax_init(struct axe_softc *sc)
+{
+ int cmd = AXE_178_CMD_READ_NODEID;
+
+ if (sc->axe_flags & AX178) {
+ axe_ax88178_init(sc);
+ } else if (sc->axe_flags & AX772) {
+ axe_ax88772_init(sc);
+ } else if (sc->axe_flags & AX772A) {
+ axe_ax88772a_init(sc);
+ } else if (sc->axe_flags & AX772B) {
+ axe_ax88772b_init(sc);
+ return;
+ } else {
+ cmd = AXE_172_CMD_READ_NODEID;
+ }
+
+ if (axe_cmd(sc, cmd, 0, 0, sc->axe_enaddr)) {
+ aprint_error_dev(sc->axe_dev,
+ "failed to read ethernet address\n");
+ }
+}
+
static void
axe_reset(struct axe_softc *sc)
@@ -542,15 +570,8 @@
#else
axe_lock_mii(sc);
- if (sc->axe_flags & AX178) {
- axe_ax88178_init(sc);
- } else if (sc->axe_flags & AX772) {
- axe_ax88772_init(sc);
- } else if (sc->axe_flags & AX772A) {
- axe_ax88772a_init(sc);
- } else if (sc->axe_flags & AX772B) {
- axe_ax88772b_init(sc);
- }
+ axe_ax_init(sc);
+
axe_unlock_mii(sc);
#endif
}
@@ -594,7 +615,8 @@
axe_cmd(sc, AXE_CMD_SROM_WR_ENABLE, 0, 0, NULL);
/* XXX magic */
- axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, &eeprom);
+ if (axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, &eeprom) != 0)
+ eeprom = 0xffff;
axe_cmd(sc, AXE_CMD_SROM_WR_DISABLE, 0, 0, NULL);
eeprom = le16toh(eeprom);
@@ -752,8 +774,7 @@
if (sc->axe_phyno == AXE_772_PHY_NO_EPHY) {
/* Manually select internal(embedded) PHY - MAC mode. */
axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0,
- AXE_SW_PHY_SELECT_EMBEDDED,
- NULL);
+ AXE_SW_PHY_SELECT_EMBEDDED, NULL);
usbd_delay_ms(sc->axe_udev, hztoms(hz / 32));
} else {
/*
@@ -815,7 +836,12 @@
* Save PHY power saving configuration(high byte) and
* clear EEPROM checksum value(low byte).
*/
- axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_PHY_PWRCFG, &eeprom);
+ if (axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_PHY_PWRCFG,
+ &eeprom)) {
+ aprint_error_dev(sc->axe_dev, "failed to read eeprom\n");
+ return;
+ }
+
sc->sc_pwrcfg = le16toh(eeprom) & 0xFF00;
/*
@@ -825,8 +851,12 @@
*/
uint8_t *eaddr = sc->axe_enaddr;
for (i = 0; i < ETHER_ADDR_LEN / 2; i++) {
- axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_NODE_ID + i,
- &eeprom);
+ if (axe_cmd(sc, AXE_CMD_SROM_READ, 0,
+ AXE_EEPROM_772B_NODE_ID + i, &eeprom)) {
+ aprint_error_dev(sc->axe_dev,
+ "failed to read eeprom\n");
+ eeprom = 0;
+ }
eeprom = le16toh(eeprom);
*eaddr++ = (uint8_t)(eeprom & 0xFF);
*eaddr++ = (uint8_t)((eeprom >> 8) & 0xFF);
@@ -940,7 +970,10 @@
/* We need the PHYID for init dance in some cases */
axe_lock_mii(sc);
- axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, (void *)&sc->axe_phyaddrs);
+ if (axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, &sc->axe_phyaddrs)) {
+ aprint_error_dev(self, "failed to read phyaddrs\n");
+ return;
+ }
DPRINTF(" phyaddrs[0]: %jx phyaddrs[1]: %jx",
sc->axe_phyaddrs[0], sc->axe_phyaddrs[1], 0, 0);
@@ -955,19 +988,7 @@
/* Initialize controller and get station address. */
- if (sc->axe_flags & AX178) {
- axe_ax88178_init(sc);
- axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, sc->axe_enaddr);
- } else if (sc->axe_flags & AX772) {
- axe_ax88772_init(sc);
- axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, sc->axe_enaddr);
- } else if (sc->axe_flags & AX772A) {
- axe_ax88772a_init(sc);
- axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, sc->axe_enaddr);
- } else if (sc->axe_flags & AX772B) {
- axe_ax88772b_init(sc);
- } else
- axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, sc->axe_enaddr);
+ axe_ax_init(sc);
/*
* Fetch IPG values.
@@ -977,8 +998,12 @@
sc->axe_ipgs[0] = AXE_IPG0_DEFAULT;
sc->axe_ipgs[1] = AXE_IPG1_DEFAULT;
sc->axe_ipgs[2] = AXE_IPG2_DEFAULT;
- } else
- axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->axe_ipgs);
+ } else {
+ if (axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->axe_ipgs)) {
+ aprint_error_dev(self, "failed to read ipg\n");
+ return;
+ }
+ }
axe_unlock_mii(sc);
Home |
Main Index |
Thread Index |
Old Index