Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp145729pxf; Wed, 17 Mar 2021 01:21:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpfwbvRFZOrSSmlHcF1g90SL0xVU13ru0EqneFEfE1A3y3+sIEc716m6BLXCsCaVyK92Ws X-Received: by 2002:a17:906:3a94:: with SMTP id y20mr7417057ejd.35.1615969276328; Wed, 17 Mar 2021 01:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615969276; cv=none; d=google.com; s=arc-20160816; b=rbH1raE1vyOifFkGyVKDkNpSV0Wq0TfHjn+jau9HkLfQX2n5aejl4Ao6XIocTOtLX3 DSschOuAS8HNYcd3R+EVW0VoVJgNmjIIWdnDEZfQlTqzp2FZApF21pgqjN3O9thD1PMW +Cn/aneFQlJg1poiHQd6uMp0+rMevAO2nHmbtS7Ev4lQrHfgDoQyCKpGQTcZUc3Eiyur NAstmp/JH2QwI0K556yaMKnQKai1nDUQ7qWeCY1dzKQR41V4RvYQKhREHbPyhP2CDR/M JAH2mEmN5fAss7VoOueeRtSwBpXduhUoOgm1g2LVwj5fKT/jPwH5Hqwh4424ieNdbH84 iBUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :organization:mime-version:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=hLfG1mLh/mmQm3ZtzhfOcgpbBnnOXvRKhCNQzWA7meA=; b=BjX+J72vsnysn+k53+lGLoGe0VKcYBG77NYk8n3A4YWfdu/A6D0POxjL4f16TKIjtR FNkWFNbe6/Z/8O5v/4qIPTia2KUCAkYJZGtn0JD+07WjRBRDisvM8zqcvu3xTwAqrm3J mrcTAR4NV2VDt6pjGRlZemYuQ/y5BRRN07WaW8oXMEYXiH5ydH0htneKG6oiEQ0cceQj 2AB6fCi5RafiSvNcdH8r1Et4VFeI/Y7LBfThR8rAzoLO/tXsSz8pcm+DRfGXEC9j77Lg +IOWRDZwKwe0pYGoNyQOT1w+GVztpdef9IJMCT3pyw8oicPdkl+ESDzG+GoupZv7Z1Ob kpgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="nwLc/q3O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si10272078edn.416.2021.03.17.01.20.52; Wed, 17 Mar 2021 01:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="nwLc/q3O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229584AbhCQIT5 (ORCPT + 99 others); Wed, 17 Mar 2021 04:19:57 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:25132 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhCQITs (ORCPT ); Wed, 17 Mar 2021 04:19:48 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210317081945euoutp02418a84f1ba8795948da5e9d6ad48cb34~tE2mdUXWG0639206392euoutp02- for ; Wed, 17 Mar 2021 08:19:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210317081945euoutp02418a84f1ba8795948da5e9d6ad48cb34~tE2mdUXWG0639206392euoutp02- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1615969185; bh=hLfG1mLh/mmQm3ZtzhfOcgpbBnnOXvRKhCNQzWA7meA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nwLc/q3OM0PnROAP10E7jrli3uZrW8LP9J+9ul92w44umNQixXzFQo7rgLD4EvTr+ Je14c9jAoAZfKNDjfubYecPDZCa1x+/CLjHqMvgNSPIrTRl+PvSZweQW9lNp1LHqOQ dPAGI3n2fszSSKWqrocxin9fHix8AEi05qf02WMg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20210317081944eucas1p2a8414c40a85ebb288eb330aa6ef073a6~tE2lvgm4r0565005650eucas1p2w; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 29.56.09452.0ABB1506; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210317081944eucas1p123bd27f3203c937d2969a66fb06d6d9e~tE2laXpAt3196031960eucas1p1r; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210317081944eusmtrp2cba4efe2928405d112d2361eeb95de27~tE2lZkuZn1423714237eusmtrp2h; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) X-AuditID: cbfec7f2-a9fff700000024ec-f1-6051bba0a4ef Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E3.B7.08696.0ABB1506; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210317081944eusmtip2b2a2731d21436519728ef0f29878a5e1~tE2lOCMoe1399213992eusmtip2Z; Wed, 17 Mar 2021 08:19:44 +0000 (GMT) From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= To: alexandre.belloni@bootlin.com Cc: l.stelmach@samsung.com, a.zummo@towertech.it, b.zolnierkie@samsung.com, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, m.szyprowski@samsung.com Subject: [PATCH 1/2] WIP: Introduce has_alarm method for rtc devices Date: Wed, 17 Mar 2021 09:19:35 +0100 Message-Id: <20210317081936.26583-1-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: MIME-Version: 1.0 Organization: Samsung R&D Institute Poland Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42LZduzned0FuwMTDL68MLBYcvEqu0X7u2Xs FhtnrGe1uHloBaPF5V1z2CyOrb7CZrH2yF12B3aPeWuqPfq2rGL0mD7vJ5PH501yASxRXDYp qTmZZalF+nYJXBmbztxmLJjBW/Gkq5e5gfEDVxcjJ4eEgInElK2PmbsYuTiEBFYwSjye3QTl fGGUOHf4CRuE85lRYlbnO1aYlm3TbjJBJJYzShy6Pp8RwnnOKHFvazsTSBWbgKNE/9ITYB0i AooSt/c9BJvLLLCQUeLBqnVgRcICLhKHD38Es1kEVCX+Ln/OAmLzClhLPH+/CWqdvET78u1s IDangIXEpwlvmSFqBCVOznwCVs8voCWxpuk6mM0MVN+8dTbYMgmBCxwSj36/YIIY5CLRdBbm B2GJV8e3sEPYMhL/d84HquEAsuslJk8yg+jtYZTYNucHC0SNtcSdc7/YQGqYBTQl1u/ShwgD PfnlKyNEK5/EjbeCECfwSUzaNp0ZIswr0dEmBFGtIrGufw/UQCmJ3lcrGCcwKs1C8swsJA/M Qti1gJF5FaN4amlxbnpqsWFearlecWJucWleul5yfu4mRmCCOf3v+KcdjHNffdQ7xMjEwXiI UYK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riDc0MTA1NzCwNTC3NjJXEeU2OrIkXEkhPLEnNTk0tSC2C6WPi 4JRqYMqrea3NFybZ1tvwRmeyWNIJvXs8q45Om/OSWehn6aKFu69ei4h9uemPqp7we60PG+2C Te/+sH0+6e7tC3cDXGvvNB5PUxV2ym3b3O7Fs6Rz1SGd2x93KFRznl4jd1zmulsqn9A0bbVc hu6DrQuDf/dmutuuOdTd8DYru5Vz12vvsLnFU6u+3da/fU7511xD5YnhV7rs2Z//5Vrze1JE pYp/Qt97GTeZn9WbUtatamniPBzumZG+WXxDwLLjPI7hhmpFovJ1F/8a3njzd0v3rF2/7hz5 VOWw5rez8Obpj2svTlEIML91TVzTYMGV/Cb+JtnXvi7Kky+2M7vs/6N7VLEqINc2qmtiaJyG sfKJDiWW4oxEQy3mouJEAFznvEYtAwAA X-CMS-MailID: 20210317081944eucas1p123bd27f3203c937d2969a66fb06d6d9e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20210317081944eucas1p123bd27f3203c937d2969a66fb06d6d9e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210317081944eucas1p123bd27f3203c937d2969a66fb06d6d9e References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The method enables determining whether a device supports setting alarms or not before checking if the alarm to be set is in the past; thus, provides clear indication of support for alarms in a given configuration. Signed-off-by: Ɓukasz Stelmach --- How about has_alarm() method. It can be checked at the beginning of __rtc_set_alarm() like RTC_HAS_ALARM flag I proposed above, but doesn't need to be introduced in all drivers at once. See the following message for the implementation in the ds1307 driver. The first uie_unsupported patch should be kept regardless of these two. drivers/rtc/interface.c | 6 ++++++ include/linux/rtc.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 794a4f036b99..1eb180370d9b 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -412,6 +412,12 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) time64_t now, scheduled; int err; + if (!rtc->ops) + err = -ENODEV; + else if (rtc->ops->has_alarm && + !rtc->ops->has_alarm(rtc->dev.parent)) + return -EINVAL; + err = rtc_valid_tm(&alarm->time); if (err) return err; diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 22d1575e4991..ce9fc77ccd02 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -66,6 +66,7 @@ struct rtc_class_ops { int (*alarm_irq_enable)(struct device *, unsigned int enabled); int (*read_offset)(struct device *, long *offset); int (*set_offset)(struct device *, long offset); + int (*has_alarm)(struct device *); }; struct rtc_device; -- 2.26.2