From patchwork Mon Oct 9 13:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 150086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1855317vqo; Mon, 9 Oct 2023 06:08:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm3ofZL8s0FQSAKhUqwZhsYk9b8Qw3LyldVH45iP0/PM87XjIJelotdgkMXNvwLQwgP+uO X-Received: by 2002:a05:6358:7204:b0:133:4ce:4e8c with SMTP id h4-20020a056358720400b0013304ce4e8cmr19842688rwa.29.1696856917286; Mon, 09 Oct 2023 06:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696856917; cv=none; d=google.com; s=arc-20160816; b=kOIyOhYNhJDfopFS0sMmQ5dLe78f65oA94II3GK1VVtz2Icv6Ud57Z2kVrBQUxINHo zGnut5HSRCpopSVW6Noa/Xh7sVZjwdi0lysDG3lsmuJy29lgJl43eMx4sLt64MK55o5e O+ugVc627PM1+a8f8CKVeH27ntWhgNEXwaNNFWJsmTRFgdfaDLQbhmEpxNXRGw/6NfVX qGjS69+7oLhmil3XYITX2E17dClfbKpY0Wf/eS2BeCuIZLKd7oqzQMD3b1CzPFH4bR/m Sa/H8paa1lpIn/WnYmxDUe1h/YC1Xy2bj0v3aaT4Pyeb2BCD4k5nkxerUYf/YgH7jUYe /6ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=bEr1MM8/2JauJrDARdrIFSYd1FdtFHHP6Pk0B7CMA2I=; fh=wIhSZdiimi4zJ55G6oNWMyXy1Gk0mFu9K7sfr168l7Q=; b=CYtwF+CljVnBfHbL9zkEBzW8NAWcG+YfxXrCB7v+lvEAFf6a/FY1OZsDEd3tTANINE SeDZQOX5eHls0EUBN/twkeezvrqlc39uSWeVpJ4QaksaINorc9JId6eAY2O1S35/eI1s WyAZtyWe334DyNutunPFWZ+6pd8VYl79IVSeZrKKAyA/oS7kEx3smIZK5f1624yaNOSy 3LRqbQsPjnCJYE2D43DuCxzxJnB4uAkIW5jEzi5iGYELyVnwy1+Gove9G7+vObuogsLT AKTcXvm4/gUaB7v5JO07/zocohVf/tEZ2iP7PLyLOX/vriqNZsaonvuWqmJf4MBETgw3 hnGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HVmt6K9Q; dkim=neutral (no key) header.i=@linutronix.de header.b=WO1Act2I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0056fa1bc208esi10539781pgu.722.2023.10.09.06.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HVmt6K9Q; dkim=neutral (no key) header.i=@linutronix.de header.b=WO1Act2I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 504308026856; Mon, 9 Oct 2023 06:08:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376722AbjJININ (ORCPT + 18 others); Mon, 9 Oct 2023 09:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376706AbjJINIL (ORCPT ); Mon, 9 Oct 2023 09:08:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE1194; Mon, 9 Oct 2023 06:08:10 -0700 (PDT) Date: Mon, 09 Oct 2023 13:08:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696856887; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bEr1MM8/2JauJrDARdrIFSYd1FdtFHHP6Pk0B7CMA2I=; b=HVmt6K9QB/yYEVM52Y+FaIxtig6OAjuph9R5H/+p7YEn7lK9FynWgoF40YU8TM4nkAEQsB 0xbsjh+r/Bct2JOWoyGafp44d9+qJVIteDOTfPBY5YRUWuEedXaDUa5Np15LxyzlA0TwIN 1u2BAEWSpaApHKQPDk4I9WVNSBSp/3ISPCP70OZBmEiNIGHh3cgFVXR2nl6UBdeTljOUKd jXyZ0AspFtE4F4YHvlukYXKrH7AfZd360SJEUAfgtxn8B9n8vcvozjVtgAeuVyvbCJ+9/k z0EiVis47+0LebOZmYtgHSUemb6hdm7jBGKpS6CoQskxivaD/yK29AHlpTiLBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696856887; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bEr1MM8/2JauJrDARdrIFSYd1FdtFHHP6Pk0B7CMA2I=; b=WO1Act2IKjSzxOrweWFXbQNaj6TQi1eEVRRwqpOLpeg2gLddHpActWv4dBXPiw4zBIxHuT y4TmzpwQusJu3lBA== From: "tip-bot2 for Guenter Roeck" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] rtc: Add API function to return alarm time bound by hardware limit Cc: Guenter Roeck , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230915152238.1144706-2-linux@roeck-us.net> References: <20230915152238.1144706-2-linux@roeck-us.net> MIME-Version: 1.0 Message-ID: <169685688633.3135.80139071644224201.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:08:30 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283438832963858 X-GMAIL-MSGID: 1779283438832963858 The following commit has been merged into the timers/core branch of tip: Commit-ID: a0fddaa0b5a587cc8d185f8802fe7e48493c43ed Gitweb: https://git.kernel.org/tip/a0fddaa0b5a587cc8d185f8802fe7e48493c43ed Author: Guenter Roeck AuthorDate: Fri, 15 Sep 2023 08:22:37 -07:00 Committer: Thomas Gleixner CommitterDate: Mon, 09 Oct 2023 15:03:28 +02:00 rtc: Add API function to return alarm time bound by hardware limit Add rtc_bound_alarmtime() to return the requested alarm timeout bound by the maxmum alarm timeout that is supported by a given RTC. Signed-off-by: Guenter Roeck Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230915152238.1144706-2-linux@roeck-us.net --- include/linux/rtc.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 4c0bcbe..5f8e438 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -225,6 +225,23 @@ static inline bool is_leap_year(unsigned int year) return (!(year % 4) && (year % 100)) || !(year % 400); } +/** + * rtc_bound_alarmtime() - Return alarm time bound by rtc limit + * @rtc: Pointer to rtc device structure + * @requested: Requested alarm timeout + * + * Return: Alarm timeout bound by maximum alarm time supported by rtc. + */ +static inline ktime_t rtc_bound_alarmtime(struct rtc_device *rtc, + ktime_t requested) +{ + if (rtc->alarm_offset_max && + rtc->alarm_offset_max * MSEC_PER_SEC < ktime_to_ms(requested)) + return ms_to_ktime(rtc->alarm_offset_max * MSEC_PER_SEC); + + return requested; +} + #define devm_rtc_register_device(device) \ __devm_rtc_register_device(THIS_MODULE, device)