aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rfkill.h
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-06-16 10:39:51 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-19 11:50:17 -0400
commit06d5caf47ef4fbd9efdceae33293c42778cb7b0c (patch)
tree51bce5f2f9f7aef903c464ac68c80da6f83e2c53 /include/linux/rfkill.h
parent7fa20a7f60df0afceafbb8197b5d110507f42c72 (diff)
rfkill: don't restore software blocked state on persistent devices
The setting of the "persistent" flag is also made more explicit using a new rfkill_init_sw_state() function, instead of special-casing rfkill_set_sw_state() when it is called before registration. Suspend is a bit of a corner case so we try to get away without adding another hack to rfkill-input - it's going to be removed soon. If the state does change over suspend, users will simply have to prod rfkill-input twice in order to toggle the state. Userspace policy agents will be able to implement a more consistent user experience. For example, they can avoid the above problem if they toggle devices individually. Then there would be no "global state" to get out of sync. Currently there are only two rfkill drivers with persistent soft-blocked state. thinkpad-acpi already checks the software state on resume. eeepc-laptop will require modification. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> CC: Marcel Holtmann <marcel@holtmann.org> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/linux/rfkill.h')
-rw-r--r--include/linux/rfkill.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 16e39c7a67fc..dcac724340d8 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -160,8 +160,9 @@ struct rfkill * __must_check rfkill_alloc(const char *name,
160 * the rfkill structure. Before calling this function the driver needs 160 * the rfkill structure. Before calling this function the driver needs
161 * to be ready to service method calls from rfkill. 161 * to be ready to service method calls from rfkill.
162 * 162 *
163 * If the software blocked state is not set before registration, 163 * If rfkill_init_sw_state() is not called before registration,
164 * set_block will be called to initialize it to a default value. 164 * set_block() will be called to initialize the software blocked state
165 * to a default value.
165 * 166 *
166 * If the hardware blocked state is not set before registration, 167 * If the hardware blocked state is not set before registration,
167 * it is assumed to be unblocked. 168 * it is assumed to be unblocked.
@@ -234,9 +235,11 @@ bool __must_check rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
234 * rfkill drivers that get events when the soft-blocked state changes 235 * rfkill drivers that get events when the soft-blocked state changes
235 * (yes, some platforms directly act on input but allow changing again) 236 * (yes, some platforms directly act on input but allow changing again)
236 * use this function to notify the rfkill core (and through that also 237 * use this function to notify the rfkill core (and through that also
237 * userspace) of the current state. It is not necessary to notify on 238 * userspace) of the current state.
238 * resume; since hibernation can always change the soft-blocked state, 239 *
239 * the rfkill core will unconditionally restore the previous state. 240 * Drivers should also call this function after resume if the state has
241 * been changed by the user. This only makes sense for "persistent"
242 * devices (see rfkill_init_sw_state()).
240 * 243 *
241 * This function can be called in any context, even from within rfkill 244 * This function can be called in any context, even from within rfkill
242 * callbacks. 245 * callbacks.
@@ -247,6 +250,21 @@ bool __must_check rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
247bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked); 250bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
248 251
249/** 252/**
253 * rfkill_init_sw_state - Initialize persistent software block state
254 * @rfkill: pointer to the rfkill class to modify.
255 * @state: the current software block state to set
256 *
257 * rfkill drivers that preserve their software block state over power off
258 * use this function to notify the rfkill core (and through that also
259 * userspace) of their initial state. It should only be used before
260 * registration.
261 *
262 * In addition, it marks the device as "persistent". Persistent devices
263 * are expected to preserve preserve their own state when suspended.
264 */
265void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
266
267/**
250 * rfkill_set_states - Set the internal rfkill block states 268 * rfkill_set_states - Set the internal rfkill block states
251 * @rfkill: pointer to the rfkill class to modify. 269 * @rfkill: pointer to the rfkill class to modify.
252 * @sw: the current software block state to set 270 * @sw: the current software block state to set
@@ -307,6 +325,10 @@ static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
307 return blocked; 325 return blocked;
308} 326}
309 327
328static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
329{
330}
331
310static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) 332static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
311{ 333{
312} 334}