Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb KNF and misc cosmetics.
details: https://anonhg.NetBSD.org/src/rev/b71e70afe724
branches: trunk
changeset: 755835:b71e70afe724
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Jun 24 15:01:45 2010 +0000
description:
KNF and misc cosmetics.
diffstat:
sys/dev/usb/if_axe.c | 190 +++++++++++++++++++++++------------------------
sys/dev/usb/if_axereg.h | 14 +-
2 files changed, 99 insertions(+), 105 deletions(-)
diffs (truncated from 543 to 300 lines):
diff -r a65001672b4e -r b71e70afe724 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c Thu Jun 24 14:41:31 2010 +0000
+++ b/sys/dev/usb/if_axe.c Thu Jun 24 15:01:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.37 2010/06/24 14:41:31 tsutsui Exp $ */
+/* $NetBSD: if_axe.c,v 1.38 2010/06/24 15:01:45 tsutsui Exp $ */
/* $OpenBSD: if_axe.c,v 1.96 2010/01/09 05:33:08 jsg Exp $ */
/*
@@ -89,7 +89,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.37 2010/06/24 14:41:31 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.38 2010/06/24 15:01:45 tsutsui Exp $");
#if defined(__NetBSD__)
#include "opt_inet.h"
@@ -215,6 +215,7 @@
static void
axe_lock_mii(struct axe_softc *sc)
{
+
sc->axe_refcnt++;
mutex_enter(&sc->axe_mii_lock);
}
@@ -222,6 +223,7 @@
static void
axe_unlock_mii(struct axe_softc *sc)
{
+
mutex_exit(&sc->axe_mii_lock);
if (--sc->axe_refcnt < 0)
usb_detach_wakeup((sc->axe_dev));
@@ -230,8 +232,8 @@
static int
axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf)
{
- usb_device_request_t req;
- usbd_status err;
+ usb_device_request_t req;
+ usbd_status err;
KASSERT(mutex_owned(&sc->axe_mii_lock));
@@ -260,8 +262,8 @@
axe_miibus_readreg(device_t dev, int phy, int reg)
{
struct axe_softc *sc = device_private(dev);
- usbd_status err;
- u_int16_t val;
+ usbd_status err;
+ uint16_t val;
if (sc->axe_dying) {
DPRINTF(("axe: dying\n"));
@@ -297,15 +299,15 @@
DPRINTF(("axe_miibus_readreg: ignore read from phy 0x%x\n",
phy));
}
- return (le16toh(val));
+ return le16toh(val);
}
static void
axe_miibus_writereg(device_t dev, int phy, int reg, int aval)
{
- struct axe_softc *sc = device_private(dev);
- usbd_status err;
- u_int16_t val;
+ struct axe_softc *sc = device_private(dev);
+ usbd_status err;
+ uint16_t val;
if (sc->axe_dying)
return;
@@ -327,7 +329,7 @@
axe_miibus_statchg(device_t dev)
{
struct axe_softc *sc = device_private(dev);
- struct mii_data *mii = &sc->axe_mii;
+ struct mii_data *mii = &sc->axe_mii;
int val, err;
if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
@@ -339,7 +341,7 @@
val |= (AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC);
switch (IFM_SUBTYPE(mii->mii_media_active)) {
- case IFM_1000_T:
+ case IFM_1000_T:
val |= AXE_178_MEDIA_GMII | AXE_178_MEDIA_ENCK;
break;
case IFM_100_TX:
@@ -367,9 +369,9 @@
static int
axe_ifmedia_upd(struct ifnet *ifp)
{
- struct axe_softc *sc = ifp->if_softc;
- struct mii_data *mii = &sc->axe_mii;
- int rc;
+ struct axe_softc *sc = ifp->if_softc;
+ struct mii_data *mii = &sc->axe_mii;
+ int rc;
sc->axe_link = 0;
@@ -402,12 +404,12 @@
static void
axe_setmulti(struct axe_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
- struct ether_multi *enm;
- struct ether_multistep step;
- u_int32_t h = 0;
- u_int16_t rxmode;
- u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ struct ifnet *ifp = &sc->sc_if;
+ struct ether_multi *enm;
+ struct ether_multistep step;
+ uint32_t h = 0;
+ uint16_t rxmode;
+ uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (sc->axe_dying)
return;
@@ -428,7 +430,7 @@
ETHER_FIRST_MULTI(step, &sc->axe_ec, enm);
while (enm != NULL) {
if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
- ETHER_ADDR_LEN) != 0)
+ ETHER_ADDR_LEN) != 0)
goto allmulti;
h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
@@ -446,19 +448,18 @@
rxmode |= AXE_RXCMD_ALLMULTI;
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
axe_unlock_mii(sc);
- return;
}
static void
axe_reset(struct axe_softc *sc)
{
+
if (sc->axe_dying)
return;
/* XXX What to reset? */
/* Wait a little while for the chip to get its brains in order. */
DELAY(1000);
- return;
}
static void
@@ -567,8 +568,8 @@
{
struct usb_attach_arg *uaa = aux;
- return (axe_lookup(uaa->vendor, uaa->product) != NULL ?
- UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
+ return axe_lookup(uaa->vendor, uaa->product) != NULL ?
+ UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
}
/*
@@ -633,7 +634,7 @@
/* Find endpoints. */
for (i = 0; i < id->bNumEndpoints; i++) {
ed = usbd_interface2endpoint_descriptor(sc->axe_iface, i);
- if (!ed) {
+ if (ed == NULL) {
aprint_error_dev(self, "couldn't get ep %d\n", i);
return;
}
@@ -668,7 +669,7 @@
*/
if (sc->axe_flags & AX178 || sc->axe_flags & AX772)
axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, &eaddr);
- else
+ else
axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, &eaddr);
/*
@@ -737,16 +738,14 @@
splx(s);
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->axe_udev, sc->axe_dev);
-
- return;
}
int
axe_detach(device_t self, int flags)
{
- struct axe_softc *sc = device_private(self);
- int s;
- struct ifnet *ifp = &sc->sc_if;
+ struct axe_softc *sc = device_private(self);
+ int s;
+ struct ifnet *ifp = &sc->sc_if;
DPRINTFN(2,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev), __func__));
@@ -820,7 +819,7 @@
static int
axe_newbuf(struct axe_softc *sc, struct axe_chain *c, struct mbuf *m)
{
- struct mbuf *m_new = NULL;
+ struct mbuf *m_new = NULL;
DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev),__func__));
@@ -829,15 +828,15 @@
if (m_new == NULL) {
aprint_error_dev(sc->axe_dev, "no memory for rx list "
"-- packet dropped!\n");
- return (ENOBUFS);
+ return ENOBUFS;
}
MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
+ if ((m_new->m_flags & M_EXT) == 0) {
aprint_error_dev(sc->axe_dev, "no memory for rx list "
"-- packet dropped!\n");
m_freem(m_new);
- return (ENOBUFS);
+ return ENOBUFS;
}
m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
} else {
@@ -849,7 +848,7 @@
m_adj(m_new, ETHER_ALIGN);
c->axe_mbuf = m_new;
- return (0);
+ return 0;
}
static int
@@ -867,16 +866,16 @@
c->axe_sc = sc;
c->axe_idx = i;
if (axe_newbuf(sc, c, NULL) == ENOBUFS)
- return (ENOBUFS);
+ return ENOBUFS;
if (c->axe_xfer == NULL) {
c->axe_xfer = usbd_alloc_xfer(sc->axe_udev);
if (c->axe_xfer == NULL)
- return (ENOBUFS);
+ return ENOBUFS;
c->axe_buf = usbd_alloc_buffer(c->axe_xfer,
sc->axe_bufsz);
if (c->axe_buf == NULL) {
usbd_free_xfer(c->axe_xfer);
- return (ENOBUFS);
+ return ENOBUFS;
}
}
}
@@ -902,12 +901,12 @@
if (c->axe_xfer == NULL) {
c->axe_xfer = usbd_alloc_xfer(sc->axe_udev);
if (c->axe_xfer == NULL)
- return (ENOBUFS);
+ return ENOBUFS;
c->axe_buf = usbd_alloc_buffer(c->axe_xfer,
sc->axe_bufsz);
if (c->axe_buf == NULL) {
usbd_free_xfer(c->axe_xfer);
- return (ENOBUFS);
+ return ENOBUFS;
}
}
}
@@ -922,15 +921,15 @@
static void
axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
{
- struct axe_softc *sc;
- struct axe_chain *c;
- struct ifnet *ifp;
- uint8_t *buf;
- u_int32_t total_len;
- u_int16_t pktlen = 0;
- struct mbuf *m;
- struct axe_sframe_hdr hdr;
- int s;
+ struct axe_softc *sc;
+ struct axe_chain *c;
+ struct ifnet *ifp;
+ uint8_t *buf;
+ uint32_t total_len;
+ uint16_t pktlen = 0;
+ struct mbuf *m;
+ struct axe_sframe_hdr hdr;
+ int s;
Home |
Main Index |
Thread Index |
Old Index