Commit 33f9359a authored by Hans de Goede's avatar Hans de Goede Committed by Matthew Garrett

dell-laptop: Don't set sw_state from the query callback

The query callback should only update the hw_state, see the comment in
net/rfkill/core.c in rfkill_set_block, which is its only caller.

rfkill_set_block will modify the sw_state directly after calling query so
calling set_sw_state is an expensive NOP.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
parent d038880e
...@@ -425,10 +425,15 @@ static int dell_rfkill_set(void *data, bool blocked) ...@@ -425,10 +425,15 @@ static int dell_rfkill_set(void *data, bool blocked)
return ret; return ret;
} }
static void dell_rfkill_update(struct rfkill *rfkill, int radio, int status) static void dell_rfkill_update_sw_state(struct rfkill *rfkill, int radio,
int status)
{ {
rfkill_set_sw_state(rfkill, !!(status & BIT(radio + 16))); rfkill_set_sw_state(rfkill, !!(status & BIT(radio + 16)));
}
static void dell_rfkill_update_hw_state(struct rfkill *rfkill, int radio,
int status)
{
if (hwswitch_state & (BIT(radio - 1))) if (hwswitch_state & (BIT(radio - 1)))
rfkill_set_hw_state(rfkill, !(status & BIT(16))); rfkill_set_hw_state(rfkill, !(status & BIT(16)));
} }
...@@ -442,7 +447,7 @@ static void dell_rfkill_query(struct rfkill *rfkill, void *data) ...@@ -442,7 +447,7 @@ static void dell_rfkill_query(struct rfkill *rfkill, void *data)
status = buffer->output[1]; status = buffer->output[1];
release_buffer(); release_buffer();
dell_rfkill_update(rfkill, (unsigned long)data, status); dell_rfkill_update_hw_state(rfkill, (unsigned long)data, status);
} }
static const struct rfkill_ops dell_rfkill_ops = { static const struct rfkill_ops dell_rfkill_ops = {
...@@ -528,12 +533,18 @@ static void dell_update_rfkill(struct work_struct *ignored) ...@@ -528,12 +533,18 @@ static void dell_update_rfkill(struct work_struct *ignored)
status = buffer->output[1]; status = buffer->output[1];
release_buffer(); release_buffer();
if (wifi_rfkill) if (wifi_rfkill) {
dell_rfkill_update(wifi_rfkill, 1, status); dell_rfkill_update_hw_state(wifi_rfkill, 1, status);
if (bluetooth_rfkill) dell_rfkill_update_sw_state(wifi_rfkill, 1, status);
dell_rfkill_update(bluetooth_rfkill, 2, status); }
if (wwan_rfkill) if (bluetooth_rfkill) {
dell_rfkill_update(wwan_rfkill, 3, status); dell_rfkill_update_hw_state(bluetooth_rfkill, 2, status);
dell_rfkill_update_sw_state(bluetooth_rfkill, 2, status);
}
if (wwan_rfkill) {
dell_rfkill_update_hw_state(wwan_rfkill, 3, status);
dell_rfkill_update_sw_state(wwan_rfkill, 3, status);
}
} }
static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill); static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment