From patchwork Fri Jun 12 02:04:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49781 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5A2D2460E for ; Fri, 12 Jun 2015 02:12:59 +0000 (UTC) Received: by wgme6 with SMTP id e6sf5871477wgm.3 for ; Thu, 11 Jun 2015 19:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=K9lPsapcuKfRpmnA0YDbxn82bOVDmgtZGKHcolQeW30=; b=jobaVFMQE1nkTsdtZ1yw7txvANIw0yf7G+qbp75P3MQ94ea6c/lu9G+X95EI+FJ2Lv PlCZDt2wbNjeUsfbe7XZmjcId+9IvF2R/TygZS7t/DqLObG1sUpLnDPWNY6+CGr/DjdM r0y8HZWYwZk3bu6opl7hI0Gb/PgyboA0y0enXuggtThgu894KIpAOjZr+PsFP6QzgVZl E2nHYtby9ot2alnLHGGYdi2c1LipinYpkwLrml2FTJshPTJ3tH0NVZfOlBMFcMPzVInU gHTVGT23aSR9gR8BxB5RALqQq4aRX6xL2jw2pLW2rVSBUQ3e78yOb8WkBq2LXmjsPYWY c+SA== X-Gm-Message-State: ALoCoQkaZjXI0cG7vuZq9Sfchd8tw48nAha296OGSm3FGup7QsNW/7lxV3xz0vxZKOoSQja8mh42 X-Received: by 10.152.9.3 with SMTP id v3mr11653345laa.6.1434075179044; Thu, 11 Jun 2015 19:12:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.133 with SMTP id y5ls524304laj.19.gmail; Thu, 11 Jun 2015 19:12:58 -0700 (PDT) X-Received: by 10.112.146.97 with SMTP id tb1mr13176917lbb.12.1434075178866; Thu, 11 Jun 2015 19:12:58 -0700 (PDT) Received: from mail-lb0-x22e.google.com (mail-lb0-x22e.google.com. [2a00:1450:4010:c04::22e]) by mx.google.com with ESMTPS id 4si2125215lar.151.2015.06.11.19.12.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 19:12:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) client-ip=2a00:1450:4010:c04::22e; Received: by lbbqq2 with SMTP id qq2so11985267lbb.3 for ; Thu, 11 Jun 2015 19:12:58 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr12660823lak.117.1434075178721; Thu, 11 Jun 2015 19:12:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp219663lbb; Thu, 11 Jun 2015 19:12:57 -0700 (PDT) X-Received: by 10.68.231.98 with SMTP id tf2mr19412699pbc.12.1434075176987; Thu, 11 Jun 2015 19:12:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rc3si3198637pbc.149.2015.06.11.19.12.56; Thu, 11 Jun 2015 19:12:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbbFLCMw (ORCPT + 29 others); Thu, 11 Jun 2015 22:12:52 -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 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp6 (Coremail) with SMTP id j9KowAAnryswPnpVKTVCAA--.101S3; Fri, 12 Jun 2015 10:04:44 +0800 (CST) 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 Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@126.com; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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(). */