diff options
| author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-02 07:01:37 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2009-06-03 14:06:13 -0400 |
| commit | 19d337dff95cbf76edd3ad95c0cee2732c3e1ec5 (patch) | |
| tree | 33326eeb09cb9664cc8427a5dc7cd2b08b5a57c3 | |
| parent | 0f6399c4c525b518644a9b09f8d6fb125a418c4d (diff) | |
rfkill: rewrite
This patch completely rewrites the rfkill core to address
the following deficiencies:
* all rfkill drivers need to implement polling where necessary
rather than having one central implementation
* updating the rfkill state cannot be done from arbitrary
contexts, forcing drivers to use schedule_work and requiring
lots of code
* rfkill drivers need to keep track of soft/hard blocked
internally -- the core should do this
* the rfkill API has many unexpected quirks, for example being
asymmetric wrt. alloc/free and register/unregister
* rfkill can call back into a driver from within a function the
driver called -- this is prone to deadlocks and generally
should be avoided
* rfkill-input pointlessly is a separate module
* drivers need to #ifdef rfkill functions (unless they want to
depend on or select RFKILL) -- rfkill should provide inlines
that do nothing if it isn't compiled in
* the rfkill structure is not opaque -- drivers need to initialise
it correctly (lots of sanity checking code required) -- instead
force drivers to pass the right variables to rfkill_alloc()
* the documentation is hard to read because it always assumes the
reader is completely clueless and contains way TOO MANY CAPS
* the rfkill code needlessly uses a lot of locks and atomic
operations in locked sections
* fix LED trigger to actually change the LED when the radio state
changes -- this wasn't done before
Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
46 files changed, 2536 insertions, 3273 deletions
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt index 40c3a3f1081..de941e309d4 100644 --- a/Documentation/rfkill.txt +++ b/Documentation/rfkill.txt | |||
| @@ -1,571 +1,130 @@ | |||
| 1 | rfkill - RF switch subsystem support | 1 | rfkill - RF kill switch support |
| 2 | ==================================== | 2 | =============================== |
| 3 | 3 | ||
| 4 | 1 Introduction | 4 | 1. Introduction |
| 5 | 2 Implementation details | 5 | 2. Implementation details |
| 6 | 3 Kernel driver guidelines | 6 | 3. Kernel driver guidelines |
| 7 | 3.1 wireless device drivers | 7 | 4. Kernel API |
| 8 | 3.2 platform/switch drivers | 8 | 5. Userspace support |
| 9 | 3.3 input device drivers | ||
| 10 | 4 Kernel API | ||
| 11 | 5 Userspace support | ||
| 12 | 9 | ||
| 13 | 10 | ||
| 14 | 1. Introduction: | 11 | 1. Introduction |
| 15 | 12 | ||
| 16 | The rfkill switch subsystem exists to add a generic interface to circuitry that | 13 | The rfkill subsystem provides a generic interface to disabling any radio |
| 17 | can enable or disable the signal output of a wireless *transmitter* of any | 14 | transmitter in the system. When a transmitter is blocked, it shall not |
| 18 | type. By far, the most common use is to disable radio-frequency transmitters. | 15 | radiate any power. |
| 19 | 16 | ||
| 20 | Note that disabling the signal output means that the the transmitter is to be | 17 | The subsystem also provides the ability to react on button presses and |
| 21 | made to not emit any energy when "blocked". rfkill is not about blocking data | 18 | disable all transmitters of a certain type (or all). This is intended for |
| 22 | transmissions, it is about blocking energy emission. | 19 | situations where transmitters need to be turned off, for example on |
| 20 | aircraft. | ||
| 23 | 21 | ||
| 24 | The rfkill subsystem offers support for keys and switches often found on | ||
| 25 | laptops to enable wireless devices like WiFi and Bluetooth, so that these keys | ||
| 26 | and switches actually perform an action in all wireless devices of a given type | ||
| 27 | attached to the system. | ||
| 28 | 22 | ||
| 29 | The buttons to enable and disable the wireless transmitters are important in | ||
| 30 | situations where the user is for example using his laptop on a location where | ||
| 31 | radio-frequency transmitters _must_ be disabled (e.g. airplanes). | ||
| 32 | 23 | ||
| 33 | Because of this requirement, userspace support for the keys should not be made | 24 | 2. Implementation details |
| 34 | mandatory. Because userspace might want to perform some additional smarter | ||
| 35 | tasks when the key is pressed, rfkill provides userspace the possibility to | ||
| 36 | take over the task to handle the key events. | ||
| 37 | |||
| 38 | =============================================================================== | ||
| 39 | 2: Implementation details | ||
| 40 | 25 | ||
| 41 | The rfkill subsystem is composed of various components: the rfkill class, the | 26 | The rfkill subsystem is composed of various components: the rfkill class, the |
| 42 | rfkill-input module (an input layer handler), and some specific input layer | 27 | rfkill-input module (an input layer handler), and some specific input layer |
| 43 | events. | 28 | events. |
| 44 | 29 | ||
| 45 | The rfkill class provides kernel drivers with an interface that allows them to | 30 | The rfkill class is provided for kernel drivers to register their radio |
| 46 | know when they should enable or disable a wireless network device transmitter. | 31 | transmitter with the kernel, provide methods for turning it on and off and, |
| 47 | This is enabled by the CONFIG_RFKILL Kconfig option. | 32 | optionally, letting the system know about hardware-disabled states that may |
| 48 | 33 | be implemented on the device. This code is enabled with the CONFIG_RFKILL | |
| 49 | The rfkill class support makes sure userspace will be notified of all state | 34 | Kconfig option, which drivers can "select". |
| 50 | changes on rfkill devices through uevents. It provides a notification chain | ||
| 51 | for interested parties in the kernel to also get notified of rfkill state | ||
| 52 | changes in other drivers. It creates several sysfs entries which can be used | ||
| 53 | by userspace. See section "Userspace support". | ||
| 54 | |||
| 55 | The rfkill-input module provides the kernel with the ability to implement a | ||
| 56 | basic response when the user presses a key or button (or toggles a switch) | ||
| 57 | related to rfkill functionality. It is an in-kernel implementation of default | ||
| 58 | policy of reacting to rfkill-related input events and neither mandatory nor | ||
| 59 | required for wireless drivers to operate. It is enabled by the | ||
| 60 | CONFIG_RFKILL_INPUT Kconfig option. | ||
| 61 | |||
| 62 | rfkill-input is a rfkill-related events input layer handler. This handler will | ||
| 63 | listen to all rfkill key events and will change the rfkill state of the | ||
| 64 | wireless devices accordingly. With this option enabled userspace could either | ||
| 65 | do nothing or simply perform monitoring tasks. | ||
| 66 | |||
| 67 | The rfkill-input module also provides EPO (emergency power-off) functionality | ||
| 68 | for all wireless transmitters. This function cannot be overridden, and it is | ||
| 69 | always active. rfkill EPO is related to *_RFKILL_ALL input layer events. | ||
| 70 | |||
| 71 | |||
| 72 | Important terms for the rfkill subsystem: | ||
| 73 | |||
| 74 | In order to avoid confusion, we avoid the term "switch" in rfkill when it is | ||
| 75 | referring to an electronic control circuit that enables or disables a | ||
| 76 | transmitter. We reserve it for the physical device a human manipulates | ||
| 77 | (which is an input device, by the way): | ||
| 78 | |||
| 79 | rfkill switch: | ||
| 80 | |||
| 81 | A physical device a human manipulates. Its state can be perceived by | ||
| 82 | the kernel either directly (through a GPIO pin, ACPI GPE) or by its | ||
| 83 | effect on a rfkill line of a wireless device. | ||
| 84 | |||
| 85 | rfkill controller: | ||
| 86 | |||
| 87 | A hardware circuit that controls the state of a rfkill line, which a | ||
| 88 | kernel driver can interact with *to modify* that state (i.e. it has | ||
| 89 | either write-only or read/write access). | ||
| 90 | |||
| 91 | rfkill line: | ||
| 92 | |||
| 93 | An input channel (hardware or software) of a wireless device, which | ||
| 94 | causes a wireless transmitter to stop emitting energy (BLOCK) when it | ||
| 95 | is active. Point of view is extremely important here: rfkill lines are | ||
| 96 | always seen from the PoV of a wireless device (and its driver). | ||
| 97 | |||
| 98 | soft rfkill line/software rfkill line: | ||
| 99 | |||
| 100 | A rfkill line the wireless device driver can directly change the state | ||
| 101 | of. Related to rfkill_state RFKILL_STATE_SOFT_BLOCKED. | ||
