diff options
-rw-r--r-- | Documentation/rfkill.txt | 20 | ||||
-rw-r--r-- | net/rfkill/rfkill.c | 7 |
2 files changed, 22 insertions, 5 deletions
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt index 0843ed0163a5..28b6ec87c642 100644 --- a/Documentation/rfkill.txt +++ b/Documentation/rfkill.txt | |||
@@ -390,9 +390,10 @@ rfkill lines are inactive, it must return RFKILL_STATE_SOFT_BLOCKED if its soft | |||
390 | rfkill input line is active. Only if none of the rfkill input lines are | 390 | rfkill input line is active. Only if none of the rfkill input lines are |
391 | active, will it return RFKILL_STATE_UNBLOCKED. | 391 | active, will it return RFKILL_STATE_UNBLOCKED. |
392 | 392 | ||
393 | If it doesn't implement the get_state() hook, it must make sure that its calls | 393 | Since the device has a hardware rfkill line, it IS subject to state changes |
394 | to rfkill_force_state() are enough to keep the status always up-to-date, and it | 394 | external to rfkill. Therefore, the driver must make sure that it calls |
395 | must do a rfkill_force_state() on resume from sleep. | 395 | rfkill_force_state() to keep the status always up-to-date, and it must do a |
396 | rfkill_force_state() on resume from sleep. | ||
396 | 397 | ||
397 | Every time the driver gets a notification from the card that one of its rfkill | 398 | Every time the driver gets a notification from the card that one of its rfkill |
398 | lines changed state (polling might be needed on badly designed cards that don't | 399 | lines changed state (polling might be needed on badly designed cards that don't |
@@ -422,13 +423,24 @@ of the hardware is unknown), or read-write (where the hardware can be queried | |||
422 | about its current state). | 423 | about its current state). |
423 | 424 | ||
424 | The rfkill class will call the get_state hook of a device every time it needs | 425 | The rfkill class will call the get_state hook of a device every time it needs |
425 | to know the *real* current state of the hardware. This can happen often. | 426 | to know the *real* current state of the hardware. This can happen often, but |
427 | it does not do any polling, so it is not enough on hardware that is subject | ||
428 | to state changes outside of the rfkill subsystem. | ||
429 | |||
430 | Therefore, calling rfkill_force_state() when a state change happens is | ||
431 | mandatory when the device has a hardware rfkill line, or when something else | ||
432 | like the firmware could cause its state to be changed without going through the | ||
433 | rfkill class. | ||
426 | 434 | ||
427 | Some hardware provides events when its status changes. In these cases, it is | 435 | Some hardware provides events when its status changes. In these cases, it is |
428 | best for the driver to not provide a get_state hook, and instead register the | 436 | best for the driver to not provide a get_state hook, and instead register the |
429 | rfkill class *already* with the correct status, and keep it updated using | 437 | rfkill class *already* with the correct status, and keep it updated using |
430 | rfkill_force_state() when it gets an event from the hardware. | 438 | rfkill_force_state() when it gets an event from the hardware. |
431 | 439 | ||
440 | rfkill_force_state() must be used on the device resume handlers to update the | ||
441 | rfkill status, should there be any chance of the device status changing during | ||
442 | the sleep. | ||
443 | |||
432 | There is no provision for a statically-allocated rfkill struct. You must | 444 | There is no provision for a statically-allocated rfkill struct. You must |
433 | use rfkill_allocate() to allocate one. | 445 | use rfkill_allocate() to allocate one. |
434 | 446 | ||
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index 7a560b785097..022fe50ab0e0 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
@@ -252,7 +252,12 @@ EXPORT_SYMBOL_GPL(rfkill_epo); | |||
252 | * a notification by the firmware/hardware of the current *real* | 252 | * a notification by the firmware/hardware of the current *real* |
253 | * state of the radio rfkill switch. | 253 | * state of the radio rfkill switch. |
254 | * | 254 | * |
255 | * It may not be called from an atomic context. | 255 | * Devices which are subject to external changes on their rfkill |
256 | * state (such as those caused by a hardware rfkill line) MUST | ||
257 | * have their driver arrange to call rfkill_force_state() as soon | ||
258 | * as possible after such a change. | ||
259 | * | ||
260 | * This function may not be called from an atomic context. | ||
256 | */ | 261 | */ |
257 | int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) | 262 | int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) |
258 | { | 263 | { |