svn commit: r187772 - user/thompsa/usb/sys/dev/usb2/wlan
Andrew Thompson
thompsa at FreeBSD.org
Tue Jan 27 07:34:31 PST 2009
Author: thompsa
Date: Tue Jan 27 15:34:30 2009
New Revision: 187772
URL: http://svn.freebsd.org/changeset/base/187772
Log:
- Remove check of null softc in attach routines; it can never happen
- Readd missing parts of zyd_attach
Submitted by: sam
Modified:
user/thompsa/usb/sys/dev/usb2/wlan/if_rum2.c
user/thompsa/usb/sys/dev/usb2/wlan/if_ural2.c
user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c
Modified: user/thompsa/usb/sys/dev/usb2/wlan/if_rum2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/wlan/if_rum2.c Tue Jan 27 12:24:53 2009 (r187771)
+++ user/thompsa/usb/sys/dev/usb2/wlan/if_rum2.c Tue Jan 27 15:34:30 2009 (r187772)
@@ -418,9 +418,6 @@ rum_attach(device_t self)
uint32_t tmp;
int error, ntries, size;
- if (sc == NULL)
- return (ENOMEM);
-
device_set_usb2_desc(self);
sc->sc_udev = uaa->device;
sc->sc_dev = self;
Modified: user/thompsa/usb/sys/dev/usb2/wlan/if_ural2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/wlan/if_ural2.c Tue Jan 27 12:24:53 2009 (r187771)
+++ user/thompsa/usb/sys/dev/usb2/wlan/if_ural2.c Tue Jan 27 15:34:30 2009 (r187772)
@@ -419,9 +419,6 @@ ural_attach(device_t self)
int error;
uint8_t bands, iface_index;
- if (sc == NULL)
- return (ENOMEM);
-
device_set_usb2_desc(self);
sc->sc_udev = uaa->device;
sc->sc_dev = self;
Modified: user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c Tue Jan 27 12:24:53 2009 (r187771)
+++ user/thompsa/usb/sys/dev/usb2/wlan/if_zyd2.c Tue Jan 27 15:34:30 2009 (r187772)
@@ -355,10 +355,7 @@ zyd_attach(device_t dev)
struct ifnet *ifp;
struct usb2_attach_arg *uaa = device_get_ivars(dev);
struct zyd_softc *sc = device_get_softc(dev);
- uint8_t bands;
-
- if (sc == NULL)
- return (ENOMEM);
+ uint8_t bands, iface_index;
if (uaa->info.bcdDevice < 0x4330) {
device_printf(dev, "device version mismatch: 0x%X "
@@ -374,19 +371,36 @@ zyd_attach(device_t dev)
#ifdef ZYD_DEBUG
sc->sc_debug = zyd_debug;
#endif
-
- if ((error = zyd_get_macaddr(sc)) != 0) {
- device_printf(sc->sc_dev, "could not read EEPROM\n");
- return (ENXIO);
- }
-
mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev),
MTX_NETWORK_LOCK, MTX_DEF);
+
USB_TASK_INIT(&sc->sc_task, zyd_task, sc, NULL);
USB_TASK_INIT(&sc->sc_scantask, zyd_scantask, sc, &sc->sc_mtx);
USB_TASK_INIT(&sc->sc_mcasttask, zyd_multitask, sc, &sc->sc_mtx);
STAILQ_INIT(&sc->sc_rqh);
+ iface_index = ZYD_IFACE_INDEX;
+ error = usb2_transfer_setup(uaa->device,
+ &iface_index, sc->sc_xfer, zyd_config,
+ ZYD_N_TRANSFER, sc, &sc->sc_mtx);
+ if (error) {
+ device_printf(dev, "could not allocate USB transfers, "
+ "err=%s\n", usb2_errstr(error));
+ goto fail0;
+ }
+ error = usb2_proc_create(&sc->sc_tq, USB_PRI_MED,
+ device_get_nameunit(dev));
+ if (error) {
+ device_printf(dev, "could not setup config thread!\n");
+ goto fail0;
+ }
+
+ if ((error = zyd_get_macaddr(sc)) != 0) {
+ device_printf(sc->sc_dev, "could not read EEPROM\n");
+ error = ENXIO;
+ goto fail0;
+ }
+
ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
@@ -395,8 +409,7 @@ zyd_attach(device_t dev)
}
ifp->if_softc = sc;
if_initname(ifp, "zyd", device_get_unit(sc->sc_dev));
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
- IFF_NEEDSGIANT; /* USB stack is still under Giant lock */
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_init = zyd_init;
ifp->if_ioctl = zyd_ioctl;
ifp->if_start = zyd_start;
@@ -1958,11 +1971,13 @@ zyd_get_macaddr(struct zyd_softc *sc)
USETW(req.wIndex, 0);
USETW(req.wLength, IEEE80211_ADDR_LEN);
+ ZYD_LOCK(sc);
error = usb2_do_request(sc->sc_udev, &sc->sc_mtx, &req, sc->sc_bssid);
if (error != 0) {
device_printf(sc->sc_dev, "could not read EEPROM: %s\n",
usb2_errstr(error));
}
+ ZYD_UNLOCK(sc);
return (error);
}
@@ -2286,9 +2301,9 @@ zyd_bulk_read_callback(struct usb2_xfer
int8_t nf;
int i, rxcount;
+ rxcount = 0;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
-
if (xfer->actlen < MAX(sizeof(desc), ZYD_MIN_FRAGSZ)) {
DPRINTF(sc, ZYD_DEBUG_ANY, "xfer too short, %d bytes\n", xfer->actlen);
ifp->if_ierrors++;
@@ -2297,7 +2312,7 @@ zyd_bulk_read_callback(struct usb2_xfer
usb2_copy_out(xfer->frbuffers, xfer->actlen - sizeof(desc),
&desc, sizeof(desc));
- rxcount = offset = 0;
+ offset = 0;
if (UGETW(desc.tag) == ZYD_TAG_MULTIFRAME) {
DPRINTF(sc, ZYD_DEBUG_RECV,
"%s: received multi-frame transfer\n", __func__);
@@ -2347,7 +2362,8 @@ tr_setup:
nf = -95; /* XXX */
- ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *));
+ ni = ieee80211_find_rxnode(ic,
+ mtod(m, struct ieee80211_frame_min *));
if (ni != NULL) {
(void)ieee80211_input(ni, m, rssi, nf, 0);
ieee80211_free_node(ni);
More information about the svn-src-user
mailing list