diff options
author | Vitaly Wool <vitaly.wool@sonymobile.com> | 2012-09-06 10:06:52 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-09-24 04:35:54 -0400 |
commit | eab48345c2b2d791159aaac4a77000baa8dbc1ae (patch) | |
tree | 7ea44540a71f3dd482441b458ae4127f055a14c3 /net/rfkill | |
parent | c6f219dc83fbb30c8426fcc7850c28d9d33dee44 (diff) |
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: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Mykyta Iziumtsev <nikita.izyumtsev@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index c275bad12068..a5c952741279 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -270,6 +270,7 @@ static bool __rfkill_set_hw_state(struct rfkill *rfkill, | |||
270 | static void rfkill_set_block(struct rfkill *rfkill, bool blocked) | 270 | static void rfkill_set_block(struct rfkill *rfkill, bool blocked) |
271 | { | 271 | { |
272 | unsigned long flags; | 272 | unsigned long flags; |
273 | bool prev, curr; | ||
273 | int err; | 274 | int err; |
274 | 275 | ||
275 | if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP)) | 276 | 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 | rfkill->ops->query(rfkill, rfkill->data); | 285 | rfkill->ops->query(rfkill, rfkill->data); |
285 | 286 | ||
286 | spin_lock_irqsave(&rfkill->lock, flags); | 287 | spin_lock_irqsave(&rfkill->lock, flags); |
288 | prev = rfkill->state & RFKILL_BLOCK_SW; | ||
289 | |||
287 | if (rfkill->state & RFKILL_BLOCK_SW) | 290 | if (rfkill->state & RFKILL_BLOCK_SW) |
288 | rfkill->state |= RFKILL_BLOCK_SW_PREV; | 291 | rfkill->state |= RFKILL_BLOCK_SW_PREV; |
289 | else | 292 | else |
@@ -313,10 +316,13 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked) | |||
313 | } | 316 | } |
314 | rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL; | 317 | rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL; |
315 | rfkill->state &= ~RFKILL_BLOCK_SW_PREV; | 318 | rfkill->state &= ~RFKILL_BLOCK_SW_PREV; |
319 | curr = rfkill->state & RFKILL_BLOCK_SW; | ||
316 | spin_unlock_irqrestore(&rfkill->lock, flags); | 320 | spin_unlock_irqrestore(&rfkill->lock, flags); |
317 | 321 | ||
318 | rfkill_led_trigger_event(rfkill); | 322 | rfkill_led_trigger_event(rfkill); |
319 | rfkill_event(rfkill); | 323 | |
324 | if (prev != curr) | ||
325 | rfkill_event(rfkill); | ||
320 | } | 326 | } |
321 | 327 | ||
322 | #ifdef CONFIG_RFKILL_INPUT | 328 | #ifdef CONFIG_RFKILL_INPUT |