Deleted Added
full compact
if_upgt.c (246565) if_upgt.c (246614)
1/* $OpenBSD: if_upgt.c,v 1.35 2008/04/16 18:32:15 damien Exp $ */
1/* $OpenBSD: if_upgt.c,v 1.35 2008/04/16 18:32:15 damien Exp $ */
2/* $FreeBSD: head/sys/dev/usb/wlan/if_upgt.c 246565 2013-02-08 21:15:47Z hselasky $ */
2/* $FreeBSD: head/sys/dev/usb/wlan/if_upgt.c 246614 2013-02-10 10:36:16Z hselasky $ */
3
4/*
5 * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *

--- 450 unchanged lines hidden (view full) ---

461}
462
463static int
464upgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
465{
466 struct upgt_softc *sc = ifp->if_softc;
467 struct ieee80211com *ic = ifp->if_l2com;
468 struct ifreq *ifr = (struct ifreq *) data;
3
4/*
5 * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *

--- 450 unchanged lines hidden (view full) ---

461}
462
463static int
464upgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
465{
466 struct upgt_softc *sc = ifp->if_softc;
467 struct ieee80211com *ic = ifp->if_l2com;
468 struct ifreq *ifr = (struct ifreq *) data;
469 int error = 0, startall = 0;
469 int error;
470 int startall = 0;
470
471
472 UPGT_LOCK(sc);
473 error = (sc->sc_flags & UPGT_FLAG_DETACHED) ? ENXIO : 0;
474 UPGT_UNLOCK(sc);
475 if (error)
476 return (error);
477
471 switch (cmd) {
472 case SIOCSIFFLAGS:
473 if (ifp->if_flags & IFF_UP) {
474 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
475 if ((ifp->if_flags ^ sc->sc_if_flags) &
476 (IFF_ALLMULTI | IFF_PROMISC))
477 upgt_set_multi(sc);
478 } else {

--- 1492 unchanged lines hidden (view full) ---

1971 STAILQ_INIT(&sc->sc_rx_active);
1972 STAILQ_INIT(&sc->sc_rx_inactive);
1973
1974 for (i = 0; i < UPGT_RX_MAXCOUNT; i++) {
1975 struct upgt_data *data = &sc->sc_rx_data[i];
1976 data->buf = ((uint8_t *)sc->sc_rx_dma_buf) + (i * MCLBYTES);
1977 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1978 }
478 switch (cmd) {
479 case SIOCSIFFLAGS:
480 if (ifp->if_flags & IFF_UP) {
481 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
482 if ((ifp->if_flags ^ sc->sc_if_flags) &
483 (IFF_ALLMULTI | IFF_PROMISC))
484 upgt_set_multi(sc);
485 } else {

--- 1492 unchanged lines hidden (view full) ---

1978 STAILQ_INIT(&sc->sc_rx_active);
1979 STAILQ_INIT(&sc->sc_rx_inactive);
1980
1981 for (i = 0; i < UPGT_RX_MAXCOUNT; i++) {
1982 struct upgt_data *data = &sc->sc_rx_data[i];
1983 data->buf = ((uint8_t *)sc->sc_rx_dma_buf) + (i * MCLBYTES);
1984 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1985 }
1979
1980 return (0);
1981}
1982
1983static int
1984upgt_detach(device_t dev)
1985{
1986 struct upgt_softc *sc = device_get_softc(dev);
1987 struct ifnet *ifp = sc->sc_ifp;
1988 struct ieee80211com *ic = ifp->if_l2com;
1986 return (0);
1987}
1988
1989static int
1990upgt_detach(device_t dev)
1991{
1992 struct upgt_softc *sc = device_get_softc(dev);
1993 struct ifnet *ifp = sc->sc_ifp;
1994 struct ieee80211com *ic = ifp->if_l2com;
1995 unsigned int x;
1989
1996
1990 if (!device_is_attached(dev))
1991 return 0;
1997 /*
1998 * Prevent further allocations from RX/TX/CMD
1999 * data lists and ioctls
2000 */
2001 UPGT_LOCK(sc);
2002 sc->sc_flags |= UPGT_FLAG_DETACHED;
1992
2003
2004 STAILQ_INIT(&sc->sc_tx_active);
2005 STAILQ_INIT(&sc->sc_tx_inactive);
2006 STAILQ_INIT(&sc->sc_tx_pending);
2007
2008 STAILQ_INIT(&sc->sc_rx_active);
2009 STAILQ_INIT(&sc->sc_rx_inactive);
2010 UPGT_UNLOCK(sc);
2011
1993 upgt_stop(sc);
1994
1995 callout_drain(&sc->sc_led_ch);
1996 callout_drain(&sc->sc_watchdog_ch);
1997
2012 upgt_stop(sc);
2013
2014 callout_drain(&sc->sc_led_ch);
2015 callout_drain(&sc->sc_watchdog_ch);
2016
1998 ieee80211_ifdetach(ic);
2017 /* drain USB transfers */
2018 for (x = 0; x != UPGT_N_XFERS; x++)
2019 usbd_transfer_drain(sc->sc_xfer[x]);
1999
2020
2000 usbd_transfer_unsetup(sc->sc_xfer, UPGT_N_XFERS);
2001
2021 /* free data buffers */
2022 UPGT_LOCK(sc);
2002 upgt_free_rx(sc);
2003 upgt_free_tx(sc);
2023 upgt_free_rx(sc);
2024 upgt_free_tx(sc);
2025 UPGT_UNLOCK(sc);
2004
2026
2027 /* free USB transfers and some data buffers */
2028 usbd_transfer_unsetup(sc->sc_xfer, UPGT_N_XFERS);
2029
2030 ieee80211_ifdetach(ic);
2005 if_free(ifp);
2006 mtx_destroy(&sc->sc_mtx);
2007
2008 return (0);
2009}
2010
2011static void
2012upgt_free_rx(struct upgt_softc *sc)

--- 11 unchanged lines hidden (view full) ---

2024static void
2025upgt_free_tx(struct upgt_softc *sc)
2026{
2027 int i;
2028
2029 for (i = 0; i < UPGT_TX_MAXCOUNT; i++) {
2030 struct upgt_data *data = &sc->sc_tx_data[i];
2031
2031 if_free(ifp);
2032 mtx_destroy(&sc->sc_mtx);
2033
2034 return (0);
2035}
2036
2037static void
2038upgt_free_rx(struct upgt_softc *sc)

--- 11 unchanged lines hidden (view full) ---

2050static void
2051upgt_free_tx(struct upgt_softc *sc)
2052{
2053 int i;
2054
2055 for (i = 0; i < UPGT_TX_MAXCOUNT; i++) {
2056 struct upgt_data *data = &sc->sc_tx_data[i];
2057
2058 if (data->ni != NULL)
2059 ieee80211_free_node(data->ni);
2060
2032 data->buf = NULL;
2033 data->ni = NULL;
2034 }
2035}
2036
2037static void
2038upgt_abort_xfers_locked(struct upgt_softc *sc)
2039{

--- 353 unchanged lines hidden ---
2061 data->buf = NULL;
2062 data->ni = NULL;
2063 }
2064}
2065
2066static void
2067upgt_abort_xfers_locked(struct upgt_softc *sc)
2068{

--- 353 unchanged lines hidden ---