Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1882084rdb; Mon, 9 Oct 2023 06:08:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4DPfLyi1+rGurlnFcvAVvCcFA77xtwbN7GNY3AG2tyW1Z8ozVCi8kXfDItRP0k6+v1FGc X-Received: by 2002:a17:902:e542:b0:1c3:d07f:39f7 with SMTP id n2-20020a170902e54200b001c3d07f39f7mr14556292plf.62.1696856903248; Mon, 09 Oct 2023 06:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696856903; cv=none; d=google.com; s=arc-20160816; b=K1jOE+zDDmT1w//tfbpT1tFIrSc+etfgl+MKnzGBJVzlOor7m144p8ToexHuMD3tRh sxYPhviMqgJl/PYToANUq1A4TV5tq5Z6PQREpKokQS6DYXyiIUVN1uNjSuVuvrShngFP LOtFwQUNJiT0O9GN2OOSXE8MK2RcpYbsmKfuLzT8IPMPTFnKtqv/fdOSPRsc8MsoCAK9 2A/9vM0bzvkH5bg5InVuAVIkgHyOCyCAujKYQgdDTIKr0A5iJTUonak1elVZbk67ziBo dh7s4YNL2qNa/C29kibgOHSE1qT1J87Kv0CbixWjYoI2UVBU4dnHEXhqCEePtBGYuAas x+6w== 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 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s16-20020a170902ea1000b001bc674914b0si10049108plg.472.2023.10.09.06.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; 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 23.128.96.31 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 2691F8061396; Mon, 9 Oct 2023 06:08:21 -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 S1376720AbjJININ (ORCPT + 99 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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:21 -0700 (PDT) X-Spam-Level: ** 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)