Commit eab48345 authored by Vitaly Wool's avatar Vitaly Wool Committed by Johannes Berg

rfkill: prevent unnecessary event generation

Prevent unnecessary rfkill event generation when the state has
not actually changed. These events have to be delivered to
relevant userspace processes, causing these processes to wake
up and do something while they could as well have slept. This
obviously results in more CPU usage, longer time-to-sleep-again
and therefore higher power consumption.
Signed-off-by: default avatarVitaly Wool <vitalywool@gmail.com>
Signed-off-by: default avatarMykyta Iziumtsev <nikita.izyumtsev@gmail.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent c6f219dc
...@@ -270,6 +270,7 @@ static bool __rfkill_set_hw_state(struct rfkill *rfkill, ...@@ -270,6 +270,7 @@ static bool __rfkill_set_hw_state(struct rfkill *rfkill,
static void rfkill_set_block(struct rfkill *rfkill, bool blocked) static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
{ {
unsigned long flags; unsigned long flags;
bool prev, curr;
int err; int err;
if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP)) if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP))
...@@ -284,6 +285,8 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked) ...@@ -284,6 +285,8 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
rfkill->ops->query(rfkill, rfkill->data); rfkill->ops->query(rfkill, rfkill->data);
spin_lock_irqsave(&rfkill->lock, flags); spin_lock_irqsave(&rfkill->lock, flags);
prev = rfkill->state & RFKILL_BLOCK_SW;
if (rfkill->state & RFKILL_BLOCK_SW) if (rfkill->state & RFKILL_BLOCK_SW)
rfkill->state |= RFKILL_BLOCK_SW_PREV; rfkill->state |= RFKILL_BLOCK_SW_PREV;
else else
...@@ -313,10 +316,13 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked) ...@@ -313,10 +316,13 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
} }
rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL; rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL;
rfkill->state &= ~RFKILL_BLOCK_SW_PREV; rfkill->state &= ~RFKILL_BLOCK_SW_PREV;
curr = rfkill->state & RFKILL_BLOCK_SW;
spin_unlock_irqrestore(&rfkill->lock, flags); spin_unlock_irqrestore(&rfkill->lock, flags);
rfkill_led_trigger_event(rfkill); rfkill_led_trigger_event(rfkill);
rfkill_event(rfkill);
if (prev != curr)
rfkill_event(rfkill);
} }
#ifdef CONFIG_RFKILL_INPUT #ifdef CONFIG_RFKILL_INPUT
......
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