Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1244635ima; Wed, 24 Oct 2018 17:35:49 -0700 (PDT) X-Google-Smtp-Source: AJdET5dD7hI2+ZmDpoovHE6hVa3JISbOooJE3emz0IuxxL9+AJGaNCgeR7aFbMLmsKZ//TqBrVc0 X-Received: by 2002:a17:902:4103:: with SMTP id e3-v6mr4467535pld.236.1540427749349; Wed, 24 Oct 2018 17:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540427749; cv=none; d=google.com; s=arc-20160816; b=zwPkghvFgx5Xo3/T9/97z78RVKTWozkDUUQ6+f2A2A+uvASlz0UIQCOC3MEqL2wU8v O5qbun0xjo6Uzv5CnxRcZY+SdyAK54P5D4m8tabQDgmnbZFwGcRrEDlmplhATLl31xCw H9H83R1QsQLINnv5ElybRQ8xdcHRSvEWkPZopMZwl5eA0Gnq+MgRlbzSMp/izE29SlB3 aSzuavGaqljZdpdRkOMRG/M4ay8SR04+n93zj4d4H27f7Hpd4MALNePunjyCJ0yJiRCH wybOI8DJTT3HQntLnwsoniP13bBtE37jgwehS09CTsYUrKByNvC0MCYbIOkQs5bcAmEw POLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=v9GmkYuRdXgrFtZfcwaPjY45w8UyTSRgQsfB6/Osj0g=; b=SOKxj8S1gyw9bFcBVAXlrOUSZXu3pY2nSPS4q57S0ODBsUMpUSkeSH3n+kJ7f75e5Y 3/14ZHJOw6EVNrMFG/CbM2EO0Kd2mkYaWKvU1X/8iLvjTDnWsmvbJp/Y9yK7crF0m/ZQ QI9fDEfXLT3MGIG08d2Gbm1lxz0EiAYmALVL+Mqi6/+N+uy+TKQVweVXl0IBfQrkuApd DWBEhhw/+IH7n68w8yIOjcIxnuc+5c1z06TZ6t23NWovyZjzPm/DC5IrlC27KMwliGQu WZv1hD8wQCipFoS8Q3nHnbsAMzjxx4olQVh09JXSKIwgoaSeMjfY81m5VudH2rc8TyNY tsBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u34-v6si6435381pgk.124.2018.10.24.17.35.33; Wed, 24 Oct 2018 17:35:49 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbeJYJFR (ORCPT + 99 others); Thu, 25 Oct 2018 05:05:17 -0400 Received: from mail.bootlin.com ([62.4.15.54]:59006 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbeJYJFR (ORCPT ); Thu, 25 Oct 2018 05:05:17 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 6CA25207C3; Thu, 25 Oct 2018 02:34:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (unknown [2.223.63.88]) by mail.bootlin.com (Postfix) with ESMTPSA id 2C2C720729; Thu, 25 Oct 2018 02:34:56 +0200 (CEST) Date: Thu, 25 Oct 2018 02:34:56 +0200 From: Alexandre Belloni To: Baolin Wang Cc: a.zummo@towertech.it, broonie@kernel.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] rtc: sc27xx: Always read normal alarm when registering RTC device Message-ID: <20181025003456.GB2737@piout.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 18/10/2018 16:52:30+0800, Baolin Wang wrote: > When registering one RTC device, it will check to see if there is an > alarm already set in RTC hardware by reading RTC alarm, at this time > we should always read the normal alarm put in always-on region by > checking the rtc->registered flag. > > Signed-off-by: Baolin Wang > --- > drivers/rtc/rtc-sc27xx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/rtc/rtc-sc27xx.c b/drivers/rtc/rtc-sc27xx.c > index 72bb002..b4eb3b3 100644 > --- a/drivers/rtc/rtc-sc27xx.c > +++ b/drivers/rtc/rtc-sc27xx.c > @@ -415,10 +415,14 @@ static int sprd_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) > u32 val; > > /* > - * If aie_timer is enabled, we should get the normal alarm time. > + * Before RTC device is registered, it will check to see if there is an > + * alarm already set in RTC hardware, and we always read the normal > + * alarm at this time. > + * > + * Or if aie_timer is enabled, we should get the normal alarm time. > * Otherwise we should get auxiliary alarm time. > */ > - if (rtc->rtc && rtc->rtc->aie_timer.enabled == 0) > + if (rtc->rtc && rtc->rtc->registered && rtc->rtc->aie_timer.enabled == 0) Note that the driver should not access rtc->registered and rtc->aie_timer.enabled and this is a bit fragile. But, on the other hand, I currently don't have anything better to suggest. I was also planning to add an in-kernel API for multiple alarms but I'm not sure it will actually help in your case. Anyway, this is applied. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com