From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752604AbbFLCMv (ORCPT ); Thu, 11 Jun 2015 22:12:51 -0400 Received: from m50-112.126.com ([123.125.50.112]:57339 "EHLO m50-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232AbbFLCMu (ORCPT ); Thu, 11 Jun 2015 22:12:50 -0400 From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , Alexandre Belloni , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [PATCH v3 2/4] rtc/lib: Introduce rtc_tm_sub() helper function Date: Fri, 12 Jun 2015 10:04:10 +0800 Message-Id: <1434074652-16054-2-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434074652-16054-1-git-send-email-xlpang@126.com> References: <1434074652-16054-1-git-send-email-xlpang@126.com> X-CM-TRANSID: j9KowAAnryswPnpVKTVCAA--.101S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKrWxWF1kKFWkGF47Ww1DAwb_yoWkXrc_C3 Wrt348Gw48Z34fA3W7Ka1akFW5Kr4UJw45XryxK3yavr4qyw4kZw4Iyr97Zw1j93yxCFs3 GFWrZ34rJF1SqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0dpnPUUUUU== X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbimhEXv1GfW36ZlgACsF Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xunlei Pang There're many sites need comparing the two rtc_time variants for many rtc drivers, especially in the instances of rtc_class_ops::set_alarm(). So add this common helper function to make things easy. Suggested-by: Arnd Bergmann Signed-off-by: Xunlei Pang --- v2->v3: Respin rtc_tm_subtract() to rtc_tm_sub() using "static inline". include/linux/rtc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 8dcf682..f46f765 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -24,6 +24,14 @@ extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); ktime_t rtc_tm_to_ktime(struct rtc_time tm); struct rtc_time rtc_ktime_to_tm(ktime_t kt); +/* + * rtc_tm_sub - Return the difference in seconds. + */ +static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs) +{ + return rtc_tm_to_time64(lhs) - rtc_tm_to_time64(rhs); +} + /** * Deprecated. Use rtc_time64_to_tm(). */ -- 1.9.1