the entire rfkill patchset
Subsystems (19)
Johannes Berg
maintainercover the entire rfkill patchset
I'm getting confused by multiple patch versions, so let me resend this to make sure you have the latest versions of all patches.
johannes
Johannes Berg
maintainerPATCH v11 1/6 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.
Johannes Berg
maintainerPATCH v6 2/6 rfkill: create useful userspace interface
In reply to Johannes BergThe new code added by this patch will make rfkill create a misc character device /dev/rfkill that userspace can use to control rfkill soft blocks and get status of devices as well as events when the status changes.
Using it is very simple -- when you open it you can read a number of times to get the initial state, and every further read blocks (you can poll) on getting the next event from the kernel. The same structure you read is also used when writing to it to change the soft block of a given device, all devices of a given type, or all devices.
This also makes CONFIG_RFKILL_INPUT selectable again in order to be able to test without it present since its functionality can now be replaced by userspace entirely and distros and users may not want the input part of rfkill interfering with their userspace code. We will also write a userspace daemon to handle all that and consequently add the input code to the feature removal schedule.
In order to have rfkilld support both kernels with and without CONFIG_RFKILL_INPUT (or new kernels after its eventual removal) we also add an ioctl (that only exists if rfkill-input is present) to disable rfkill-input. It is not very efficient, but at least gives the correct behaviour in all cases.
---
v4: set default global state from userspace for rfkill hotplug
(pointed out by Marcel)
v5: add ioctl
v6: hook up compat_ioctl
Documentation/feature-removal-schedule.txt | 7 include/linux/rfkill.h | 84 +++++-- net/rfkill/Kconfig | 4 net/rfkill/core.c | 330 ++++++++++++++++++++++++++++- 4 files changed, 394 insertions(+), 31 deletions(-)
include/linux/rfkill.h +60 -24
@@ -22,34 +22,17 @@* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <linux/types.h> /* 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> -#include <linux/mutex.h> -#include <linux/device.h> -#include <linux/leds.h> -/** * enum rfkill_type - type of rfkill switch. * +* @RFKILL_TYPE_ALL: toggles all switches (userspace only) * @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.
@@ -58,6 +41,7 @@ enum rfkill_user_states {* @NUM_RFKILL_TYPES: number of defined rfkill types */ enum rfkill_type { +RFKILL_TYPE_ALL =0 ,RFKILL_TYPE_WLAN ,RFKILL_TYPE_BLUETOOTH ,RFKILL_TYPE_UWB ,
@@ -66,6 +50,62 @@ enum rfkill_type { NUM_RFKILL_TYPES, }; +/** +* enum rfkill_operation - operation types +* @RFKILL_OP_ADD: a device was added +* @RFKILL_OP_DEL: a device was removed +* @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device +* @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all) +*/ +enum rfkill_operation { +RFKILL_OP_ADD =0 , +RFKILL_OP_DEL , +RFKILL_OP_CHANGE , +RFKILL_OP_CHANGE_ALL , +}; + +/** +* struct rfkill_event - events for userspace on /dev/rfkill +* @idx: index of dev rfkill +* @type: type of the rfkill struct +* @op: operation code +* @hard: hard state (0/1) +* @soft: soft state (0/1) +* +* Structure used for userspace communication on /dev/rfkill, +* used for events from the kernel and control to the kernel. +*/ +struct rfkill_event { +__u32 idx; +__u8 type; +__u8 op; +__u8 soft, hard; +} __packed; + +/* ioctl for turning off rfkill-input (if present) */ +#define RFKILL_IOC_MAGIC 'R' +#define RFKILL_IOC_NOINPUT 1 +#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) + +/* 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> +#include <linux/mutex.h> +#include <linux/device.h> +#include <linux/leds.h> +/* this is opaque */ struct rfkill ;
@@ -84,11 +124,7 @@ struct rfkill;* 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(). +* (blocked == true) -- ignore and return 0 when hard blocked. * This callback must be assigned. */ struct rfkill_ops {
net/rfkill/core.c +325 -5
475 lines not on this page · raw message
net/rfkill/Kconfig +2 -2
@@ -18,7 +18,7 @@ config RFKILL_LEDS default y config RFKILL_INPUT - bool + bool "RF switch input support" depends on RFKILL depends on INPUT = y || RFKILL = INPUT - default y + default y if !EMBEDDED
Documentation/feature-removal-schedule.txt +7 -0
@@ -437,3 +437,10 @@ Why: Superseded by tdfxfb. I2C/DDC suppo driver but this caused driver conflicts. Who: Jean Delvare <[email protected]> Krzysztof Helt <[email protected]> + +--------------------------- + +What: CONFIG_RFKILL_INPUT +When: 2.6.33 +Why: Should be implemented in userspace, policy daemon. +Who: Johannes Berg <[email protected]>
Johannes Berg
maintainerPATCH 3/6 cfg80211: move txpower wext from mac80211
In reply to Johannes BergThis patch introduces new cfg80211 API to set the TX power via cfg80211, puts the wext code into cfg80211 and updates mac80211 to use all that. The -ENETDOWN bits are a hack but will go away soon.
--- include/net/cfg80211.h | 30 ++++++++++++++++ net/mac80211/cfg.c | 54 ++++++++++++++++++++++++++++++ net/mac80211/wext.c | 80 +-------------------------------------------- net/wireless/wext-compat.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 78 deletions(-)
include/net/cfg80211.h +30 -0
@@ -752,6 +752,21 @@ enum wiphy_params_flags { };/** +* enum tx_power_setting - TX power adjustment +* +* @TX_POWER_AUTOMATIC: the dbm parameter is ignored +* @TX_POWER_LIMITED: limit TX power by the dbm parameter +* @TX_POWER_FIXED: fix TX power to the dbm parameter +* @TX_POWER_OFF: turn off completely (will go away) +*/ +enum tx_power_setting { +TX_POWER_AUTOMATIC , +TX_POWER_LIMITED , +TX_POWER_FIXED , +TX_POWER_OFF , +}; + +/** * struct cfg80211_ops - backend description for wireless configuration * * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -837,6 +852,11 @@ enum wiphy_params_flags {* @changed bitfield (see &enum wiphy_params_flags) describes which values * have changed. The actual parameter values are available in * struct wiphy. If returning an error, no value should be changed. +* +* @set_tx_power: set the transmit power according to the parameters +* @get_tx_power: store the current TX power into the dbm variable; +* return 0 if successful; or -ENETDOWN if successful but power +* is disabled (this will go away) */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy);
@@ -928,6 +948,10 @@ struct cfg80211_ops {int (*leave_ibss)(struct wiphy *wiphy,struct net_device *dev);int (*set_wiphy_params)(struct wiphy *wiphy,u32 changed); + +int (*set_tx_power)(struct wiphy *wiphy, +enum tx_power_setting type,int dbm); +int (*get_tx_power)(struct wiphy *wiphy,int *dbm); };/*
@@ -1451,6 +1475,12 @@ int cfg80211_wext_siwencode(struct net_dint cfg80211_wext_giwencode (struct net_device *dev,struct iw_request_info *info,struct iw_point *erq,char *keybuf); +int cfg80211_wext_siwtxpower (struct net_device *dev, +struct iw_request_info *info, +union iwreq_data *data,char *keybuf); +int cfg80211_wext_giwtxpower (struct net_device *dev, +struct iw_request_info *info, +union iwreq_data *data,char *keybuf);/* * callbacks for asynchronous cfg80211 methods, notification
net/mac80211/cfg.c +54 -0
64 lines not on this page · raw message
net/mac80211/wext.c +2 -78
92 lines not on this page · raw message
net/wireless/wext-compat.c +80 -0
83 lines not on this page · raw message
Johannes Berg
maintainerPATCH 4/6 rfkill: add function to query state
In reply to Johannes BergSometimes it is necessary to know how the state is, and it is easier to query rfkill than keep track of it somewhere else, so add a function for that. This could later be expanded to return hard/soft block, but so far that isn't necessary.
--- include/linux/rfkill.h | 12 ++++++++++++ net/rfkill/core.c | 13 +++++++++++++ 2 files changed, 25 insertions(+)
include/linux/rfkill.h +12 -0
@@ -261,6 +261,13 @@ void rfkill_set_states(struct rfkill *rf* registered drivers? */ void rfkill_set_global_sw_state (const enum rfkill_type type,bool blocked); + +/** +* rfkill_blocked - query rfkill block +* +* @rfkill: rfkill struct to query +*/ +bool rfkill_blocked (struct rfkill *rfkill);#else /* !RFKILL */ static inline struct rfkill *__must_check rfkill_alloc(const char *name,
@@ -313,6 +320,11 @@ static inline void rfkill_set_global_sw_ bool blocked) { } + +static inline bool rfkill_blocked (struct rfkill *rfkill) +{ +return false; +}#endif /* RFKILL || RFKILL_MODULE */
net/rfkill/core.c +13 -0
@@ -773,6 +773,19 @@ static struct class rfkill_class = { .resume = rfkill_resume, }; +bool rfkill_blocked (struct rfkill *rfkill) +{ +unsigned long flags; +u32 state; + +spin_lock_irqsave (&rfkill->lock, flags); + state = rfkill->state; +spin_unlock_irqrestore (&rfkill->lock, flags); + +return !!(state &RFKILL_BLOCK_ANY ); +} +EXPORT_SYMBOL (rfkill_blocked); + struct rfkill * __must_check rfkill_alloc(const char *name, struct device *parent,
Johannes Berg
maintainerPATCH v3 5/6 cfg80211: add rfkill support
In reply to Johannes BergTo be easier on drivers and users, have cfg80211 register an rfkill structure that drivers can access. When soft-killed, simply take down all interfaces; when hard-killed the driver needs to notify us and we will take down the interfaces after the fact. While rfkilled, interfaces cannot be set UP.
---
v2: -ERFKILL
v3: rework polling with start/stop
include/asm-generic/errno.h | 2 include/net/cfg80211.h | 29 +++++++++++-- include/net/mac80211.h | 20 +++++++-- net/mac80211/cfg.c | 20 +++------ net/mac80211/driver-ops.h | 7 +++ net/mac80211/iface.c | 4 - net/mac80211/util.c | 2 net/wireless/Kconfig | 3 - net/wireless/core.c | 97 ++++++++++++++++++++++++++++++++++++++++++-- net/wireless/core.h | 7 +++ net/wireless/wext-compat.c | 11 +++- 11 files changed, 172 insertions(+), 30 deletions(-)
net/wireless/core.c +94 -3
@@ -12,6 +12,7 @@#include <linux/debugfs.h> #include <linux/notifier.h> #include <linux/device.h> +#include <linux/rtnetlink.h> #include <net/genetlink.h> #include <net/cfg80211.h> #include "nl80211.h"
@@ -227,6 +228,41 @@ int cfg80211_dev_rename(struct cfg80211_return 0 ; } +static void cfg80211_rfkill_poll (struct rfkill *rfkill,void *data) +{ +struct cfg80211_registered_device *drv = data; + + drv->ops->rfkill_poll (&drv->wiphy); +} + +static int cfg80211_rfkill_set_block (void *data,bool blocked) +{ +struct cfg80211_registered_device *drv = data; +struct wireless_dev *wdev; + +if (!blocked) +return 0 ; + +rtnl_lock (); +mutex_lock (&drv->devlist_mtx); + +list_for_each_entry (wdev, &drv->netdev_list, list) +dev_close (wdev->netdev); + +mutex_unlock (&drv->devlist_mtx); +rtnl_unlock (); + +return 0 ; +} + +static void cfg80211_rfkill_sync_work (struct work_struct *work) +{ +struct cfg80211_registered_device *drv; + + drv = container_of(work, struct cfg80211_registered_device, rfkill_sync); +cfg80211_rfkill_set_block (drv,rfkill_blocked (drv->rfkill)); +} +/* exported functions */ struct wiphy *wiphy_new (const struct cfg80211_ops *ops,int sizeof_priv)
@@ -274,6 +310,18 @@ struct wiphy *wiphy_new(const struct cfg drv->wiphy.dev.class = &ieee80211_class; drv->wiphy.dev.platform_data = drv; + drv->rfkill_ops.set_block = cfg80211_rfkill_set_block; + drv->rfkill =rfkill_alloc (dev_name (&drv->wiphy.dev), + &drv->wiphy.dev,RFKILL_TYPE_WLAN , + &drv->rfkill_ops, drv); + +if (!drv->rfkill) { +kfree (drv); +return NULL ; + } + +INIT_WORK (&drv->rfkill_sync, cfg80211_rfkill_sync_work); +/* * Initialize wiphy parameters to IEEE 802.11 MIB default values. * Fragmentation and RTS threshold are disabled by default with the
@@ -356,6 +404,10 @@ int wiphy_register(struct wiphy *wiphy)if (res) goto out_unlock; + res =rfkill_register (drv->rfkill); +if (res) + goto out_rm_dev; +list_add (&drv->list, &cfg80211_drv_list);/* add to debugfs */
@@ -379,16 +431,41 @@ int wiphy_register(struct wiphy *wiphy)cfg80211_debugfs_drv_add (drv); res =0 ; -out_unlock: + goto out_unlock; + + out_rm_dev: +device_del (&drv->wiphy.dev); + out_unlock:mutex_unlock (&cfg80211_mutex);return res; }EXPORT_SYMBOL (wiphy_register); +void wiphy_rfkill_start_polling (struct wiphy *wiphy) +{ +struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); + +if (!drv->ops->rfkill_poll) +return ; + drv->rfkill_ops.poll = cfg80211_rfkill_poll; +rfkill_resume_polling (drv->rfkill); +} +EXPORT_SYMBOL (wiphy_rfkill_start_polling); + +void wiphy_rfkill_stop_polling (struct wiphy *wiphy) +{ +struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); + +rfkill_pause_polling (drv->rfkill); +} +EXPORT_SYMBOL (wiphy_rfkill_stop_polling); +void wiphy_unregister (struct wiphy *wiphy) {struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +rfkill_unregister (drv->rfkill); +/* protect the device list */ mutex_lock (&cfg80211_mutex);
@@ -425,6 +502,7 @@ EXPORT_SYMBOL(wiphy_unregister);void cfg80211_dev_free (struct cfg80211_registered_device *drv) {struct cfg80211_internal_bss *scan, *tmp; +rfkill_destroy (drv->rfkill);mutex_destroy (&drv->mtx);mutex_destroy (&drv->devlist_mtx);list_for_each_entry_safe (scan, tmp, &drv->bss_list, list)
@@ -438,6 +516,15 @@ void wiphy_free(struct wiphy *wiphy) }EXPORT_SYMBOL (wiphy_free); +void wiphy_rfkill_set_hw_state (struct wiphy *wiphy,bool blocked) +{ +struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); + +if (rfkill_set_hw_state (drv->rfkill, blocked)) +schedule_work (&drv->rfkill_sync); +} +EXPORT_SYMBOL (wiphy_rfkill_set_hw_state); +static int cfg80211_netdev_notifier_call (struct notifier_block * nb,unsigned long state,void *ndev)
@@ -446,7 +533,7 @@ static int cfg80211_netdev_notifier_callstruct cfg80211_registered_device *rdev;if (!dev->ieee80211_ptr) -return 0 ; +return NOTIFY_DONE ; rdev =wiphy_to_dev (dev->ieee80211_ptr->wiphy);
@@ -492,9 +579,13 @@ static int cfg80211_netdev_notifier_call }mutex_unlock (&rdev->devlist_mtx);break ; +case NETDEV_PRE_UP : +if (rfkill_blocked (rdev->rfkill)) +return notifier_from_errno (-ERFKILL ); +break ; } -return 0 ; +return NOTIFY_DONE ; }static struct notifier_block cfg80211_netdev_notifier = {
net/wireless/core.h +7 -0
@@ -11,6 +11,8 @@#include <linux/kref.h> #include <linux/rbtree.h> #include <linux/debugfs.h> +#include <linux/rfkill.h> +#include <linux/workqueue.h> #include <net/genetlink.h> #include <net/cfg80211.h> #include "reg.h"
@@ -24,6 +26,11 @@ struct cfg80211_registered_device {* any call is in progress */ struct mutex mtx; +/* rfkill support */ +struct rfkill_ops rfkill_ops; +struct rfkill *rfkill; +struct work_struct rfkill_sync; +/* ISO / IEC 3166 alpha2 for which this device is receiving * country IEs on, this can help disregard country IEs from APs * on the same alpha2 quickly. The alpha2 may differ from
include/net/cfg80211.h +25 -4
@@ -757,13 +757,11 @@ enum wiphy_params_flags {* @TX_POWER_AUTOMATIC: the dbm parameter is ignored * @TX_POWER_LIMITED: limit TX power by the dbm parameter * @TX_POWER_FIXED: fix TX power to the dbm parameter -* @TX_POWER_OFF: turn off completely (will go away) */ enum tx_power_setting {TX_POWER_AUTOMATIC ,TX_POWER_LIMITED ,TX_POWER_FIXED , -TX_POWER_OFF , };/**
@@ -855,8 +853,10 @@ enum tx_power_setting {* * @set_tx_power: set the transmit power according to the parameters * @get_tx_power: store the current TX power into the dbm variable; -* return 0 if successful; or -ENETDOWN if successful but power -* is disabled (this will go away) +* return 0 if successful +* +* @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting +* functions to adjust rfkill hw state */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy);
@@ -952,6 +952,8 @@ struct cfg80211_ops {int (*set_tx_power)(struct wiphy *wiphy,enum tx_power_setting type,int dbm);int (*get_tx_power)(struct wiphy *wiphy,int *dbm); + +void (*rfkill_poll)(struct wiphy *wiphy); };/*
@@ -1666,4 +1668,23 @@ void cfg80211_michael_mic_failure(struct*/ void cfg80211_ibss_joined (struct net_device *dev,const u8 *bssid,gfp_t gfp); +/** +* wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state +* @wiphy: the wiphy +* @blocked: block status +*/ +void wiphy_rfkill_set_hw_state (struct wiphy *wiphy,bool blocked); + +/** +* wiphy_rfkill_start_polling - start polling rfkill +* @wiphy: the wiphy +*/ +void wiphy_rfkill_start_polling (struct wiphy *wiphy); + +/** +* wiphy_rfkill_stop_polling - stop polling rfkill +* @wiphy: the wiphy +*/ +void wiphy_rfkill_stop_polling (struct wiphy *wiphy); +#endif /* __NET_CFG80211_H */
net/wireless/Kconfig +2 -1
@@ -1,5 +1,6 @@ config CFG80211 - tristate "Improved wireless configuration API" + tristate "Improved wireless configuration API" + depends on RFKILL || !RFKILL config CFG80211_REG_DEBUG bool "cfg80211 regulatory debugging"
net/wireless/wext-compat.c +7 -4
@@ -764,6 +764,8 @@ int cfg80211_wext_siwtxpower(struct net_/* only change when not disabling */ if (!data->txpower.disabled) { +rfkill_set_sw_state (rdev->rfkill, false); +if (data->txpower.fixed) {/* * wext doesn't support negative values, see
@@ -787,7 +789,9 @@ int cfg80211_wext_siwtxpower(struct net_ } } }else { - type =TX_POWER_OFF ; +rfkill_set_sw_state (rdev->rfkill, true); +schedule_work (&rdev->rfkill_sync); +return 0 ; }return rdev->ops->set_tx_power (wdev->wiphy, type, dbm);;
@@ -811,13 +815,12 @@ int cfg80211_wext_giwtxpower(struct net_return -EOPNOTSUPP ; err = rdev->ops->get_tx_power (wdev->wiphy, &val); -/* HACK!!! */ -if (err && err != -ENETDOWN ) +if (err)return err;/* well... oh well */ data->txpower.fixed =1 ; - data->txpower.disabled = err == -ENETDOWN ; + data->txpower.disabled =rfkill_blocked (rdev->rfkill); data->txpower.value = val; data->txpower.flags =IW_TXPOW_DBM ;
net/mac80211/cfg.c +8 -12
@@ -1340,7 +1340,6 @@ static int ieee80211_set_tx_power(structstruct ieee80211_local *local =wiphy_priv (wiphy);struct ieee80211_channel *chan = local->hw.conf.channel;u32 changes =0 ; -bool radio_enabled = true;switch (type) {case TX_POWER_AUTOMATIC :
@@ -1359,14 +1358,6 @@ static int ieee80211_set_tx_power(structreturn -EINVAL ; local->user_power_level = dbm;break ; -case TX_POWER_OFF : - radio_enabled = false; -break ; - } - -if (radio_enabled != local->hw.conf.radio_enabled) { - changes |=IEEE80211_CONF_CHANGE_RADIO_ENABLED ; - local->hw.conf.radio_enabled = radio_enabled; }ieee80211_hw_config (local, changes);
@@ -1380,12 +1371,16 @@ static int ieee80211_get_tx_power(struct *dbm = local->hw.conf.power_level; -if (!local->hw.conf.radio_enabled) -return -ENETDOWN ; -return 0 ; } +static void ieee80211_rfkill_poll (struct wiphy *wiphy) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); + +drv_rfkill_poll (local); +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1427,4 +1422,5 @@ struct cfg80211_ops mac80211_config_ops .set_wiphy_params = ieee80211_set_wiphy_params, .set_tx_power = ieee80211_set_tx_power, .get_tx_power = ieee80211_get_tx_power, + .rfkill_poll = ieee80211_rfkill_poll, };
net/mac80211/iface.c +2 -2
@@ -170,7 +170,7 @@ static int ieee80211_open(struct net_dev goto err_del_bss;/* we're brought up, everything changes */ hw_reconf_flags = ~0 ; -ieee80211_led_radio (local, local->hw.conf.radio_enabled); +ieee80211_led_radio (local, true); }/*
@@ -560,7 +560,7 @@ static int ieee80211_stop(struct net_devdrv_stop (local); -ieee80211_led_radio (local,0 ); +ieee80211_led_radio (local, false);flush_workqueue (local->hw.workqueue);
net/mac80211/util.c +1 -1
@@ -973,7 +973,7 @@ int ieee80211_reconfig(struct ieee80211_if (local->open_count) { res =drv_start (local); -ieee80211_led_radio (local, hw->conf.radio_enabled); +ieee80211_led_radio (local, true); }/* add interfaces */
include/net/mac80211.h +17 -3
@@ -526,7 +526,7 @@ enum ieee80211_conf_flags {/** * enum ieee80211_conf_changed - denotes which configuration changed * -* @IEEE80211_CONF_CHANGE_RADIO_ENABLED: the value of radio_enabled changed +* @_IEEE80211_CONF_CHANGE_RADIO_ENABLED: DEPRECATED * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed * @IEEE80211_CONF_CHANGE_RADIOTAP: the radiotap flag changed * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
@@ -536,7 +536,7 @@ enum ieee80211_conf_flags {* @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed */ enum ieee80211_conf_changed { -IEEE80211_CONF_CHANGE_RADIO_ENABLED =BIT (0 ), + _IEEE80211_CONF_CHANGE_RADIO_ENABLED =BIT (0 ),IEEE80211_CONF_CHANGE_LISTEN_INTERVAL =BIT (2 ),IEEE80211_CONF_CHANGE_RADIOTAP =BIT (3 ),IEEE80211_CONF_CHANGE_PS =BIT (4 ),
@@ -546,6 +546,14 @@ enum ieee80211_conf_changed { IEEE80211_CONF_CHANGE_IDLE = BIT(8), }; +static inline __deprecated enum ieee80211_conf_changed +__IEEE80211_CONF_CHANGE_RADIO_ENABLED (void ) +{ +return _IEEE80211_CONF_CHANGE_RADIO_ENABLED; +} +#define IEEE80211_CONF_CHANGE_RADIO_ENABLED \ + __IEEE80211_CONF_CHANGE_RADIO_ENABLED() +/** * struct ieee80211_conf - configuration of the device *
@@ -585,7 +593,7 @@ struct ieee80211_conf {int max_sleep_period;u16 listen_interval; -bool radio_enabled; +bool __deprecated radio_enabled;u8 long_frame_max_tx_count, short_frame_max_tx_count;
@@ -1396,6 +1404,10 @@ enum ieee80211_ampdu_mlme_action {* is the first frame we expect to perform the action on. Notice * that TX/RX_STOP can pass NULL for this parameter. * Returns a negative error code on failure. +* +* @rfkill_poll: Poll rfkill hardware state. If you need this, you also +* need to set wiphy->rfkill_poll to %true before registration, +* and need to call wiphy_rfkill_set_hw_state() in the callback. */ struct ieee80211_ops {int (*tx)(struct ieee80211_hw *hw,struct sk_buff *skb);
@@ -1444,6 +1456,8 @@ struct ieee80211_ops {int (*ampdu_action)(struct ieee80211_hw *hw,enum ieee80211_ampdu_mlme_action action,struct ieee80211_sta *sta,u16 tid,u16 *ssn); + +void (*rfkill_poll)(struct ieee80211_hw *hw); };/**
net/mac80211/driver-ops.h +7 -0
@@ -181,4 +181,11 @@ static inline int drv_ampdu_action(struc sta, tid, ssn); return -EOPNOTSUPP; } + + +static inline void drv_rfkill_poll (struct ieee80211_local *local) +{ +if (local->ops->rfkill_poll) + local->ops->rfkill_poll (&local->hw); +}#endif /* __MAC80211_DRIVER_OPS */
include/asm-generic/errno.h +2 -0
@@ -106,4 +106,6 @@#define EOWNERDEAD 130/* Owner died */ #define ENOTRECOVERABLE 131/* State not recoverable */ +#define ERFKILL 132/* Operation not possible due to RF-kill */ +#endif
Johannes Berg
maintainerPATCH v2 6/6 iwm: port to new cfg80211 rfkill
In reply to Johannes BergWhich means removing all rfkill code since it only does soft-kill which cfg80211 will now handle in exactly the same way the driver did.
--- drivers/net/wireless/iwmc3200wifi/Kconfig | 1 drivers/net/wireless/iwmc3200wifi/Makefile | 2 drivers/net/wireless/iwmc3200wifi/iwm.h | 4 - drivers/net/wireless/iwmc3200wifi/netdev.c | 10 --- drivers/net/wireless/iwmc3200wifi/rfkill.c | 83 ----------------------------- 5 files changed, 1 insertion(+), 99 deletions(-)
drivers/net/wireless/iwmc3200wifi/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_IWM) := iwmc3200wifi.o iwmc3200wifi-objs += main.o netdev.o rx.o tx.o sdio.o hal.o fw.o -iwmc3200wifi-objs += commands.o wext.o cfg80211.o eeprom.o rfkill.o +iwmc3200wifi-objs += commands.o wext.o cfg80211.o eeprom.o iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o
drivers/net/wireless/iwmc3200wifi/rfkill.c deleted +0 -83
83 lines not on this page · raw message
drivers/net/wireless/iwmc3200wifi/iwm.h +0 -4
@@ -343,8 +343,4 @@ int iwm_rx_handle_resp(struct iwm_priv * struct iwm_wifi_cmd *cmd);void iwm_rx_free (struct iwm_priv *iwm); -/* RF Kill API */ -int iwm_rfkill_init (struct iwm_priv *iwm); -void iwm_rfkill_exit (struct iwm_priv *iwm); -#endif
drivers/net/wireless/iwmc3200wifi/netdev.c +0 -10
@@ -136,17 +136,8 @@ void *iwm_if_alloc(int sizeof_bus, struc wdev->netdev = ndev; - ret =iwm_rfkill_init (iwm); -if (ret) { -dev_err (dev,"Failed to init rfkill\n" ); - goto out_rfkill; - } -return iwm; - out_rfkill: -unregister_netdev (ndev); - out_ndev:free_netdev (ndev);
@@ -162,7 +153,6 @@ void iwm_if_free(struct iwm_priv *iwm)if (!iwm_to_ndev (iwm))return ; -iwm_rfkill_exit (iwm);unregister_netdev (iwm_to_ndev (iwm));free_netdev (iwm_to_ndev (iwm));iwm_wdev_free (iwm);
drivers/net/wireless/iwmc3200wifi/Kconfig +0 -1
@@ -3,7 +3,6 @@ config IWM depends on MMC && WLAN_80211 && EXPERIMENTAL select LIB80211 select FW_LOADER - select RFKILL config IWM_DEBUG bool "Enable full debugging output in iwmc3200wifi"