From patchwork Thu Feb 9 22:24:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 6747 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 C96D423E01 for ; Thu, 9 Feb 2012 22:29:30 +0000 (UTC) Received: from mail-gx0-f180.google.com (mail-gx0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 807D4A18089 for ; Thu, 9 Feb 2012 22:29:30 +0000 (UTC) Received: by ggnr1 with SMTP id r1so1539747ggn.11 for ; Thu, 09 Feb 2012 14:29:30 -0800 (PST) Received: by 10.50.57.234 with SMTP id l10mr6762794igq.12.1328826569782; Thu, 09 Feb 2012 14:29:29 -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.231.12.131 with SMTP id x3cs56450ibx; Thu, 9 Feb 2012 14:29:29 -0800 (PST) Received: by 10.101.105.3 with SMTP id h3mr1656833anm.6.1328826568768; Thu, 09 Feb 2012 14:29:28 -0800 (PST) Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com. [32.97.182.145]) by mx.google.com with ESMTPS id y1si4127094yha.21.2012.02.09.14.29.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Feb 2012 14:29:28 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) client-ip=32.97.182.145; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.145 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2012 17:29:21 -0500 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e5.ny.us.ibm.com (192.168.1.105) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2012 17:25:05 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 6AB4D38C8052; Thu, 9 Feb 2012 17:24:51 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q19MOpnn3448918; Thu, 9 Feb 2012 17:24:51 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q19MOole019421; Thu, 9 Feb 2012 20:24:50 -0200 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q19MOnSw019389; Thu, 9 Feb 2012 20:24:49 -0200 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 17A9DBFEC5; Thu, 9 Feb 2012 14:24:48 -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/12] android-alarm: Fix namespace collision with upstreamed alarmtimers Date: Thu, 9 Feb 2012 14:24:34 -0800 Message-Id: <1328826281-27148-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1328826281-27148-1-git-send-email-john.stultz@linaro.org> References: <1328826281-27148-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12020922-5930-0000-0000-000004F48083 X-Gm-Message-State: ALoCoQkZ/8CDhqulZSDv9JjsbFQZ0S54Mu8vA669g43sDHNoCdwOcg4cTXlyGcRX+BJgnASN54vF 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 80ea850..758d828 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -55,7 +55,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) { @@ -90,7 +90,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) @@ -121,7 +121,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); @@ -152,7 +152,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); @@ -213,7 +213,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) { @@ -230,7 +230,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; @@ -269,7 +269,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 7aaf5b8..1f8bb5c 100644 --- a/drivers/staging/android/alarm.c +++ b/drivers/staging/android/alarm.c @@ -70,7 +70,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]; @@ -85,7 +85,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)); @@ -102,12 +102,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", @@ -122,7 +122,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. @@ -144,13 +144,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; @@ -161,12 +161,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; @@ -178,7 +179,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: @@ -187,7 +188,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; @@ -218,17 +219,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(); @@ -239,7 +240,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; @@ -317,7 +318,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; @@ -331,7 +332,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