From patchwork Tue Jan 31 03:49:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 6457 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CB215249CF for ; Tue, 31 Jan 2012 03:49:54 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id BB24DA18772 for ; Tue, 31 Jan 2012 03:49:54 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id r19so5134385bka.11 for ; Mon, 30 Jan 2012 19:49:54 -0800 (PST) Received: by 10.205.130.12 with SMTP id hk12mr9677937bkc.56.1327981794575; Mon, 30 Jan 2012 19:49:54 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs170405bks; Mon, 30 Jan 2012 19:49:54 -0800 (PST) Received: by 10.68.240.164 with SMTP id wb4mr46826028pbc.57.1327981792559; Mon, 30 Jan 2012 19:49:52 -0800 (PST) Received: from e39.co.us.ibm.com (e39.co.us.ibm.com. [32.97.110.160]) by mx.google.com with ESMTPS id l7si14053278pbd.250.2012.01.30.19.49.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jan 2012 19:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.160 as permitted sender) client-ip=32.97.110.160; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.160 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Jan 2012 20:49:51 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 30 Jan 2012 20:49:48 -0700 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id AB3DB1FF0038; Mon, 30 Jan 2012 20:49:47 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0V3nlbE139606; Mon, 30 Jan 2012 20:49:47 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0V3nlm1009218; Mon, 30 Jan 2012 20:49:47 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0V3nkn7008904; Mon, 30 Jan 2012 20:49:47 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 69319BFE5E; Mon, 30 Jan 2012 19:49:45 -0800 (PST) From: John Stultz To: Greg KH Cc: John Stultz , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Greg KH , Android Kernel Team Subject: [PATCH 05/11] android-alarm: Fix namespace collision with upstreamed alarmtimers Date: Mon, 30 Jan 2012 19:49:26 -0800 Message-Id: <1327981772-12329-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1327981772-12329-1-git-send-email-john.stultz@linaro.org> References: <1327981772-12329-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12013103-4242-0000-0000-000000A6DBE0 The upstreamed alarmtimers are similar but not quite 100% API compatibile with the android in-kernel alarm api. To aid the transition, prefix the the android in-kernel api with android_ CC: Arve Hjønnevåg CC: Greg KH CC: Android Kernel Team Signed-off-by: John Stultz --- drivers/staging/android/alarm-dev.c | 14 ++++++------ drivers/staging/android/alarm.c | 37 ++++++++++++++++--------------- drivers/staging/android/android_alarm.h | 17 +++++++------ 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c index 96a2cce..21a6200 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -56,7 +56,7 @@ static uint32_t alarm_pending; static uint32_t alarm_enabled; static uint32_t wait_pending; -static struct alarm alarms[ANDROID_ALARM_TYPE_COUNT]; +static struct android_alarm alarms[ANDROID_ALARM_TYPE_COUNT]; static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -91,7 +91,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case ANDROID_ALARM_CLEAR(0): spin_lock_irqsave(&alarm_slock, flags); pr_alarm(IO, "alarm %d clear\n", alarm_type); - alarm_try_to_cancel(&alarms[alarm_type]); + android_alarm_try_to_cancel(&alarms[alarm_type]); if (alarm_pending) { alarm_pending &= ~alarm_type_mask; if (!alarm_pending && !wait_pending) @@ -122,7 +122,7 @@ from_old_alarm_set: pr_alarm(IO, "alarm %d set %ld.%09ld\n", alarm_type, new_alarm_time.tv_sec, new_alarm_time.tv_nsec); alarm_enabled |= alarm_type_mask; - alarm_start_range(&alarms[alarm_type], + android_alarm_start_range(&alarms[alarm_type], timespec_to_ktime(new_alarm_time), timespec_to_ktime(new_alarm_time)); spin_unlock_irqrestore(&alarm_slock, flags); @@ -153,7 +153,7 @@ from_old_alarm_set: rv = -EFAULT; goto err1; } - rv = alarm_set_rtc(new_rtc_time); + rv = android_alarm_set_rtc(new_rtc_time); spin_lock_irqsave(&alarm_slock, flags); alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK; wake_up(&alarm_wait_queue); @@ -214,7 +214,7 @@ static int alarm_release(struct inode *inode, struct file *file) alarm_enabled &= ~alarm_type_mask; } spin_unlock_irqrestore(&alarm_slock, flags); - alarm_cancel(&alarms[i]); + android_alarm_cancel(&alarms[i]); spin_lock_irqsave(&alarm_slock, flags); } if (alarm_pending | wait_pending) { @@ -231,7 +231,7 @@ static int alarm_release(struct inode *inode, struct file *file) return 0; } -static void alarm_triggered(struct alarm *alarm) +static void alarm_triggered(struct android_alarm *alarm) { unsigned long flags; uint32_t alarm_type_mask = 1U << alarm->type; @@ -270,7 +270,7 @@ static int __init alarm_dev_init(void) return err; for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) - alarm_init(&alarms[i], i, alarm_triggered); + android_alarm_init(&alarms[i], i, alarm_triggered); wake_lock_init(&alarm_wake_lock, WAKE_LOCK_SUSPEND, "alarm"); return 0; diff --git a/drivers/staging/android/alarm.c b/drivers/staging/android/alarm.c index 54bcae2..fa7a7d8 100644 --- a/drivers/staging/android/alarm.c +++ b/drivers/staging/android/alarm.c @@ -71,7 +71,7 @@ static bool suspended; static void update_timer_locked(struct alarm_queue *base, bool head_removed) { - struct alarm *alarm; + struct android_alarm *alarm; bool is_wakeup = base == &alarms[ANDROID_ALARM_RTC_WAKEUP] || base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP]; @@ -86,7 +86,7 @@ static void update_timer_locked(struct alarm_queue *base, bool head_removed) if (!base->first) return; - alarm = container_of(base->first, struct alarm, node); + alarm = container_of(base->first, struct android_alarm, node); pr_alarm(FLOW, "selected alarm, type %d, func %pF at %lld\n", alarm->type, alarm->function, ktime_to_ns(alarm->expires)); @@ -103,12 +103,12 @@ static void update_timer_locked(struct alarm_queue *base, bool head_removed) hrtimer_start_expires(&base->timer, HRTIMER_MODE_ABS); } -static void alarm_enqueue_locked(struct alarm *alarm) +static void alarm_enqueue_locked(struct android_alarm *alarm) { struct alarm_queue *base = &alarms[alarm->type]; struct rb_node **link = &base->alarms.rb_node; struct rb_node *parent = NULL; - struct alarm *entry; + struct android_alarm *entry; int leftmost = 1; pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n", @@ -123,7 +123,7 @@ static void alarm_enqueue_locked(struct alarm *alarm) while (*link) { parent = *link; - entry = rb_entry(parent, struct alarm, node); + entry = rb_entry(parent, struct android_alarm, node); /* * We dont care about collisions. Nodes with * the same expiry time stay together. @@ -145,13 +145,13 @@ static void alarm_enqueue_locked(struct alarm *alarm) } /** - * alarm_init - initialize an alarm + * android_alarm_init - initialize an alarm * @alarm: the alarm to be initialized * @type: the alarm type to be used * @function: alarm callback function */ -void alarm_init(struct alarm *alarm, - enum android_alarm_type type, void (*function)(struct alarm *)) +void android_alarm_init(struct android_alarm *alarm, + enum android_alarm_type type, void (*function)(struct android_alarm *)) { RB_CLEAR_NODE(&alarm->node); alarm->type = type; @@ -162,12 +162,13 @@ void alarm_init(struct alarm *alarm, /** - * alarm_start_range - (re)start an alarm + * android_alarm_start_range - (re)start an alarm * @alarm: the alarm to be added * @start: earliest expiry time * @end: expiry time */ -void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end) +void android_alarm_start_range(struct android_alarm *alarm, ktime_t start, + ktime_t end) { unsigned long flags; @@ -179,7 +180,7 @@ void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end) } /** - * alarm_try_to_cancel - try to deactivate an alarm + * android_alarm_try_to_cancel - try to deactivate an alarm * @alarm: alarm to stop * * Returns: @@ -188,7 +189,7 @@ void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end) * -1 when the alarm may currently be excuting the callback function and * cannot be stopped (it may also be inactive) */ -int alarm_try_to_cancel(struct alarm *alarm) +int android_alarm_try_to_cancel(struct android_alarm *alarm) { struct alarm_queue *base = &alarms[alarm->type]; unsigned long flags; @@ -219,17 +220,17 @@ int alarm_try_to_cancel(struct alarm *alarm) } /** - * alarm_cancel - cancel an alarm and wait for the handler to finish. + * android_alarm_cancel - cancel an alarm and wait for the handler to finish. * @alarm: the alarm to be cancelled * * Returns: * 0 when the alarm was not active * 1 when the alarm was active */ -int alarm_cancel(struct alarm *alarm) +int android_alarm_cancel(struct android_alarm *alarm) { for (;;) { - int ret = alarm_try_to_cancel(alarm); + int ret = android_alarm_try_to_cancel(alarm); if (ret >= 0) return ret; cpu_relax(); @@ -240,7 +241,7 @@ int alarm_cancel(struct alarm *alarm) * alarm_set_rtc - set the kernel and rtc walltime * @new_time: timespec value containing the new time */ -int alarm_set_rtc(struct timespec new_time) +int android_alarm_set_rtc(struct timespec new_time) { int i; int ret; @@ -318,7 +319,7 @@ ktime_t alarm_get_elapsed_realtime(void) static enum hrtimer_restart alarm_timer_triggered(struct hrtimer *timer) { struct alarm_queue *base; - struct alarm *alarm; + struct android_alarm *alarm; unsigned long flags; ktime_t now; @@ -332,7 +333,7 @@ static enum hrtimer_restart alarm_timer_triggered(struct hrtimer *timer) base - alarms, ktime_to_ns(now)); while (base->first) { - alarm = container_of(base->first, struct alarm, node); + alarm = container_of(base->first, struct android_alarm, node); if (alarm->softexpires.tv64 > now.tv64) { pr_alarm(FLOW, "don't call alarm, %pF, %lld (s %lld)\n", alarm->function, ktime_to_ns(alarm->expires), diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h index 753ed93..9213581 100644 --- a/drivers/staging/android/android_alarm.h +++ b/drivers/staging/android/android_alarm.h @@ -57,23 +57,24 @@ enum android_alarm_type { * */ -struct alarm { +struct android_alarm { struct rb_node node; enum android_alarm_type type; ktime_t softexpires; ktime_t expires; - void (*function)(struct alarm *); + void (*function)(struct android_alarm *); }; -void alarm_init(struct alarm *alarm, - enum android_alarm_type type, void (*function)(struct alarm *)); -void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end); -int alarm_try_to_cancel(struct alarm *alarm); -int alarm_cancel(struct alarm *alarm); +void android_alarm_init(struct android_alarm *alarm, + enum android_alarm_type type, void (*function)(struct android_alarm *)); +void android_alarm_start_range(struct android_alarm *alarm, ktime_t start, + ktime_t end); +int android_alarm_try_to_cancel(struct android_alarm *alarm); +int android_alarm_cancel(struct android_alarm *alarm); ktime_t alarm_get_elapsed_realtime(void); /* set rtc while preserving elapsed realtime */ -int alarm_set_rtc(const struct timespec ts); +int android_alarm_set_rtc(const struct timespec ts); #endif