aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author=?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>2011-12-13 01:23:17 +0800
committerAndy Green <andy.green@linaro.org>2012-01-09 10:53:04 +0800
commit1366abf37a05dc9a3fe69517e45615bb1279c77b (patch)
treeacf9623b19312c3e30c59dd06d6a1fc6ad03f830
parente597d791b16bfc0dd49750cb0fb983f09a5fc70b (diff)
downloadimx53-1366abf37a05dc9a3fe69517e45615bb1279c77b.tar.gz
rtc: alarm: Update hrtimer if alarm at the head of the queue is reprogrammed
MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an alarm was restarted with a value that moved it away from the head of a queue, the hrtimer would not be updated. This would cause unnecessary wakeups. Change-Id: If379f8dd92b0bdb3173bd8d057adfe0dc1d15259 Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--drivers/rtc/alarm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/rtc/alarm.c b/drivers/rtc/alarm.c
index 084ef648f9c..e0e98dd1eac 100644
--- a/drivers/rtc/alarm.c
+++ b/drivers/rtc/alarm.c
@@ -109,12 +109,15 @@ static void alarm_enqueue_locked(struct alarm *alarm)
struct rb_node *parent = NULL;
struct alarm *entry;
int leftmost = 1;
+ bool was_first = false;
pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires));
- if (base->first == &alarm->node)
+ if (base->first == &alarm->node) {
base->first = rb_next(&alarm->node);
+ was_first = true;
+ }
if (!RB_EMPTY_NODE(&alarm->node)) {
rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node);
@@ -134,10 +137,10 @@ static void alarm_enqueue_locked(struct alarm *alarm)
leftmost = 0;
}
}
- if (leftmost) {
+ if (leftmost)
base->first = &alarm->node;
- update_timer_locked(base, false);
- }
+ if (leftmost || was_first)
+ update_timer_locked(base, was_first);
rb_link_node(&alarm->node, parent, link);
rb_insert_color(&alarm->node, &base->alarms);