From patchwork Tue Jun 2 09:04:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49348 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 A2F782052D for ; Tue, 2 Jun 2015 09:08:06 +0000 (UTC) Received: by wgla2 with SMTP id a2sf39219819wgl.1 for ; Tue, 02 Jun 2015 02:08:06 -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=xBQD6cDFZjqzelHZGVuko7DOyuc36WINj7J63mGfU1w=; b=nHhU2TKMZOcM/AmZcK5NULR88ZTEYQGPAPVJzt6z0XkaZPkWuCuK8dA5uUHaDIBYOK hTamQRH9obgfVgK961BMwCfJ51OYwy9v+kkuEH7fcHRfHN2yPmem950G+Fih9zKVufYp 5IR0ormxO1VChu+6sgdkx3J/5xXD7iFte/7j/Estwgy+RJQWhGeE7EwfzhA7UIIgzcj+ zx1bAcNMccX+B7ihf8l4y4RRaAZb7P2/dHorWGzAl8VL+NwdjUcfxG5n/KanBDzqLgpM eaFmWgPiW5Z/Z0BRrHWsJIMSMBNwjo+waqcG8YZada2ZYqYPpI27h7cb6zpPYA/M1r6H aWDA== X-Gm-Message-State: ALoCoQn4nmg2KxiiDm5lpTxzuLdD7FNYRjWFkU85zayI2sdpdLSGwnYq8ePGQwjzdtbITJeJJKxD X-Received: by 10.194.5.229 with SMTP id v5mr24906934wjv.0.1433236085971; Tue, 02 Jun 2015 02:08:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.7 with SMTP id m7ls761412laj.70.gmail; Tue, 02 Jun 2015 02:08:05 -0700 (PDT) X-Received: by 10.112.85.204 with SMTP id j12mr24258684lbz.47.1433236085778; Tue, 02 Jun 2015 02:08:05 -0700 (PDT) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com. [2a00:1450:4010:c04::22f]) by mx.google.com with ESMTPS id je10si14561506lac.49.2015.06.02.02.08.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 02:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) client-ip=2a00:1450:4010:c04::22f; Received: by lbbqq2 with SMTP id qq2so100145218lbb.3 for ; Tue, 02 Jun 2015 02:08:05 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr24704245lbc.72.1433236085663; Tue, 02 Jun 2015 02:08:05 -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 hn6csp2909930lbb; Tue, 2 Jun 2015 02:08:04 -0700 (PDT) X-Received: by 10.68.245.67 with SMTP id xm3mr10714971pbc.45.1433236083919; Tue, 02 Jun 2015 02:08:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mk3si25429441pdb.222.2015.06.02.02.08.02; Tue, 02 Jun 2015 02:08:03 -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 S1756691AbbFBJHt (ORCPT + 28 others); Tue, 2 Jun 2015 05:07:49 -0400 Received: from m50-110.126.com ([123.125.50.110]:44317 "EHLO m50-110.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755176AbbFBJH0 (ORCPT ); Tue, 2 Jun 2015 05:07:26 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp4 (Coremail) with SMTP id jdKowADHAkWqcW1V1JEqAQ--.1798S3; Tue, 02 Jun 2015 17:04:49 +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 v2 2/4] rtc/lib: Introduce rtc_tm_subtract() helper function Date: Tue, 2 Jun 2015 17:04:20 +0800 Message-Id: <1433235862-1638-2-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433235862-1638-1-git-send-email-xlpang@126.com> References: <1433235862-1638-1-git-send-email-xlpang@126.com> X-CM-TRANSID: jdKowADHAkWqcW1V1JEqAQ--.1798S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF48Xr4rKFWfJFyxJw1UWrg_yoW8ArWfpF 4Duw1DGr4kKrnYgF9rGws7Za13W3y8Jr4kWF98Jws3Za48ta4kGFykC3WUtryDta95CF4a qF4rZrn8Wr1UW37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jT7KsUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi6BENv1UJQRZYMQAAsp 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::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; 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 --- drivers/rtc/rtc-lib.c | 9 +++++++++ include/linux/rtc.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index e6bfb9c..fdb94cc 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -124,6 +124,15 @@ time64_t rtc_tm_to_time64(struct rtc_time *tm) EXPORT_SYMBOL(rtc_tm_to_time64); /* + * rtc_tm_subtract - Return the difference in seconds. + */ +time64_t rtc_tm_subtract(struct rtc_time *minuend, struct rtc_time *subtrahend) +{ + return rtc_tm_to_time64(minuend) - rtc_tm_to_time64(subtrahend); +} +EXPORT_SYMBOL_GPL(rtc_tm_subtract); + +/* * Convert rtc_time to ktime */ ktime_t rtc_tm_to_ktime(struct rtc_time tm) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 8dcf682..13e4138 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -21,6 +21,8 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year extern int rtc_valid_tm(struct rtc_time *tm); extern time64_t rtc_tm_to_time64(struct rtc_time *tm); extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); +extern time64_t rtc_tm_subtract(struct rtc_time *minuend, + struct rtc_time *subtrahend); ktime_t rtc_tm_to_ktime(struct rtc_time tm); struct rtc_time rtc_ktime_to_tm(ktime_t kt);