| @@ -1,39 +1,39 @@ | | | @@ -1,39 +1,39 @@ |
1 | /* $NetBSD: if_run.c,v 1.10 2014/01/28 13:08:13 martin Exp $ */ | | 1 | /* $NetBSD: if_run.c,v 1.11 2015/03/13 15:33:04 nonaka Exp $ */ |
2 | /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ | | 2 | /* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr> | | 5 | * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr> |
6 | * | | 6 | * |
7 | * Permission to use, copy, modify, and distribute this software for any | | 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 | | 8 | * purpose with or without fee is hereby granted, provided that the above |
9 | * copyright notice and this permission notice appear in all copies. | | 9 | * copyright notice and this permission notice appear in all copies. |
10 | * | | 10 | * |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ | | 18 | */ |
19 | | | 19 | |
20 | /*- | | 20 | /*- |
21 | * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver. | | 21 | * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver. |
22 | * http://www.ralinktech.com/ | | 22 | * http://www.ralinktech.com/ |
23 | */ | | 23 | */ |
24 | | | 24 | |
25 | #include <sys/cdefs.h> | | 25 | #include <sys/cdefs.h> |
26 | __KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.10 2014/01/28 13:08:13 martin Exp $"); | | 26 | __KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.11 2015/03/13 15:33:04 nonaka Exp $"); |
27 | | | 27 | |
28 | #include <sys/param.h> | | 28 | #include <sys/param.h> |
29 | #include <sys/sockio.h> | | 29 | #include <sys/sockio.h> |
30 | #include <sys/sysctl.h> | | 30 | #include <sys/sysctl.h> |
31 | #include <sys/mbuf.h> | | 31 | #include <sys/mbuf.h> |
32 | #include <sys/kernel.h> | | 32 | #include <sys/kernel.h> |
33 | #include <sys/socket.h> | | 33 | #include <sys/socket.h> |
34 | #include <sys/systm.h> | | 34 | #include <sys/systm.h> |
35 | #include <sys/malloc.h> | | 35 | #include <sys/malloc.h> |
36 | #include <sys/callout.h> | | 36 | #include <sys/callout.h> |
37 | #include <sys/module.h> | | 37 | #include <sys/module.h> |
38 | #include <sys/conf.h> | | 38 | #include <sys/conf.h> |
39 | #include <sys/device.h> | | 39 | #include <sys/device.h> |
| @@ -652,39 +652,44 @@ run_attach(device_t parent, device_t sel | | | @@ -652,39 +652,44 @@ run_attach(device_t parent, device_t sel |
652 | &sc->sc_drvbpf); | | 652 | &sc->sc_drvbpf); |
653 | | | 653 | |
654 | sc->sc_rxtap_len = sizeof(sc->sc_rxtapu); | | 654 | sc->sc_rxtap_len = sizeof(sc->sc_rxtapu); |
655 | sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len); | | 655 | sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len); |
656 | sc->sc_rxtap.wr_ihdr.it_present = htole32(RUN_RX_RADIOTAP_PRESENT); | | 656 | sc->sc_rxtap.wr_ihdr.it_present = htole32(RUN_RX_RADIOTAP_PRESENT); |
657 | | | 657 | |
658 | sc->sc_txtap_len = sizeof(sc->sc_txtapu); | | 658 | sc->sc_txtap_len = sizeof(sc->sc_txtapu); |
659 | sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len); | | 659 | sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len); |
660 | sc->sc_txtap.wt_ihdr.it_present = htole32(RUN_TX_RADIOTAP_PRESENT); | | 660 | sc->sc_txtap.wt_ihdr.it_present = htole32(RUN_TX_RADIOTAP_PRESENT); |
661 | | | 661 | |
662 | ieee80211_announce(ic); | | 662 | ieee80211_announce(ic); |
663 | | | 663 | |
664 | usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); | | 664 | usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); |
| | | 665 | |
| | | 666 | if (!pmf_device_register(self, NULL, NULL)) |
| | | 667 | aprint_error_dev(self, "couldn't establish power handler\n"); |
665 | } | | 668 | } |
666 | | | 669 | |
667 | static int | | 670 | static int |
668 | run_detach(device_t self, int flags) | | 671 | run_detach(device_t self, int flags) |
669 | { | | 672 | { |
670 | struct run_softc *sc = device_private(self); | | 673 | struct run_softc *sc = device_private(self); |
671 | struct ifnet *ifp = &sc->sc_if; | | 674 | struct ifnet *ifp = &sc->sc_if; |
672 | struct ieee80211com *ic = &sc->sc_ic; | | 675 | struct ieee80211com *ic = &sc->sc_ic; |
673 | int s; | | 676 | int s; |
674 | | | 677 | |
675 | if (ifp->if_softc == NULL) | | 678 | if (ifp->if_softc == NULL) |
676 | return (0); | | 679 | return (0); |
677 | | | 680 | |
| | | 681 | pmf_device_deregister(self); |
| | | 682 | |
678 | s = splnet(); | | 683 | s = splnet(); |
679 | | | 684 | |
680 | sc->sc_flags |= RUN_DETACHING; | | 685 | sc->sc_flags |= RUN_DETACHING; |
681 | | | 686 | |
682 | if (ifp->if_flags & IFF_RUNNING) { | | 687 | if (ifp->if_flags & IFF_RUNNING) { |
683 | usb_rem_task(sc->sc_udev, &sc->sc_task); | | 688 | usb_rem_task(sc->sc_udev, &sc->sc_task); |
684 | run_stop(ifp, 0); | | 689 | run_stop(ifp, 0); |
685 | } | | 690 | } |
686 | | | 691 | |
687 | ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); | | 692 | ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); |
688 | bpf_detach(ifp); | | 693 | bpf_detach(ifp); |
689 | ieee80211_ifdetach(ic); | | 694 | ieee80211_ifdetach(ic); |
690 | if_detach(ifp); | | 695 | if_detach(ifp); |