diff options
author | Zhu Yi <yi.zhu@intel.com> | 2009-05-21 09:20:45 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-05-22 14:06:02 -0400 |
commit | bb9f8692f5043efef0dcef048cdd1db68299c2cb (patch) | |
tree | de0eade3ea6e40341727789a3a91e5c506b68759 /drivers/net/wireless/iwmc3200wifi/rfkill.c | |
parent | e31a16d6f64ef0e324c6f54d5112703c3f13a9c4 (diff) |
iwmc3200wifi: Add new Intel Wireless Multicomm 802.11 driver
This driver supports Intel's full MAC wireless multicomm 802.11 hardware.
Although the hardware is a 802.11agn device, we currently only support
802.11ag, in managed and ad-hoc mode (no AP mode for now).
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwmc3200wifi/rfkill.c')
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/rfkill.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/rfkill.c b/drivers/net/wireless/iwmc3200wifi/rfkill.c new file mode 100644 index 000000000000..4ca8b495f82d --- /dev/null +++ b/drivers/net/wireless/iwmc3200wifi/rfkill.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Intel Wireless Multicomm 3200 WiFi driver | ||
3 | * | ||
4 | * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com> | ||
5 | * Samuel Ortiz <samuel.ortiz@intel.com> | ||
6 | * Zhu Yi <yi.zhu@intel.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License version | ||
10 | * 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
20 | * 02110-1301, USA. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/rfkill.h> | ||
25 | |||
26 | #include "iwm.h" | ||
27 | |||
28 | static int iwm_rfkill_soft_toggle(void *data, enum rfkill_state state) | ||
29 | { | ||
30 | struct iwm_priv *iwm = data; | ||
31 | |||
32 | switch (state) { | ||
33 | case RFKILL_STATE_UNBLOCKED: | ||
34 | if (test_bit(IWM_RADIO_RFKILL_HW, &iwm->radio)) | ||
35 | return -EBUSY; | ||
36 | |||
37 | if (test_and_clear_bit(IWM_RADIO_RFKILL_SW, &iwm->radio) && | ||
38 | (iwm_to_ndev(iwm)->flags & IFF_UP)) | ||
39 | iwm_up(iwm); | ||
40 | |||
41 | break; | ||
42 | case RFKILL_STATE_SOFT_BLOCKED: | ||
43 | if (!test_and_set_bit(IWM_RADIO_RFKILL_SW, &iwm->radio)) | ||
44 | iwm_down(iwm); | ||
45 | |||
46 | break; | ||
47 | default: | ||
48 | break; | ||
49 | } | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | int iwm_rfkill_init(struct iwm_priv *iwm) | ||
55 | { | ||
56 | int ret; | ||
57 | |||
58 | iwm->rfkill = rfkill_allocate(iwm_to_dev(iwm), RFKILL_TYPE_WLAN); | ||
59 | if (!iwm->rfkill) { | ||
60 | IWM_ERR(iwm, "Unable to allocate rfkill device\n"); | ||
61 | return -ENOMEM; | ||
62 | } | ||
63 | |||
64 | iwm->rfkill->name = KBUILD_MODNAME; | ||
65 | iwm->rfkill->data = iwm; | ||
66 | iwm->rfkill->state = RFKILL_STATE_UNBLOCKED; | ||
67 | iwm->rfkill->toggle_radio = iwm_rfkill_soft_toggle; | ||
68 | |||
69 | ret = rfkill_register(iwm->rfkill); | ||
70 | if (ret) { | ||
71 | IWM_ERR(iwm, "Failed to register rfkill device\n"); | ||
72 | goto fail; | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | fail: | ||
77 | rfkill_free(iwm->rfkill); | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | void iwm_rfkill_exit(struct iwm_priv *iwm) | ||
82 | { | ||
83 | if (iwm->rfkill) | ||
84 | rfkill_unregister(iwm->rfkill); | ||
85 | |||
86 | rfkill_free(iwm->rfkill); | ||
87 | iwm->rfkill = NULL; | ||
88 | } | ||