diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2008-07-03 12:14:57 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-07-08 14:16:03 -0400 |
commit | fd4484af7c02b31bcb6090eeb0d85cf947719f2d (patch) | |
tree | b7cf0b5b4ade5c3cd4351b1a1256432356898068 /net/rfkill | |
parent | 0f687e9aeb590e9581709379f47dd13ee9357258 (diff) |
rfkill: ignore errors from rfkill_toggle_radio in rfkill_add_switch
rfkill_add_switch() calls rfkill_toggle_radio() to set the state of a
recently registered rfkill class to the current global state [for that
rfkill->type].
The rfkill_toggle_radio() call is going to error out if the hardware is
RFKILL_STATE_HARD_BLOCKED, and the global state is RFKILL_STATE_UNBLOCKED.
That is a quite normal situation which I missed to account for. As things
stand, the error return from rfkill_toggle_radio ends up causing
rfkill_register to bail out with an error (de-registering the new switch in
the process), which is Not Nice.
Change rfkill_add_switch() to not return errors because of a failed call to
rfkill_toggle_radio(). We can go back to returning errors again (if that's
indeed the right thing to do) if we define the exact error codes the
rfkill->toggle_radio callbacks are to return in each situation, so that we
can ignore the right ones only.
Bug reported by "kionez <kionez@anche.no>".
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: kionez <kionez@anche.no>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/rfkill.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index aa7039dfa19d..7a560b785097 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
@@ -501,17 +501,15 @@ static struct class rfkill_class = { | |||
501 | 501 | ||
502 | static int rfkill_add_switch(struct rfkill *rfkill) | 502 | static int rfkill_add_switch(struct rfkill *rfkill) |
503 | { | 503 | { |
504 | int error; | ||
505 | |||
506 | mutex_lock(&rfkill_mutex); | 504 | mutex_lock(&rfkill_mutex); |
507 | 505 | ||
508 | error = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0); | 506 | rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0); |
509 | if (!error) | 507 | |
510 | list_add_tail(&rfkill->node, &rfkill_list); | 508 | list_add_tail(&rfkill->node, &rfkill_list); |
511 | 509 | ||
512 | mutex_unlock(&rfkill_mutex); | 510 | mutex_unlock(&rfkill_mutex); |
513 | 511 | ||
514 | return error; | 512 | return 0; |
515 | } | 513 | } |
516 | 514 | ||
517 | static void rfkill_remove_switch(struct rfkill *rfkill) | 515 | static void rfkill_remove_switch(struct rfkill *rfkill) |