Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3096699pxj; Mon, 10 May 2021 18:46:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwozBUucJAUaX0nxwiuTIAsMmOS8rM3MdsBhgjNjGrpeSyzow40UfD7PhPhhCZ3I1/lIlsy X-Received: by 2002:a02:77d6:: with SMTP id g205mr24836883jac.48.1620697589767; Mon, 10 May 2021 18:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620697589; cv=none; d=google.com; s=arc-20160816; b=aFwsoEpTc4+fY8MTXYF5AWfS5VrTkFkch9yQ1Wf9E3pOpAGKv2R96UpdUeBrKM3eCj p04t5S/OdfwWf91YH6RWzEDb8iRKlooGGDPxABI70NNGUUJaiZYp4Ft89hMsZDU6VC07 BcZypFksukdRXQ+d8nkrA9Txc5E/Y8z1IMcSRSeHJhEHiDllZ4wB5LWkX6qk0xLzIAX8 wVQed7AOhtBtydKKAaaZdCmYJiP95ROCIYV9d3OXF2MpIpkLSTzfmJf8FXNoL3Nipqdu or1WYuRQpgPLCvOIQgdTUXLNKhRtetQCRej44ro+SNH3Cc6gdGSwAGChHOA3lZ7wcqFY MW8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+hiS4jgQKJpXeVaMxdoKp/UZ3nzxFfiqfmW9ThOkTHo=; b=KoaURI1iyrdt3NJ76VQA0qlk0f/Nbeq8Eh6+tN1spgXonM3jiTeeWma3V97z8AnLPs iL0aR400/KbG4egGFqkn7kbi7d7OWKjWyqprlPTsQvE+Ys115SDGQzrUgvDRH9KCSqa7 Y0ZvjKu8vP+mj9/htFQrfcmqnyUxSG2KcgX7Ai7RD6VdWAUBm6W0hMSSWUjsfvZIYuw/ iHxfBaT6T/1JxFThsLAdR7B+46M0TFEibsivb3XmK9E4+fwFHeXVWrOVThXJtzJH1XIp r+L2/29RmLjr0O9iO8WC7HiZb7+LdtYducLFIFzNAsdDJvm5Mm8zTZMuft7/HaIBnCVa 7rnw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si19925387iov.91.2021.05.10.18.46.17; Mon, 10 May 2021 18:46:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbhEKBqa (ORCPT + 99 others); Mon, 10 May 2021 21:46:30 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:39679 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230291AbhEKBq1 (ORCPT ); Mon, 10 May 2021 21:46:27 -0400 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 6032920003; Tue, 11 May 2021 01:45:20 +0000 (UTC) From: Alexandre Belloni To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexandre Belloni Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] alarmtimer: check RTC features instead of ops Date: Tue, 11 May 2021 03:45:16 +0200 Message-Id: <20210511014516.563031-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RTC drivers used to leave .set_alarm() NULL in order to signal the RTC device doesn't support alarms. The drivers are now clearing the RTC_FEATURE_ALARM bit for that purpose in order to keep the rtc_class_ops structure const. So now, .set_alarm() is set unconditionally and this possibly causes the alarmtimer code to select an RTC device that doesn't support alarms. Test RTC_FEATURE_ALARM instead of relying on ops->set_alarm to determine whether alarms are available. Fixes: 7ae41220ef58 ("rtc: introduce features bitfield") Signed-off-by: Alexandre Belloni --- kernel/time/alarmtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index bea9d08b1698..5897828b9d7e 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -92,7 +92,7 @@ static int alarmtimer_rtc_add_device(struct device *dev, if (rtcdev) return -EBUSY; - if (!rtc->ops->set_alarm) + if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) return -1; if (!device_may_wakeup(rtc->dev.parent)) return -1; -- 2.31.1