提交 fd4484af 编写于 作者: H Henrique de Moraes Holschuh 提交者: John W. Linville

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: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: kionez <kionez@anche.no>
Acked-by: NIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 0f687e9a
......@@ -501,17 +501,15 @@ static struct class rfkill_class = {
static int rfkill_add_switch(struct rfkill *rfkill)
{
int error;
mutex_lock(&rfkill_mutex);
error = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0);
if (!error)
list_add_tail(&rfkill->node, &rfkill_list);
rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0);
list_add_tail(&rfkill->node, &rfkill_list);
mutex_unlock(&rfkill_mutex);
return error;
return 0;
}
static void rfkill_remove_switch(struct rfkill *rfkill)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册