From patchwork Thu Feb 24 15:28:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Fietze X-Patchwork-Id: 84406 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-fx0-f56.google.com (mail-fx0-f56.google.com [209.85.161.56]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 461E4B7088 for ; Fri, 25 Feb 2011 02:38:29 +1100 (EST) Received: by fxm3 with SMTP id 3sf337264fxm.11 for ; Thu, 24 Feb 2011 07:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:x-beenthere:received-spf:comment:from :organization:to:subject:user-agent:cc:references:in-reply-to :mime-version:x-tnefevaluated:message-id:date:x-mimetrack :x-original-sender:x-original-authentication-results :x-google-group-id:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=A2RM5kenj4BoJk6cJj3vBbLW4EdsrtNCozosZ2dwkis=; b=jHR+i6qL8tt8lwPfpB5NluxqMHpO3Shqif2iNJHOd7e07Myc7QPAK0YsBkzjd5FYsL jnB1dYiKpXCePjVBNNvf/jCUm1W7FPtZdNkr4OS5Onew+a1kIT7hFZ/GAmiYK4SKs42y NsHdSAkQHpGxYLmRHy1w7/n2gZMCMv4XgBfec= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:comment:from:organization:to:subject :user-agent:cc:references:in-reply-to:mime-version:x-tnefevaluated :message-id:date:x-mimetrack:x-original-sender :x-original-authentication-results:x-google-group-id:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; b=jvpEuPGkDDdrSCfnm3SXpm0P1lwS41fV47L0XwScWzWgJJcjsUtRh0ZBsCTI8ns11u HEzFCPie3kV69DsiqDcaEFvd3i+4yvD72uH8prmnI3rhvTr7DHvguLoQxz39LDM90QSZ EUx6005NdGkDOHMtC2Jr2t/kOg9TqXHpEBU4c= Received: by 10.223.83.199 with SMTP id g7mr89438fal.25.1298561323195; Thu, 24 Feb 2011 07:28:43 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.204.75.35 with SMTP id w35ls311217bkj.3.p; Thu, 24 Feb 2011 07:28:42 -0800 (PST) Received: by 10.204.16.207 with SMTP id p15mr118269bka.22.1298561322683; Thu, 24 Feb 2011 07:28:42 -0800 (PST) Received: by 10.204.16.207 with SMTP id p15mr118268bka.22.1298561322667; Thu, 24 Feb 2011 07:28:42 -0800 (PST) Received: from coyote.quickmin.net (coyote.quickmin.net [217.14.112.24]) by gmr-mx.google.com with ESMTPS id dd11si1723946bkb.4.2011.02.24.07.28.41 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Feb 2011 07:28:41 -0800 (PST) Received-SPF: neutral (google.com: 217.14.112.24 is neither permitted nor denied by best guess record for domain of roman.fietze@telemotive.de) client-ip=217.14.112.24; Received: (qmail 46933 invoked from network); 24 Feb 2011 16:28:40 +0100 Received: by simscan 1.4.0 ppid: 46930, pid: 46931, t: 0.0163s scanners: clamav: 0.95.2/m:49/d:8609 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys Received: from mail.telemotive.de (62.206.149.210) by coyote.quickmin.net with SMTP; 24 Feb 2011 16:28:40 +0100 Received: from alderan.mit.telemotive.de ([10.96.96.15]) by mail.telemotive.de (Lotus Domino Release 8.0.2FP1) with ESMTP id 2011022416284025-9623 ; Thu, 24 Feb 2011 16:28:40 +0100 Received: from rfietze.mit.telemotive.de (rfietze.mit.telemotive.de [10.96.97.33]) by alderan.mit.telemotive.de (Postfix) with ESMTP id 6F7AFD56FE; Thu, 24 Feb 2011 16:28:40 +0100 (CET) Received: by rfietze.mit.telemotive.de (Postfix, from userid 10062) id 606C720791; Thu, 24 Feb 2011 16:28:40 +0100 (CET) From: Roman Fietze Organization: Telemotive AG To: John Stultz Subject: [rtc-linux] [PATCH 3/3] rtc core: use pointers to pass rtc_time to and from ktime conversion routines User-Agent: KMail/1.13.6 (Linux/2.6.34.7-0.7-default; KDE/4.6.0; x86_64; ; ) Cc: rtc-linux@googlegroups.com References: <201102241624.47015.roman.fietze@telemotive.de> In-Reply-To: <201102241624.47015.roman.fietze@telemotive.de> MIME-Version: 1.0 X-TNEFEvaluated: 1 Message-ID: <201102241628.40267.roman.fietze@telemotive.de> Date: Thu, 24 Feb 2011 16:28:40 +0100 X-MIMETrack: Itemize by SMTP Server on muc/Telemotive(Release 8.0.2FP1|January 12, 2009) at 24.02.2011 16:28:40, Serialize by Router on muc/Telemotive(Release 8.0.2FP1|January 12, 2009) at 24.02.2011 16:28:40, Serialize complete at 24.02.2011 16:28:40 X-Original-Sender: roman.fietze@telemotive.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 217.14.112.24 is neither permitted nor denied by best guess record for domain of roman.fietze@telemotive.de) smtp.mail=roman.fietze@telemotive.de; domainkeys=pass header.From=roman.fietze@telemotive.de X-Google-Group-Id: -934837877 Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Hello John, Now the one where I'm really awaiting some comments ... eventually. From 36019404e6a3525dc6b87e826750a5e5a371646b Mon Sep 17 00:00:00 2001 From: Roman Fietze Date: Thu, 24 Feb 2011 16:11:25 +0100 Subject: [PATCH 3/3] rtc core: use pointers to pass rtc_time to and from ktime conversion routines Use a const struct rtc_time pointer to pass the RTC time to rtc_tm_to_ktime() instead of by value. Use a struct rtc_time pointer to return the RTC time from rtc_ktime_to_tm(). This change saves a little code space. The struct rtc_time consts of nine integers, structures this big shouldn't be passed or returned by value. This way the way of passing and returning rtc_time also matches the other functions handling rtc_time. Signed-off-by: Roman Fietze --- drivers/rtc/interface.c | 14 +++++++------- drivers/rtc/rtc-lib.c | 10 ++++------ include/linux/rtc.h | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index cb2f072..06a401c 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -130,7 +130,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) else { memset(alarm, 0, sizeof(struct rtc_wkalrm)); alarm->enabled = rtc->aie_timer.enabled; - alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); + rtc_ktime_to_tm(rtc->aie_timer.node.expires, &alarm->time); } mutex_unlock(&rtc->ops_lock); @@ -185,7 +185,7 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) if (rtc->aie_timer.enabled) { rtc_timer_remove(rtc, &rtc->aie_timer); } - rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); + rtc->aie_timer.node.expires = rtc_tm_to_ktime(&alarm->time); rtc->aie_timer.period = ktime_set(0, 0); if (alarm->enabled) { err = rtc_timer_enqueue(rtc, &rtc->aie_timer); @@ -244,7 +244,7 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) __rtc_read_time(rtc, &tm); onesec = ktime_set(1, 0); - now = rtc_tm_to_ktime(tm); + now = rtc_tm_to_ktime(&tm); rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); rtc->uie_rtctimer.period = ktime_set(1, 0); err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer); @@ -521,7 +521,7 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) { struct rtc_wkalrm alarm; int err; - alarm.time = rtc_ktime_to_tm(timer->node.expires); + rtc_ktime_to_tm(timer->node.expires, &alarm.time); alarm.enabled = 1; err = __rtc_set_alarm(rtc, &alarm); if (err == -ETIME) @@ -558,7 +558,7 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) next = timerqueue_getnext(&rtc->timerqueue); if (!next) return; - alarm.time = rtc_ktime_to_tm(next->expires); + rtc_ktime_to_tm(next->expires, &alarm.time); alarm.enabled = 1; err = __rtc_set_alarm(rtc, &alarm); if (err == -ETIME) @@ -589,7 +589,7 @@ void rtc_timer_do_work(struct work_struct *work) mutex_lock(&rtc->ops_lock); again: __rtc_read_time(rtc, &tm); - now = rtc_tm_to_ktime(tm); + now = rtc_tm_to_ktime(&tm); while ((next = timerqueue_getnext(&rtc->timerqueue))) { if (next->expires.tv64 > now.tv64) break; @@ -614,7 +614,7 @@ again: if (next) { struct rtc_wkalrm alarm; int err; - alarm.time = rtc_ktime_to_tm(next->expires); + rtc_ktime_to_tm(next->expires, &alarm.time); alarm.enabled = 1; err = __rtc_set_alarm(rtc, &alarm); if (err == -ETIME) diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 2341ce6..40c37b6 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -120,10 +120,10 @@ EXPORT_SYMBOL(rtc_tm_to_time); /* * Convert rtc_time to ktime */ -ktime_t rtc_tm_to_ktime(struct rtc_time tm) +ktime_t rtc_tm_to_ktime(const struct rtc_time *tm) { time_t time; - rtc_tm_to_time(&tm, &time); + rtc_tm_to_time(tm, &time); return ktime_set(time, 0); } EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); @@ -131,17 +131,15 @@ EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); /* * Convert ktime to rtc_time */ -struct rtc_time rtc_ktime_to_tm(ktime_t kt) +void rtc_ktime_to_tm(ktime_t kt, struct rtc_time *tm) { struct timespec ts; - struct rtc_time ret; ts = ktime_to_timespec(kt); /* Round up any ns */ if (ts.tv_nsec) ts.tv_sec++; - rtc_time_to_tm(ts.tv_sec, &ret); - return ret; + rtc_time_to_tm(ts.tv_sec, tm); } EXPORT_SYMBOL_GPL(rtc_ktime_to_tm); diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 58c0cde..43639c9 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -107,8 +107,8 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year extern int rtc_valid_tm(const struct rtc_time *tm); extern int rtc_tm_to_time(const struct rtc_time *tm, unsigned long *time); extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); -extern ktime_t rtc_tm_to_ktime(struct rtc_time tm); -extern struct rtc_time rtc_ktime_to_tm(ktime_t kt); +extern ktime_t rtc_tm_to_ktime(const struct rtc_time *tm); +extern void rtc_ktime_to_tm(ktime_t kt, struct rtc_time *tm); #include