Commit | Line | Data |
---|---|---|
cf4328cd ID |
1 | #ifndef __RFKILL_H |
2 | #define __RFKILL_H | |
3 | ||
4 | /* | |
fe242cfd | 5 | * Copyright (C) 2006 - 2007 Ivo van Doorn |
cf4328cd ID |
6 | * Copyright (C) 2007 Dmitry Torokhov |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the | |
20 | * Free Software Foundation, Inc., | |
21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | */ | |
23 | ||
24 | #include <linux/types.h> | |
25 | #include <linux/kernel.h> | |
26 | #include <linux/list.h> | |
27 | #include <linux/mutex.h> | |
28 | #include <linux/device.h> | |
135900c1 | 29 | #include <linux/leds.h> |
cf4328cd ID |
30 | |
31 | /** | |
32 | * enum rfkill_type - type of rfkill switch. | |
279632be MB |
33 | * RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. |
34 | * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. | |
35 | * RFKILL_TYPE_UWB: switch is on a ultra wideband device. | |
cf4328cd ID |
36 | */ |
37 | enum rfkill_type { | |
234a0ca6 ID |
38 | RFKILL_TYPE_WLAN , |
39 | RFKILL_TYPE_BLUETOOTH, | |
e0665486 | 40 | RFKILL_TYPE_UWB, |
234a0ca6 | 41 | RFKILL_TYPE_MAX, |
cf4328cd ID |
42 | }; |
43 | ||
44 | enum rfkill_state { | |
45 | RFKILL_STATE_OFF = 0, | |
46 | RFKILL_STATE_ON = 1, | |
47 | }; | |
48 | ||
49 | /** | |
50 | * struct rfkill - rfkill control structure. | |
51 | * @name: Name of the switch. | |
52 | * @type: Radio type which the button controls, the value stored | |
53 | * here should be a value from enum rfkill_type. | |
54 | * @state: State of the switch (on/off). | |
55 | * @user_claim: Set when the switch is controlled exlusively by userspace. | |
56 | * @mutex: Guards switch state transitions | |
57 | * @data: Pointer to the RF button drivers private data which will be | |
58 | * passed along when toggling radio state. | |
59 | * @toggle_radio(): Mandatory handler to control state of the radio. | |
135900c1 | 60 | * @led_trigger: A LED trigger for this button's LED. |
cf4328cd ID |
61 | * @dev: Device structure integrating the switch into device tree. |
62 | * @node: Used to place switch into list of all switches known to the | |
63 | * the system. | |
64 | * | |
65 | * This structure represents a RF switch located on a network device. | |
66 | */ | |
67 | struct rfkill { | |
c36befb5 | 68 | const char *name; |
cf4328cd ID |
69 | enum rfkill_type type; |
70 | ||
71 | enum rfkill_state state; | |
72 | bool user_claim; | |
73 | ||
74 | struct mutex mutex; | |
75 | ||
76 | void *data; | |
77 | int (*toggle_radio)(void *data, enum rfkill_state state); | |
78 | ||
135900c1 MB |
79 | #ifdef CONFIG_RFKILL_LEDS |
80 | struct led_trigger led_trigger; | |
81 | #endif | |
82 | ||
cf4328cd ID |
83 | struct device dev; |
84 | struct list_head node; | |
85 | }; | |
86 | #define to_rfkill(d) container_of(d, struct rfkill, dev) | |
87 | ||
88 | struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type); | |
89 | void rfkill_free(struct rfkill *rfkill); | |
90 | int rfkill_register(struct rfkill *rfkill); | |
91 | void rfkill_unregister(struct rfkill *rfkill); | |
92 | ||
135900c1 MB |
93 | /** |
94 | * rfkill_get_led_name - Get the LED trigger name for the button's LED. | |
95 | * This function might return a NULL pointer if registering of the | |
96 | * LED trigger failed. | |
97 | * Use this as "default_trigger" for the LED. | |
98 | */ | |
99 | static inline char *rfkill_get_led_name(struct rfkill *rfkill) | |
100 | { | |
101 | #ifdef CONFIG_RFKILL_LEDS | |
102 | return (char *)(rfkill->led_trigger.name); | |
103 | #else | |
104 | return NULL; | |
105 | #endif | |
106 | } | |
107 | ||
cf4328cd | 108 | #endif /* RFKILL_H */ |