rfkill: rewrite
Subsystems (16)
Johannes Berg
maintainerPATCH v10 1/1 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
---
v3: * fix locking bugs
* fix bug in input.c that made it ignore things
* allow setting LED trigger name
* apply default state while registering
* convert HSO
v4: * LED triggering
v5: * convert sony
* introduce rfkill_set_states function
* change query/poll methods to require calls to rfkill_set{_sw,_hw}_state/rfkill_set_states
* do not call driver from registration
* remove tested-by since it changed a lot
v6: * fix stupid sync work bugs
v7: * fix setting states before registration
* make EEEPC resume properly [Alan Jenkins]
v8: * move one rfkill_set_state call under the mutex
* protect things with spinlock and take care to close the race Henrique pointed out
* add note about set_block race
* remove tested-by again, the spinlock change is a little too invasive to claim testing
v9: * fix documentation on query op
* push sw state to device on resume
* remove thing about not calling device while hw blocked -- the call can be ignored but we can't avoid it due to races anyway
* convert toshiba
v10: * fix whitespace error pointed out by Alan Jenkins
* thinkpad conversion from hmh
* fix bug in input.c (thanks hmh)
* make a function static
* fix eeepc conversion (again? what happened here?)
* correct rfkill Kconfig dependencies in platform drivers
* fix eeepc bluetooth name
* correct led-trigger dependencies
* build input handler only if input support in kernel
* fix bug with RFKILL_BLOCK_SW_PREV by resetting it
More work will be needed on locking eventually, but since the old rfkill core had horrible locking drivers are prepared to deal with that and I don't need to do this right away.
Documentation/rfkill.txt | 637 +++------------------ MAINTAINERS | 6 arch/arm/mach-pxa/tosa-bt.c | 30 - arch/arm/mach-pxa/tosa.c | 1 drivers/net/usb/hso.c | 42 - drivers/net/wireless/ath/ath9k/ath9k.h | 7 drivers/net/wireless/ath/ath9k/main.c | 115 --- drivers/net/wireless/ath/ath9k/pci.c | 15 drivers/net/wireless/b43/Kconfig | 2 drivers/net/wireless/b43/leds.c | 2 drivers/net/wireless/b43/main.c | 4 drivers/net/wireless/b43/phy_a.c | 4 drivers/net/wireless/b43/phy_common.c | 17 drivers/net/wireless/b43/phy_common.h | 4 drivers/net/wireless/b43/phy_g.c | 4 drivers/net/wireless/b43/phy_lp.c | 2 drivers/net/wireless/b43/phy_n.c | 2 drivers/net/wireless/b43/rfkill.c | 123 +--- drivers/net/wireless/b43/rfkill.h | 5 drivers/net/wireless/b43legacy/Kconfig | 2 drivers/net/wireless/b43legacy/leds.c | 3 drivers/net/wireless/b43legacy/rfkill.c | 123 +--- drivers/net/wireless/b43legacy/rfkill.h | 6 drivers/net/wireless/iwlwifi/Kconfig | 5 drivers/net/wireless/iwlwifi/iwl-rfkill.c | 69 -- drivers/platform/x86/Kconfig | 14 drivers/platform/x86/acer-wmi.c | 50 - drivers/platform/x86/dell-laptop.c | 101 +-- drivers/platform/x86/eeepc-laptop.c | 99 --- drivers/platform/x86/hp-wmi.c | 103 +-- drivers/platform/x86/sony-laptop.c | 191 ++---- drivers/platform/x86/thinkpad_acpi.c | 869 +++++++++++++++-------------- drivers/platform/x86/toshiba_acpi.c | 159 +---- include/linux/Kbuild | 1 include/linux/rfkill.h | 327 ++++++++-- include/net/wimax.h | 8 net/rfkill/Kconfig | 21 net/rfkill/Makefile | 5 net/rfkill/core.c | 896 ++++++++++++++++++++++++++++++ net/rfkill/input.c | 342 +++++++++++ net/rfkill/rfkill-input.c | 390 ------------- net/rfkill/rfkill-input.h | 21 net/rfkill/rfkill.c | 855 ---------------------------- net/rfkill/rfkill.h | 27 net/wimax/Kconfig | 14 net/wimax/op-rfkill.c | 123 ---- 46 files changed, 2557 insertions(+), 3289 deletions(-)
include/linux/rfkill.h +252 -75
@@ -4,6 +4,7 @@/* * Copyright (C) 2006 - 2007 Ivo van Doorn * Copyright (C) 2007 Dmitry Torokhov +* Copyright 2009 Johannes Berg <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -21,6 +22,24 @@* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* define userspace visible states */ +#define RFKILL_STATE_SOFT_BLOCKED 0 +#define RFKILL_STATE_UNBLOCKED 1 +#define RFKILL_STATE_HARD_BLOCKED 2 + +/* and that's all userspace gets */ +#ifdef __KERNEL__ +/* don't allow anyone to use these in the kernel */ +enum rfkill_user_states { +RFKILL_USER_STATE_SOFT_BLOCKED =RFKILL_STATE_SOFT_BLOCKED , +RFKILL_USER_STATE_UNBLOCKED =RFKILL_STATE_UNBLOCKED , +RFKILL_USER_STATE_HARD_BLOCKED =RFKILL_STATE_HARD_BLOCKED , +}; +#undef RFKILL_STATE_SOFT_BLOCKED +#undef RFKILL_STATE_UNBLOCKED +#undef RFKILL_STATE_HARD_BLOCKED +#include <linux/types.h> #include <linux/kernel.h> #include <linux/list.h>
@@ -30,109 +49,267 @@/** * enum rfkill_type - type of rfkill switch. -* RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. -* RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. -* RFKILL_TYPE_UWB: switch is on a ultra wideband device. -* RFKILL_TYPE_WIMAX: switch is on a WiMAX device. -* RFKILL_TYPE_WWAN: switch is on a wireless WAN device. +* +* @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. +* @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. +* @RFKILL_TYPE_UWB: switch is on a ultra wideband device. +* @RFKILL_TYPE_WIMAX: switch is on a WiMAX device. +* @RFKILL_TYPE_WWAN: switch is on a wireless WAN device. +* @NUM_RFKILL_TYPES: number of defined rfkill types */ enum rfkill_type { -RFKILL_TYPE_WLAN , +RFKILL_TYPE_WLAN ,RFKILL_TYPE_BLUETOOTH ,RFKILL_TYPE_UWB ,RFKILL_TYPE_WIMAX ,RFKILL_TYPE_WWAN , -RFKILL_TYPE_MAX , +NUM_RFKILL_TYPES , }; -enum rfkill_state { -RFKILL_STATE_SOFT_BLOCKED =0 ,/* Radio output blocked */ -RFKILL_STATE_UNBLOCKED =1 ,/* Radio output allowed */ -RFKILL_STATE_HARD_BLOCKED =2 ,/* Output blocked, non-overrideable */ -RFKILL_STATE_MAX ,/* marker for last valid state */ +/* this is opaque */ +struct rfkill ; + +/** +* struct rfkill_ops - rfkill driver methods +* +* @poll: poll the rfkill block state(s) -- only assign this method +* when you need polling. When called, simply call one of the +* rfkill_set{,_hw,_sw}_state family of functions. If the hw +* is getting unblocked you need to take into account the return +* value of those functions to make sure the software block is +* properly used. +* @query: query the rfkill block state(s) and call exactly one of the +* rfkill_set{,_hw,_sw}_state family of functions. Assign this +* method if input events can cause hardware state changes to make +* the rfkill core query your driver before setting a requested +* block. +* @set_block: turn the transmitter on (blocked == false) or off +* (blocked == true) -- this is called only while the transmitter +* is not hard-blocked, but note that the core's view of whether +* the transmitter is hard-blocked might differ from your driver's +* view due to race conditions, so it is possible that it is still +* called at the same time as you are calling rfkill_set_hw_state(). +* This callback must be assigned. +*/ +struct rfkill_ops { +void (*poll)(struct rfkill *rfkill,void *data); +void (*query)(struct rfkill *rfkill,void *data); +int (*set_block)(void *data,bool blocked); }; +#if defined(CONFIG_RFKILL ) || defined(CONFIG_RFKILL_MODULE )/** -* struct rfkill - rfkill control structure. -* @name: Name of the switch. -* @type: Radio type which the button controls, the value stored -* here should be a value from enum rfkill_type. -* @state: State of the switch, "UNBLOCKED" means radio can operate. -* @mutex: Guards switch state transitions. It serializes callbacks -* and also protects the state. -* @data: Pointer to the RF button drivers private data which will be -* passed along when toggling radio state. -* @toggle_radio(): Mandatory handler to control state of the radio. -* only RFKILL_STATE_SOFT_BLOCKED and RFKILL_STATE_UNBLOCKED are -* valid parameters. -* @get_state(): handler to read current radio state from hardware, -* may be called from atomic context, should return 0 on success. -* Either this handler OR judicious use of rfkill_force_state() is -* MANDATORY for any driver capable of RFKILL_STATE_HARD_BLOCKED. -* @led_trigger: A LED trigger for this button's LED. -* @dev: Device structure integrating the switch into device tree. -* @node: Used to place switch into list of all switches known to the -* the system. -* -* This structure represents a RF switch located on a network device. -*/ -struct rfkill { -const char *name; -enum rfkill_type type; - -/* the mutex serializes callbacks and also protects -* the state */ -struct mutex mutex; -enum rfkill_state state; -void *data; -int (*toggle_radio)(void *data,enum rfkill_state state); -int (*get_state)(void *data,enum rfkill_state *state); +* rfkill_alloc - allocate rfkill structure +* @name: name of the struct -- the string is not copied internally +* @parent: device that has rf switch on it +* @type: type of the switch (RFKILL_TYPE_*) +* @ops: rfkill methods +* @ops_data: data passed to each method +* +* This function should be called by the transmitter driver to allocate an +* rfkill structure. Returns %NULL on failure. +*/ +struct rfkill *__must_check rfkill_alloc (const char *name, +struct device *parent, +const enum rfkill_type type, +const struct rfkill_ops *ops, +void *ops_data); -#ifdef CONFIG_RFKILL_LEDS -struct led_trigger led_trigger; -#endif +/** +* rfkill_register - Register a rfkill structure. +* @rfkill: rfkill structure to be registered +* +* This function should be called by the transmitter driver to register +* the rfkill structure needs to be registered. Before calling this function +* the driver needs to be ready to service method calls from rfkill. +*/ +int __must_check rfkill_register (struct rfkill *rfkill); -struct device dev; -struct list_head node; -enum rfkill_state state_for_resume; -}; -#define to_rfkill (d) container_of(d, struct rfkill, dev) +/** +* rfkill_pause_polling(struct rfkill *rfkill) +* +* Pause polling -- say transmitter is off for other reasons. +* NOTE: not necessary for suspend/resume -- in that case the +* core stops polling anyway +*/ +void rfkill_pause_polling (struct rfkill *rfkill); -struct rfkill *__must_check rfkill_allocate (struct device *parent, -enum rfkill_type type); -void rfkill_free (struct rfkill *rfkill); -int __must_check rfkill_register (struct rfkill *rfkill); +/** +* rfkill_resume_polling(struct rfkill *rfkill) +* +* Pause polling -- say transmitter is off for other reasons. +* NOTE: not necessary for suspend/resume -- in that case the +* core stops polling anyway +*/ +void rfkill_resume_polling (struct rfkill *rfkill); + + +/** +* rfkill_unregister - Unregister a rfkill structure. +* @rfkill: rfkill structure to be unregistered +* +* This function should be called by the network driver during device +* teardown to destroy rfkill structure. Until it returns, the driver +* needs to be able to service method calls. +*/ void rfkill_unregister (struct rfkill *rfkill); -int rfkill_force_state (struct rfkill *rfkill,enum rfkill_state state); -int rfkill_set_default (enum rfkill_type type,enum rfkill_state state); +/** +* rfkill_destroy - free rfkill structure +* @rfkill: rfkill structure to be destroyed +* +* Destroys the rfkill structure. +*/ +void rfkill_destroy (struct rfkill *rfkill); + +/** +* rfkill_set_hw_state - Set the internal rfkill hardware block state +* @rfkill: pointer to the rfkill class to modify. +* @state: the current hardware block state to set +* +* rfkill drivers that get events when the hard-blocked state changes +* use this function to notify the rfkill core (and through that also +* userspace) of the current state -- they should also use this after +* resume if the state could have changed. +* +* You need not (but may) call this function if poll_state is assigned. +* +* This function can be called in any context, even from within rfkill +* callbacks. +* +* The function returns the combined block state (true if transmitter +* should be blocked) so that drivers need not keep track of the soft +* block state -- which they might not be able to. +*/ +bool __must_check rfkill_set_hw_state (struct rfkill *rfkill,bool blocked); + +/** +* rfkill_set_sw_state - Set the internal rfkill software block state +* @rfkill: pointer to the rfkill class to modify. +* @state: the current software block state to set +* +* rfkill drivers that get events when the soft-blocked state changes +* (yes, some platforms directly act on input but allow changing again) +* use this function to notify the rfkill core (and through that also +* userspace) of the current state -- they should also use this after +* resume if the state could have changed. +* +* This function can be called in any context, even from within rfkill +* callbacks. +* +* The function returns the combined block state (true if transmitter +* should be blocked). +*/ +bool rfkill_set_sw_state (struct rfkill *rfkill,bool blocked); + +/** +* rfkill_set_states - Set the internal rfkill block states +* @rfkill: pointer to the rfkill class to modify. +* @sw: the current software block state to set +* @hw: the current hardware block state to set +* +* This function can be called in any context, even from within rfkill +* callbacks. +*/ +void rfkill_set_states (struct rfkill *rfkill,bool sw,bool hw);/** -* rfkill_state_complement - return complementar state -* @state: state to return the complement of +* rfkill_set_global_sw_state - set global sw block default +* @type: rfkill type to set default for +* @blocked: default to set * -* Returns RFKILL_STATE_SOFT_BLOCKED if @state is RFKILL_STATE_UNBLOCKED, -* returns RFKILL_STATE_UNBLOCKED otherwise. +* This function sets the global default -- use at boot if your platform has +* an rfkill switch. If not early enough this call may be ignored. +* +* XXX: instead of ignoring -- how about just updating all currently +* registered drivers? */ -static inline enum rfkill_state rfkill_state_complement (enum rfkill_state state) +void rfkill_set_global_sw_state (const enum rfkill_type type,bool blocked); +#else /* !RFKILL */ +static inline struct rfkill *__must_check +rfkill_alloc (const char *name, +struct device *parent, +const enum rfkill_type type, +const struct rfkill_ops *ops, +void *ops_data) +{ +return ERR_PTR (-ENODEV ); +} + +static inline int __must_check rfkill_register (struct rfkill *rfkill) +{ +if (rfkill ==ERR_PTR (-ENODEV )) +return 0 ; +return -EINVAL ; +} + +static inline void rfkill_pause_polling (struct rfkill *rfkill) +{ +} + +static inline void rfkill_resume_polling (struct rfkill *rfkill) +{ +} + +static inline void rfkill_unregister (struct rfkill *rfkill) +{ +} + +static inline void rfkill_destroy (struct rfkill *rfkill) +{ +} + +static inline bool rfkill_set_hw_state (struct rfkill *rfkill,bool blocked) +{ +return blocked; +} + +static inline bool rfkill_set_sw_state (struct rfkill *rfkill,bool blocked) +{ +return blocked; +} + +static inline void rfkill_set_states (struct rfkill *rfkill,bool sw,bool hw) +{ +} + +static inline void rfkill_set_global_sw_state (const enum rfkill_type type, +bool blocked) { -return (state ==RFKILL_STATE_UNBLOCKED ) ? -RFKILL_STATE_SOFT_BLOCKED :RFKILL_STATE_UNBLOCKED ; } +#endif /* RFKILL || RFKILL_MODULE */ + +#ifdef CONFIG_RFKILL_LEDS /** -* rfkill_get_led_name - Get the LED trigger name for the button's LED. +* rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED. * This function might return a NULL pointer if registering of the -* LED trigger failed. -* Use this as "default_trigger" for the LED. +* LED trigger failed. Use this as "default_trigger" for the LED. */ -static inline char *rfkill_get_led_name (struct rfkill *rfkill) -{ -#ifdef CONFIG_RFKILL_LEDS -return (char *)(rfkill->led_trigger.name); +const char *rfkill_get_led_trigger_name (struct rfkill *rfkill); + +/** +* rfkill_set_led_trigger_name -- set the LED trigger name +* @rfkill: rfkill struct +* @name: LED trigger name +* +* This function sets the LED trigger name of the radio LED +* trigger that rfkill creates. It is optional, but if called +* must be called before rfkill_register() to be effective. +*/ +void rfkill_set_led_trigger_name (struct rfkill *rfkill,const char *name);#else +static inline const char *rfkill_get_led_trigger_name (struct rfkill *rfkill) +{return NULL ; -#endif } +static inline void +rfkill_set_led_trigger_name (struct rfkill *rfkill,const char *name) +{ +} +#endif + +#endif /* __KERNEL__ */ +#endif /* RFKILL_H */
drivers/net/wireless/ath/ath9k/main.c +29 -86
169 lines not on this page · raw message
drivers/platform/x86/eeepc-laptop.c +29 -70
160 lines not on this page · raw message
net/rfkill/rfkill.c deleted +0 -855
855 lines not on this page · raw message
net/rfkill/rfkill-input.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* Copyright (C) 2007 Ivo van Doorn -*/ - -/* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2 as published -* by the Free Software Foundation. -*/ - -#ifndef __RFKILL_INPUT_H -#define __RFKILL_INPUT_H - -void rfkill_switch_all (enum rfkill_type type,enum rfkill_state state); -void rfkill_epo (void ); -void rfkill_restore_states (void ); -void rfkill_remove_epo_lock (void ); -bool rfkill_is_epo_lock_active (void ); -enum rfkill_state rfkill_get_global_state (const enum rfkill_type type); - -#endif /* __RFKILL_INPUT_H */
net/rfkill/rfkill-input.c deleted +0 -390
390 lines not on this page · raw message
drivers/net/wireless/b43/main.c +2 -2
@@ -3470,7 +3470,7 @@ static int b43_op_config(struct ieee8021if (!!conf->radio_enabled != phy->radio_on) {if (conf->radio_enabled) { -b43_software_rfkill (dev,RFKILL_STATE_UNBLOCKED ); +b43_software_rfkill (dev, false);b43info (dev->wl,"Radio turned on by software\n" );if (!dev->radio_hw_enable) { b43info(dev->wl, "The hardware RF-kill button "
@@ -3478,7 +3478,7 @@ static int b43_op_config(struct ieee8021 "Press the button to turn it on.\n"); } }else { -b43_software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); +b43_software_rfkill (dev, true);b43info (dev->wl,"Radio turned off by software\n" ); } }
drivers/net/wireless/b43/phy_a.c +2 -2
@@ -480,11 +480,11 @@ static bool b43_aphy_op_supports_hwpctl( }static void b43_aphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {struct b43_phy *phy = &dev->phy; -if (state ==RFKILL_STATE_UNBLOCKED ) { +if (!blocked) {if (phy->radio_on)return ;b43_radio_write16 (dev,0x0004 ,0x00C0 );
drivers/net/wireless/b43/phy_common.c +6 -11
@@ -84,7 +84,7 @@ int b43_phy_init(struct b43_wldev *dev) phy->channel = ops->get_default_chan (dev); - ops->software_rfkill (dev,RFKILL_STATE_UNBLOCKED ); + ops->software_rfkill (dev, false); err = ops->init (dev);if (err) {b43err (dev->wl,"PHY init failed\n" );
@@ -104,7 +104,7 @@ err_phy_exit:if (ops->exit) ops->exit (dev); err_block_rf: - ops->software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); + ops->software_rfkill (dev, true);return err; }
@@ -113,7 +113,7 @@ void b43_phy_exit(struct b43_wldev *dev) {const struct b43_phy_operations *ops = dev->phy.ops; - ops->software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); + ops->software_rfkill (dev, true);if (ops->exit) ops->exit (dev); }
@@ -295,18 +295,13 @@ err_restore_cookie:return err; } -void b43_software_rfkill (struct b43_wldev *dev,enum rfkill_state state) +void b43_software_rfkill (struct b43_wldev *dev,bool blocked) {struct b43_phy *phy = &dev->phy; -if (state ==RFKILL_STATE_HARD_BLOCKED ) { -/* We cannot hardware-block the device */ - state =RFKILL_STATE_SOFT_BLOCKED ; - } -b43_mac_suspend (dev); - phy->ops->software_rfkill (dev, state); - phy->radio_on = (state ==RFKILL_STATE_UNBLOCKED ); + phy->ops->software_rfkill (dev, blocked); + phy->radio_on = !blocked;b43_mac_enable (dev); }
drivers/net/wireless/b43/phy_common.h +2 -2
@@ -159,7 +159,7 @@ struct b43_phy_operations {/* Radio */ bool (*supports_hwpctl)(struct b43_wldev *dev); -void (*software_rfkill)(struct b43_wldev *dev,enum rfkill_state state); +void (*software_rfkill)(struct b43_wldev *dev,bool blocked);void (*switch_analog)(struct b43_wldev *dev,bool on);int (*switch_channel)(struct b43_wldev *dev,unsigned int new_channel);unsigned int (*get_default_chan)(struct b43_wldev *dev);
@@ -364,7 +364,7 @@ int b43_switch_channel(struct b43_wldev/** * b43_software_rfkill - Turn the radio ON or OFF in software. */ -void b43_software_rfkill (struct b43_wldev *dev,enum rfkill_state state); +void b43_software_rfkill (struct b43_wldev *dev,bool blocked);/** * b43_phy_txpower_check - Check TX power output.
drivers/net/wireless/b43/phy_g.c +2 -2
@@ -2592,7 +2592,7 @@ static bool b43_gphy_op_supports_hwpctl( }static void b43_gphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {struct b43_phy *phy = &dev->phy;struct b43_phy_g *gphy = phy->g;
@@ -2600,7 +2600,7 @@ static void b43_gphy_op_software_rfkill(might_sleep (); -if (state ==RFKILL_STATE_UNBLOCKED ) { +if (!blocked) {/* Turn radio ON */ if (phy->radio_on)return ;
drivers/net/wireless/b43/phy_n.c +1 -1
@@ -579,7 +579,7 @@ static void b43_nphy_op_radio_write(stru }static void b43_nphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {//TODO }
drivers/net/wireless/b43/rfkill.c +34 -89
188 lines not on this page · raw message
drivers/net/wireless/b43legacy/rfkill.c +39 -84
192 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-rfkill.c +28 -41
124 lines not on this page · raw message
Documentation/rfkill.txt +98 -539
414 lines not on this page · raw message
net/rfkill/Kconfig +7 -14
Lines of this file are not shown. View the raw message.
net/rfkill/Makefile +3 -2
Lines of this file are not shown. View the raw message.
net/rfkill/core.c new file +896 -0
896 lines not on this page · raw message
net/rfkill/input.c new file +342 -0
342 lines not on this page · raw message
net/rfkill/rfkill.h new file +27 -0
Lines of this file are not shown. View the raw message.
MAINTAINERS +3 -3
Lines of this file are not shown. View the raw message.
include/linux/Kbuild +1 -0
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath9k/ath9k.h +1 -6
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath9k/pci.c +0 -15
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/Kconfig +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/rfkill.h +1 -4
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/Kconfig +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/leds.c +2 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/rfkill.h +1 -5
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/leds.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/iwlwifi/Kconfig +2 -3
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/phy_lp.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/platform/x86/Kconfig +6 -8
Lines of this file are not shown. View the raw message.
drivers/platform/x86/acer-wmi.c +22 -28
50 lines not on this page · raw message
drivers/platform/x86/dell-laptop.c +32 -69
101 lines not on this page · raw message
drivers/platform/x86/hp-wmi.c +52 -51
103 lines not on this page · raw message
drivers/platform/x86/toshiba_acpi.c +45 -114
159 lines not on this page · raw message
arch/arm/mach-pxa/tosa-bt.c +15 -15
Lines of this file are not shown. View the raw message.
arch/arm/mach-pxa/tosa.c +0 -1
Lines of this file are not shown. View the raw message.
include/net/wimax.h +2 -6
Lines of this file are not shown. View the raw message.
net/wimax/op-rfkill.c +26 -97
123 lines not on this page · raw message
net/wimax/Kconfig +0 -14
Lines of this file are not shown. View the raw message.
drivers/net/usb/hso.c +22 -20
42 lines not on this page · raw message
drivers/platform/x86/sony-laptop.c +71 -120
191 lines not on this page · raw message
drivers/platform/x86/thinkpad_acpi.c +450 -419
869 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Johannes Berg
maintainerPATCH v11 1/1 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
---
v3: * fix locking bugs
* fix bug in input.c that made it ignore things
* allow setting LED trigger name
* apply default state while registering
* convert HSO
v4: * LED triggering
v5: * convert sony
* introduce rfkill_set_states function
* change query/poll methods to require calls to rfkill_set{_sw,_hw}_state/rfkill_set_states
* do not call driver from registration
* remove tested-by since it changed a lot
v6: * fix stupid sync work bugs
v7: * fix setting states before registration
* make EEEPC resume properly [Alan Jenkins]
v8: * move one rfkill_set_state call under the mutex
* protect things with spinlock and take care to close the race Henrique pointed out
* add note about set_block race
* remove tested-by again, the spinlock change is a little too invasive to claim testing
v9: * fix documentation on query op
* push sw state to device on resume
* remove thing about not calling device while hw blocked -- the call can be ignored but we can't avoid it due to races anyway
* convert toshiba
v10: * fix whitespace error pointed out by Alan Jenkins
* thinkpad conversion from hmh
* fix bug in input.c (thanks hmh)
* make a function static
* fix eeepc conversion (again? what happened here?)
* correct rfkill Kconfig dependencies in platform drivers
* fix eeepc bluetooth name
* correct led-trigger dependencies
* build input handler only if input support in kernel
* fix bug with RFKILL_BLOCK_SW_PREV by resetting it
v11: * update and fix iwm (iwm did unregister + free which is
not permitted in the current API but unintuitive)
More work will be needed on locking eventually, but since the old rfkill core had horrible locking drivers are prepared to deal with that and I don't need to do this right away.
Documentation/rfkill.txt | 637 +++----------------- MAINTAINERS | 6 arch/arm/mach-pxa/tosa-bt.c | 30 arch/arm/mach-pxa/tosa.c | 1 drivers/net/usb/hso.c | 42 - drivers/net/wireless/ath/ath9k/ath9k.h | 7 drivers/net/wireless/ath/ath9k/main.c | 115 --- drivers/net/wireless/ath/ath9k/pci.c | 15 drivers/net/wireless/b43/Kconfig | 2 drivers/net/wireless/b43/leds.c | 2 drivers/net/wireless/b43/main.c | 4 drivers/net/wireless/b43/phy_a.c | 4 drivers/net/wireless/b43/phy_common.c | 17 drivers/net/wireless/b43/phy_common.h | 4 drivers/net/wireless/b43/phy_g.c | 4 drivers/net/wireless/b43/phy_lp.c | 2 drivers/net/wireless/b43/phy_n.c | 2 drivers/net/wireless/b43/rfkill.c | 123 +-- drivers/net/wireless/b43/rfkill.h | 5 drivers/net/wireless/b43legacy/Kconfig | 2 drivers/net/wireless/b43legacy/leds.c | 3 drivers/net/wireless/b43legacy/rfkill.c | 123 +-- drivers/net/wireless/b43legacy/rfkill.h | 6 drivers/net/wireless/iwlwifi/Kconfig | 5 drivers/net/wireless/iwlwifi/iwl-rfkill.c | 69 -- drivers/net/wireless/iwmc3200wifi/rfkill.c | 39 - drivers/platform/x86/Kconfig | 14 drivers/platform/x86/acer-wmi.c | 50 - drivers/platform/x86/dell-laptop.c | 101 +-- drivers/platform/x86/eeepc-laptop.c | 99 --- drivers/platform/x86/hp-wmi.c | 103 +-- drivers/platform/x86/sony-laptop.c | 191 ++---- drivers/platform/x86/thinkpad_acpi.c | 869 ++++++++++++++-------------- drivers/platform/x86/toshiba_acpi.c | 159 +---- include/linux/Kbuild | 1 include/linux/rfkill.h | 327 ++++++++-- include/net/wimax.h | 8 net/rfkill/Kconfig | 21 net/rfkill/Makefile | 5 net/rfkill/core.c | 896 +++++++++++++++++++++++++++++ net/rfkill/input.c | 342 +++++++++++ net/rfkill/rfkill-input.c | 390 ------------ net/rfkill/rfkill-input.h | 21 net/rfkill/rfkill.c | 855 --------------------------- net/rfkill/rfkill.h | 27 net/wimax/Kconfig | 14 net/wimax/op-rfkill.c | 123 --- 47 files changed, 2574 insertions(+), 3311 deletions(-)
include/linux/rfkill.h +252 -75
@@ -4,6 +4,7 @@/* * Copyright (C) 2006 - 2007 Ivo van Doorn * Copyright (C) 2007 Dmitry Torokhov +* Copyright 2009 Johannes Berg <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -21,6 +22,24 @@* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* define userspace visible states */ +#define RFKILL_STATE_SOFT_BLOCKED 0 +#define RFKILL_STATE_UNBLOCKED 1 +#define RFKILL_STATE_HARD_BLOCKED 2 + +/* and that's all userspace gets */ +#ifdef __KERNEL__ +/* don't allow anyone to use these in the kernel */ +enum rfkill_user_states { +RFKILL_USER_STATE_SOFT_BLOCKED =RFKILL_STATE_SOFT_BLOCKED , +RFKILL_USER_STATE_UNBLOCKED =RFKILL_STATE_UNBLOCKED , +RFKILL_USER_STATE_HARD_BLOCKED =RFKILL_STATE_HARD_BLOCKED , +}; +#undef RFKILL_STATE_SOFT_BLOCKED +#undef RFKILL_STATE_UNBLOCKED +#undef RFKILL_STATE_HARD_BLOCKED +#include <linux/types.h> #include <linux/kernel.h> #include <linux/list.h>
@@ -30,109 +49,267 @@/** * enum rfkill_type - type of rfkill switch. -* RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. -* RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. -* RFKILL_TYPE_UWB: switch is on a ultra wideband device. -* RFKILL_TYPE_WIMAX: switch is on a WiMAX device. -* RFKILL_TYPE_WWAN: switch is on a wireless WAN device. +* +* @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. +* @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. +* @RFKILL_TYPE_UWB: switch is on a ultra wideband device. +* @RFKILL_TYPE_WIMAX: switch is on a WiMAX device. +* @RFKILL_TYPE_WWAN: switch is on a wireless WAN device. +* @NUM_RFKILL_TYPES: number of defined rfkill types */ enum rfkill_type { -RFKILL_TYPE_WLAN , +RFKILL_TYPE_WLAN ,RFKILL_TYPE_BLUETOOTH ,RFKILL_TYPE_UWB ,RFKILL_TYPE_WIMAX ,RFKILL_TYPE_WWAN , -RFKILL_TYPE_MAX , +NUM_RFKILL_TYPES , }; -enum rfkill_state { -RFKILL_STATE_SOFT_BLOCKED =0 ,/* Radio output blocked */ -RFKILL_STATE_UNBLOCKED =1 ,/* Radio output allowed */ -RFKILL_STATE_HARD_BLOCKED =2 ,/* Output blocked, non-overrideable */ -RFKILL_STATE_MAX ,/* marker for last valid state */ +/* this is opaque */ +struct rfkill ; + +/** +* struct rfkill_ops - rfkill driver methods +* +* @poll: poll the rfkill block state(s) -- only assign this method +* when you need polling. When called, simply call one of the +* rfkill_set{,_hw,_sw}_state family of functions. If the hw +* is getting unblocked you need to take into account the return +* value of those functions to make sure the software block is +* properly used. +* @query: query the rfkill block state(s) and call exactly one of the +* rfkill_set{,_hw,_sw}_state family of functions. Assign this +* method if input events can cause hardware state changes to make +* the rfkill core query your driver before setting a requested +* block. +* @set_block: turn the transmitter on (blocked == false) or off +* (blocked == true) -- this is called only while the transmitter +* is not hard-blocked, but note that the core's view of whether +* the transmitter is hard-blocked might differ from your driver's +* view due to race conditions, so it is possible that it is still +* called at the same time as you are calling rfkill_set_hw_state(). +* This callback must be assigned. +*/ +struct rfkill_ops { +void (*poll)(struct rfkill *rfkill,void *data); +void (*query)(struct rfkill *rfkill,void *data); +int (*set_block)(void *data,bool blocked); }; +#if defined(CONFIG_RFKILL ) || defined(CONFIG_RFKILL_MODULE )/** -* struct rfkill - rfkill control structure. -* @name: Name of the switch. -* @type: Radio type which the button controls, the value stored -* here should be a value from enum rfkill_type. -* @state: State of the switch, "UNBLOCKED" means radio can operate. -* @mutex: Guards switch state transitions. It serializes callbacks -* and also protects the state. -* @data: Pointer to the RF button drivers private data which will be -* passed along when toggling radio state. -* @toggle_radio(): Mandatory handler to control state of the radio. -* only RFKILL_STATE_SOFT_BLOCKED and RFKILL_STATE_UNBLOCKED are -* valid parameters. -* @get_state(): handler to read current radio state from hardware, -* may be called from atomic context, should return 0 on success. -* Either this handler OR judicious use of rfkill_force_state() is -* MANDATORY for any driver capable of RFKILL_STATE_HARD_BLOCKED. -* @led_trigger: A LED trigger for this button's LED. -* @dev: Device structure integrating the switch into device tree. -* @node: Used to place switch into list of all switches known to the -* the system. -* -* This structure represents a RF switch located on a network device. -*/ -struct rfkill { -const char *name; -enum rfkill_type type; - -/* the mutex serializes callbacks and also protects -* the state */ -struct mutex mutex; -enum rfkill_state state; -void *data; -int (*toggle_radio)(void *data,enum rfkill_state state); -int (*get_state)(void *data,enum rfkill_state *state); +* rfkill_alloc - allocate rfkill structure +* @name: name of the struct -- the string is not copied internally +* @parent: device that has rf switch on it +* @type: type of the switch (RFKILL_TYPE_*) +* @ops: rfkill methods +* @ops_data: data passed to each method +* +* This function should be called by the transmitter driver to allocate an +* rfkill structure. Returns %NULL on failure. +*/ +struct rfkill *__must_check rfkill_alloc (const char *name, +struct device *parent, +const enum rfkill_type type, +const struct rfkill_ops *ops, +void *ops_data); -#ifdef CONFIG_RFKILL_LEDS -struct led_trigger led_trigger; -#endif +/** +* rfkill_register - Register a rfkill structure. +* @rfkill: rfkill structure to be registered +* +* This function should be called by the transmitter driver to register +* the rfkill structure needs to be registered. Before calling this function +* the driver needs to be ready to service method calls from rfkill. +*/ +int __must_check rfkill_register (struct rfkill *rfkill); -struct device dev; -struct list_head node; -enum rfkill_state state_for_resume; -}; -#define to_rfkill (d) container_of(d, struct rfkill, dev) +/** +* rfkill_pause_polling(struct rfkill *rfkill) +* +* Pause polling -- say transmitter is off for other reasons. +* NOTE: not necessary for suspend/resume -- in that case the +* core stops polling anyway +*/ +void rfkill_pause_polling (struct rfkill *rfkill); -struct rfkill *__must_check rfkill_allocate (struct device *parent, -enum rfkill_type type); -void rfkill_free (struct rfkill *rfkill); -int __must_check rfkill_register (struct rfkill *rfkill); +/** +* rfkill_resume_polling(struct rfkill *rfkill) +* +* Pause polling -- say transmitter is off for other reasons. +* NOTE: not necessary for suspend/resume -- in that case the +* core stops polling anyway +*/ +void rfkill_resume_polling (struct rfkill *rfkill); + + +/** +* rfkill_unregister - Unregister a rfkill structure. +* @rfkill: rfkill structure to be unregistered +* +* This function should be called by the network driver during device +* teardown to destroy rfkill structure. Until it returns, the driver +* needs to be able to service method calls. +*/ void rfkill_unregister (struct rfkill *rfkill); -int rfkill_force_state (struct rfkill *rfkill,enum rfkill_state state); -int rfkill_set_default (enum rfkill_type type,enum rfkill_state state); +/** +* rfkill_destroy - free rfkill structure +* @rfkill: rfkill structure to be destroyed +* +* Destroys the rfkill structure. +*/ +void rfkill_destroy (struct rfkill *rfkill); + +/** +* rfkill_set_hw_state - Set the internal rfkill hardware block state +* @rfkill: pointer to the rfkill class to modify. +* @state: the current hardware block state to set +* +* rfkill drivers that get events when the hard-blocked state changes +* use this function to notify the rfkill core (and through that also +* userspace) of the current state -- they should also use this after +* resume if the state could have changed. +* +* You need not (but may) call this function if poll_state is assigned. +* +* This function can be called in any context, even from within rfkill +* callbacks. +* +* The function returns the combined block state (true if transmitter +* should be blocked) so that drivers need not keep track of the soft +* block state -- which they might not be able to. +*/ +bool __must_check rfkill_set_hw_state (struct rfkill *rfkill,bool blocked); + +/** +* rfkill_set_sw_state - Set the internal rfkill software block state +* @rfkill: pointer to the rfkill class to modify. +* @state: the current software block state to set +* +* rfkill drivers that get events when the soft-blocked state changes +* (yes, some platforms directly act on input but allow changing again) +* use this function to notify the rfkill core (and through that also +* userspace) of the current state -- they should also use this after +* resume if the state could have changed. +* +* This function can be called in any context, even from within rfkill +* callbacks. +* +* The function returns the combined block state (true if transmitter +* should be blocked). +*/ +bool rfkill_set_sw_state (struct rfkill *rfkill,bool blocked); + +/** +* rfkill_set_states - Set the internal rfkill block states +* @rfkill: pointer to the rfkill class to modify. +* @sw: the current software block state to set +* @hw: the current hardware block state to set +* +* This function can be called in any context, even from within rfkill +* callbacks. +*/ +void rfkill_set_states (struct rfkill *rfkill,bool sw,bool hw);/** -* rfkill_state_complement - return complementar state -* @state: state to return the complement of +* rfkill_set_global_sw_state - set global sw block default +* @type: rfkill type to set default for +* @blocked: default to set * -* Returns RFKILL_STATE_SOFT_BLOCKED if @state is RFKILL_STATE_UNBLOCKED, -* returns RFKILL_STATE_UNBLOCKED otherwise. +* This function sets the global default -- use at boot if your platform has +* an rfkill switch. If not early enough this call may be ignored. +* +* XXX: instead of ignoring -- how about just updating all currently +* registered drivers? */ -static inline enum rfkill_state rfkill_state_complement (enum rfkill_state state) +void rfkill_set_global_sw_state (const enum rfkill_type type,bool blocked); +#else /* !RFKILL */ +static inline struct rfkill *__must_check +rfkill_alloc (const char *name, +struct device *parent, +const enum rfkill_type type, +const struct rfkill_ops *ops, +void *ops_data) +{ +return ERR_PTR (-ENODEV ); +} + +static inline int __must_check rfkill_register (struct rfkill *rfkill) +{ +if (rfkill ==ERR_PTR (-ENODEV )) +return 0 ; +return -EINVAL ; +} + +static inline void rfkill_pause_polling (struct rfkill *rfkill) +{ +} + +static inline void rfkill_resume_polling (struct rfkill *rfkill) +{ +} + +static inline void rfkill_unregister (struct rfkill *rfkill) +{ +} + +static inline void rfkill_destroy (struct rfkill *rfkill) +{ +} + +static inline bool rfkill_set_hw_state (struct rfkill *rfkill,bool blocked) +{ +return blocked; +} + +static inline bool rfkill_set_sw_state (struct rfkill *rfkill,bool blocked) +{ +return blocked; +} + +static inline void rfkill_set_states (struct rfkill *rfkill,bool sw,bool hw) +{ +} + +static inline void rfkill_set_global_sw_state (const enum rfkill_type type, +bool blocked) { -return (state ==RFKILL_STATE_UNBLOCKED ) ? -RFKILL_STATE_SOFT_BLOCKED :RFKILL_STATE_UNBLOCKED ; } +#endif /* RFKILL || RFKILL_MODULE */ + +#ifdef CONFIG_RFKILL_LEDS /** -* rfkill_get_led_name - Get the LED trigger name for the button's LED. +* rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED. * This function might return a NULL pointer if registering of the -* LED trigger failed. -* Use this as "default_trigger" for the LED. +* LED trigger failed. Use this as "default_trigger" for the LED. */ -static inline char *rfkill_get_led_name (struct rfkill *rfkill) -{ -#ifdef CONFIG_RFKILL_LEDS -return (char *)(rfkill->led_trigger.name); +const char *rfkill_get_led_trigger_name (struct rfkill *rfkill); + +/** +* rfkill_set_led_trigger_name -- set the LED trigger name +* @rfkill: rfkill struct +* @name: LED trigger name +* +* This function sets the LED trigger name of the radio LED +* trigger that rfkill creates. It is optional, but if called +* must be called before rfkill_register() to be effective. +*/ +void rfkill_set_led_trigger_name (struct rfkill *rfkill,const char *name);#else +static inline const char *rfkill_get_led_trigger_name (struct rfkill *rfkill) +{return NULL ; -#endif } +static inline void +rfkill_set_led_trigger_name (struct rfkill *rfkill,const char *name) +{ +} +#endif + +#endif /* __KERNEL__ */ +#endif /* RFKILL_H */
drivers/net/wireless/ath/ath9k/main.c +29 -86
169 lines not on this page · raw message
drivers/platform/x86/eeepc-laptop.c +29 -70
160 lines not on this page · raw message
net/rfkill/rfkill.c deleted +0 -855
855 lines not on this page · raw message
net/rfkill/rfkill-input.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* Copyright (C) 2007 Ivo van Doorn -*/ - -/* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2 as published -* by the Free Software Foundation. -*/ - -#ifndef __RFKILL_INPUT_H -#define __RFKILL_INPUT_H - -void rfkill_switch_all (enum rfkill_type type,enum rfkill_state state); -void rfkill_epo (void ); -void rfkill_restore_states (void ); -void rfkill_remove_epo_lock (void ); -bool rfkill_is_epo_lock_active (void ); -enum rfkill_state rfkill_get_global_state (const enum rfkill_type type); - -#endif /* __RFKILL_INPUT_H */
net/rfkill/rfkill-input.c deleted +0 -390
390 lines not on this page · raw message
drivers/net/wireless/b43/main.c +2 -2
@@ -3470,7 +3470,7 @@ static int b43_op_config(struct ieee8021if (!!conf->radio_enabled != phy->radio_on) {if (conf->radio_enabled) { -b43_software_rfkill (dev,RFKILL_STATE_UNBLOCKED ); +b43_software_rfkill (dev, false);b43info (dev->wl,"Radio turned on by software\n" );if (!dev->radio_hw_enable) { b43info(dev->wl, "The hardware RF-kill button "
@@ -3478,7 +3478,7 @@ static int b43_op_config(struct ieee8021 "Press the button to turn it on.\n"); } }else { -b43_software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); +b43_software_rfkill (dev, true);b43info (dev->wl,"Radio turned off by software\n" ); } }
drivers/net/wireless/b43/phy_a.c +2 -2
@@ -480,11 +480,11 @@ static bool b43_aphy_op_supports_hwpctl( }static void b43_aphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {struct b43_phy *phy = &dev->phy; -if (state ==RFKILL_STATE_UNBLOCKED ) { +if (!blocked) {if (phy->radio_on)return ;b43_radio_write16 (dev,0x0004 ,0x00C0 );
drivers/net/wireless/b43/phy_common.c +6 -11
@@ -84,7 +84,7 @@ int b43_phy_init(struct b43_wldev *dev) phy->channel = ops->get_default_chan (dev); - ops->software_rfkill (dev,RFKILL_STATE_UNBLOCKED ); + ops->software_rfkill (dev, false); err = ops->init (dev);if (err) {b43err (dev->wl,"PHY init failed\n" );
@@ -104,7 +104,7 @@ err_phy_exit:if (ops->exit) ops->exit (dev); err_block_rf: - ops->software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); + ops->software_rfkill (dev, true);return err; }
@@ -113,7 +113,7 @@ void b43_phy_exit(struct b43_wldev *dev) {const struct b43_phy_operations *ops = dev->phy.ops; - ops->software_rfkill (dev,RFKILL_STATE_SOFT_BLOCKED ); + ops->software_rfkill (dev, true);if (ops->exit) ops->exit (dev); }
@@ -295,18 +295,13 @@ err_restore_cookie:return err; } -void b43_software_rfkill (struct b43_wldev *dev,enum rfkill_state state) +void b43_software_rfkill (struct b43_wldev *dev,bool blocked) {struct b43_phy *phy = &dev->phy; -if (state ==RFKILL_STATE_HARD_BLOCKED ) { -/* We cannot hardware-block the device */ - state =RFKILL_STATE_SOFT_BLOCKED ; - } -b43_mac_suspend (dev); - phy->ops->software_rfkill (dev, state); - phy->radio_on = (state ==RFKILL_STATE_UNBLOCKED ); + phy->ops->software_rfkill (dev, blocked); + phy->radio_on = !blocked;b43_mac_enable (dev); }
drivers/net/wireless/b43/phy_common.h +2 -2
@@ -159,7 +159,7 @@ struct b43_phy_operations {/* Radio */ bool (*supports_hwpctl)(struct b43_wldev *dev); -void (*software_rfkill)(struct b43_wldev *dev,enum rfkill_state state); +void (*software_rfkill)(struct b43_wldev *dev,bool blocked);void (*switch_analog)(struct b43_wldev *dev,bool on);int (*switch_channel)(struct b43_wldev *dev,unsigned int new_channel);unsigned int (*get_default_chan)(struct b43_wldev *dev);
@@ -364,7 +364,7 @@ int b43_switch_channel(struct b43_wldev/** * b43_software_rfkill - Turn the radio ON or OFF in software. */ -void b43_software_rfkill (struct b43_wldev *dev,enum rfkill_state state); +void b43_software_rfkill (struct b43_wldev *dev,bool blocked);/** * b43_phy_txpower_check - Check TX power output.
drivers/net/wireless/b43/phy_g.c +2 -2
@@ -2592,7 +2592,7 @@ static bool b43_gphy_op_supports_hwpctl( }static void b43_gphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {struct b43_phy *phy = &dev->phy;struct b43_phy_g *gphy = phy->g;
@@ -2600,7 +2600,7 @@ static void b43_gphy_op_software_rfkill(might_sleep (); -if (state ==RFKILL_STATE_UNBLOCKED ) { +if (!blocked) {/* Turn radio ON */ if (phy->radio_on)return ;
drivers/net/wireless/b43/phy_n.c +1 -1
@@ -579,7 +579,7 @@ static void b43_nphy_op_radio_write(stru }static void b43_nphy_op_software_rfkill (struct b43_wldev *dev, -enum rfkill_state state) +bool blocked) {//TODO }
drivers/net/wireless/b43/rfkill.c +34 -89
188 lines not on this page · raw message
drivers/net/wireless/b43legacy/rfkill.c +39 -84
192 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-rfkill.c +28 -41
124 lines not on this page · raw message
Documentation/rfkill.txt +98 -539
414 lines not on this page · raw message
net/rfkill/Kconfig +7 -14
Lines of this file are not shown. View the raw message.
net/rfkill/Makefile +3 -2
Lines of this file are not shown. View the raw message.
net/rfkill/core.c new file +896 -0
896 lines not on this page · raw message
net/rfkill/input.c new file +342 -0
342 lines not on this page · raw message
net/rfkill/rfkill.h new file +27 -0
Lines of this file are not shown. View the raw message.
MAINTAINERS +3 -3
Lines of this file are not shown. View the raw message.
include/linux/Kbuild +1 -0
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath9k/ath9k.h +1 -6
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath9k/pci.c +0 -15
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/Kconfig +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/rfkill.h +1 -4
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/Kconfig +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/leds.c +2 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43legacy/rfkill.h +1 -5
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/leds.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/iwlwifi/Kconfig +2 -3
Lines of this file are not shown. View the raw message.
drivers/net/wireless/b43/phy_lp.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/platform/x86/Kconfig +6 -8
Lines of this file are not shown. View the raw message.
drivers/platform/x86/acer-wmi.c +22 -28
50 lines not on this page · raw message
drivers/platform/x86/dell-laptop.c +32 -69
101 lines not on this page · raw message
drivers/platform/x86/hp-wmi.c +52 -51
103 lines not on this page · raw message
drivers/platform/x86/toshiba_acpi.c +45 -114
159 lines not on this page · raw message
arch/arm/mach-pxa/tosa-bt.c +15 -15
Lines of this file are not shown. View the raw message.
arch/arm/mach-pxa/tosa.c +0 -1
Lines of this file are not shown. View the raw message.
include/net/wimax.h +2 -6
Lines of this file are not shown. View the raw message.
net/wimax/op-rfkill.c +26 -97
123 lines not on this page · raw message
net/wimax/Kconfig +0 -14
Lines of this file are not shown. View the raw message.
drivers/net/usb/hso.c +22 -20
42 lines not on this page · raw message
drivers/platform/x86/sony-laptop.c +71 -120
191 lines not on this page · raw message
drivers/platform/x86/thinkpad_acpi.c +450 -419
869 lines not on this page · raw message
drivers/net/wireless/iwmc3200wifi/rfkill.c +17 -22
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Thanks,
Will Keaney
Johannes Berg
maintainerQuoted 7 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Good to hear, thanks for testing and the report!
johannes
Quoted 7 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 5 lines · John W. Linville
Quoted 4 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
Quoted 8 lines
Quoted 3 lines
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
Merge it!
Dan
Hi John,
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
This patch completely rewrites the rfkill core to address the following deficiencies:
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Quoted 6 lines
Quoted 4 lines
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
Merge it!
yeah, go for it ;)
Regards
Marcel
Quoted 5 lines · John W. Linville
Quoted 4 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
Quoted 8 lines
Quoted 3 lines
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Johannes Berg
maintainerQuoted 6 lines · Henrique de Moraes Holschuh
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
I'm sorry, but you're wrong. Before I removed it, almost all drivers disabled that functionality. We do want to add it back, but certainly not with the mostly braindead interface it used to have.
johannes
Quoted 11 lines · Johannes Berg
Quoted 6 lines · Henrique de Moraes Holschuh
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
I'm sorry, but you're wrong. Before I removed it, almost all drivers disabled that functionality. We do want to add it back, but certainly not with the mostly braindead interface it used to have.
Well, thinkpad-acpi has users of that functionality, and not just that, it is in the middle of a two year effort to deprecate the thinkpad-acpi
specific driver attributes and switch to just rfkill. This effort will be
destroyed if a kernel releases without support to writes to the "state" attribute.
I need that userspace interface (writes to the state attribute) in place and working. It _is_ a big regression for thinkpad-acpi to have it return -EOPNOTSUPP.
Also, regardless of the "claim" attribute (and the related user_claim_unsupported nonsense), the old core would allow the user to change the soft state using sysfs, so I really don't understand what you mean when you say "almost all drivers disabled that functionality", you can't disable writes to the "state" attribute in the old core from what I can see. Please correct me if I am wrong on this.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Johannes Berg
maintainerQuoted 9 lines · Henrique de Moraes Holschuh
Well, thinkpad-acpi has users of that functionality, and not just that, it is in the middle of a two year effort to deprecate the thinkpad-acpi
specific driver attributes and switch to just rfkill. This effort will be
destroyed if a kernel releases without support to writes to the "state" attribute.I need that userspace interface (writes to the state attribute) in place and working. It _is_ a big regression for thinkpad-acpi to have it return
-EOPNOTSUPP.
You're free to implement a sane API -- I don't think the current API is feasible because we need to be able to set the soft state regardless of the hard state, query each state separately, and ideally poll the states. Also, the old user_claim is crap when it comes to userspace apps 'forgetting' to reset it when they're finished.
I was suggesting earlier today to John that it might make sense to create a character device for each rfkill instance so that you can
* read soft/hard state from it
* while the device is open for write, that's the equivalent of user_claim
* you can poll() the fd for the device instead of having to listen to the stupid uevents
Also, I want to have any actual proper use cases like switching between classes covered better.
Quoted 6 lines
Also, regardless of the "claim" attribute (and the related
user_claim_unsupportednonsense), the old core would allow the user to change the soft state using sysfs, so I really don't understand what you mean when you say "almost all drivers disabled that functionality", you can't disable writes to the "state" attribute in the old core from what I can see. Please correct me if I am wrong on this.
Without user_claim userspace can have no expectation of actually having control over the state attribute. If your userspace tools do not always user_claim before I believe they are broken.
johannes
Quoted 8 lines · Johannes Berg
Quoted 3 lines · Henrique de Moraes Holschuh
I need that userspace interface (writes to the state attribute) in place and working. It _is_ a big regression for thinkpad-acpi to have it return
-EOPNOTSUPP.You're free to implement a sane API -- I don't think the current API is feasible because we need to be able to set the soft state regardless of the hard state, query each state separately, and ideally poll the
Well, the "state" attribute doesn't get in the way for that. Only expectations that it would REMAIN on a given soft state do, and that's implied nowhere in the "state" attribute ABI. Those assurances were never made, and even "claim" wouldn't be able to pull them off.
And you can simply error out if the request to change radio state fails because of EPO or hard-blocking, nobody said it has to always work.
So can we get that? I don't want to touch the "claim" stuff, I too think
it is not a good way of doing things, and it is not really used by anyone.
Writes to "state" would still merge well with the new core way of doing
things: you return -EPERM if in EPO mode, otherwise you try to change the radio state to the requested state, and error out if you can't. It is that simple. You can return -EACCESS if the state change failed due to hard-block for bonus points, but that certainly isn't required.
Quoted 7 lines
I was suggesting earlier today to John that it might make sense to create a character device for each rfkill instance so that you can
* read soft/hard state from it
* while the device is open for write, that's the equivalent ofuser_claim
* you canpoll()the fd for the device instead of having to listen to the stupid uevents
Hmm, you CAN poll() sysfs, you know? The API is atrocious, but it is there. Thinkpad-ACPI implements this on some of its driver-specific attributes.
We could add poll() support for "state", actually. The crap about this is that userspace needs an out-of-band way to be able to know if poll() is there for a given sysfs attribute, as it doesn't get an error if the support is not there and just waits for events that will never arrive (who makes up these half-baked PoS interfaces?)
That said, I don't have anything against the char device. Just don't remove the simple "state" attribute if you end up switching to, say, netlink or IOCTL.
And truth to be told, you will need a deprecation period if you want to move away from "state". It is in-use ABI, so it is covered by the stable ABI policy.
Quoted 3 lines
Without
user_claimuserspace can have no expectation of actually having control over the state attribute. If your userspace tools do not alwaysuser_claimbefore I believe they are broken.
Nevertheless, it works and people use it. They don't care if a hotkey will change the state (in fact, they probably WANT it to). It is used as "turn off this crap now" and "turn it back on now". Not "keep it off" and "keep it on". Since very little stuff touches it, it ends up being predictable, and thus, useful.
So can I please have writes to "state" back? Unlike the other stuff that never worked quite right (like "claim" -- btw it DID work right with thinkpad-acpi and rfkill-input :-) ), it is in active use.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 15 lines · Henrique de Moraes Holschuh
Quoted 5 lines · John W. Linville
Quoted 4 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
Quoted 8 lines
Quoted 3 lines
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
Quoted 6 lines
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
Are there any apps that actually use this feature? It seems like that even if there are apps, they need to handle drivers that don't support it.
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 16 lines · John W. Linville
Quoted 15 lines · Henrique de Moraes Holschuh
Quoted 13 lines · John W. Linville
Quoted 7 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
Quoted 8 lines
Quoted 6 lines
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
Are there any apps that actually use this feature? It seems like
It is somewhat common on user scripts that are tied to hotkeys by thinkpad users. It may also have found its way to some thinkpad-specific utilities and applets.
I have been telling these people to switch to rfkill for one year, now. 2.6.30 has code that will pester them into doing it, so the numbers will climb a bit (because I intend to remove the non-rfkil-way of doing things in 2010, two years after it was first deprecated).
I don't know if there are any generic apps using it. But I do know I have users of that feature.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 20 lines · John W. Linville
Quoted 19 lines · Henrique de Moraes Holschuh
Quoted 5 lines · John W. Linville
Quoted 4 lines · Will Keaney
Quoted 3 lines · Johannes Berg
This patch completely rewrites the rfkill core to address the following deficiencies:
Quoted 8 lines
Quoted 3 lines
I applied this to a fresh pull of wireless-testing this morning, and haven't had any problems from it. It looks like the soft lockup I reported earlier has been fixed.
Cool, thanks for the report.
I'm leaning towards merging this in time for the 2.6.31 merge window...who wants to complain? :-)
As long as the missing userspace control functionality (the lack of which is a _serious_ regression for platform drivers) is added before 2.6.31 ships, I have no complains.
Quoted 6 lines
Quoted 2 lines
Userspace must be able to change the (soft) state using sysfs. This is not an optional part of rfkill :-)
Are there any apps that actually use this feature? It seems like that even if there are apps, they need to handle drivers that don't support it.
I'd use it NM for the "Enable Wireless" checkbox. The alternative is SIOCSIWTXPOW -> off I guess, though it would be nicer to just talk to one thing in sysfs instead of listen to one and SIWTXPOW to set.
Dan