Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1303301ima; Wed, 24 Oct 2018 18:58:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5dmL4Rzp/6hoaxbmaX8mkg/WZeNswWcQt67kNT2zgAr962wO2SUST6nh+PoJ7KwjWs+6N27 X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr1293231plg.310.1540432725452; Wed, 24 Oct 2018 18:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540432725; cv=none; d=google.com; s=arc-20160816; b=HnUTdKLe80upo+VB5zRHnzWRM99olIsa3VZ1mMQeBx8kXDybOg98Kpu9/0XKVIwJH9 bgF2vtD1dZw9khxQlp7d2PnGDqBcXZ1Iz7ob9yhd4s0e4E//z1/RffFw0fNG0gWWczID EIgAqy0wZj7798PXS+OJnHy+HezN48xHnNH3L0dUpCIwqUpnG2IEP9VAh3PNdeLfpwqb DKf0pWyhwk77pepMLGISKCFPB5Uh9pvPOfimt+ZbmdUq76pM7Tt6DUYAb9ZVmCTKr+2B BtqXf/U9Dzj23AagQ6+fYBLgQmYqa29L7eHrJg4HqNAAYYjsh3/Ad9TcoB0q/Bx7rGkS 5KKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=3MAOzR6LOCJt++ofCZuUAgfpHuME7Ee1ftRjmgI42/o=; b=YP2sa1v1ZXRTHOhUhaaGNI+eR/998lNjaBLsti9ure1LjuLKo46WPu7nXmuaIqu9oT /2whnF/A7xRG+Mc97NuoHIxK5yfyNKdNALqQ05f5hECCX7/yqAqNEkvGYlxYKwShUYhh pHqfEyApi2rWTTo8OFlcl6SEuc/sGePLECCel+af6n4jG6JHYq3Yfe2Ko/6jEs1APEfK NWN+KSq5uJM5nFtPzyPO+TMZJecoRBL43WLK76RVfz2ikmHfBChWUx2hP5upihI22LMa RrpbSAT5fyVO/sIL+Sgp1zbec6790qh+SSP4eMSJoE8Iy1RfiLAFekexYvrAVAonTEI5 HCkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RAsiQYlL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n23-v6si6579278pgl.574.2018.10.24.18.58.29; Wed, 24 Oct 2018 18:58:45 -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; dkim=pass header.i=@linaro.org header.s=google header.b=RAsiQYlL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727201AbeJYK1v (ORCPT + 99 others); Thu, 25 Oct 2018 06:27:51 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39222 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeJYK1u (ORCPT ); Thu, 25 Oct 2018 06:27:50 -0400 Received: by mail-lf1-f65.google.com with SMTP id p11-v6so5488751lfc.6 for ; Wed, 24 Oct 2018 18:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3MAOzR6LOCJt++ofCZuUAgfpHuME7Ee1ftRjmgI42/o=; b=RAsiQYlLJj1gxv1EDYRjLlP5+Ti6HddKAwVMBGxWzgG6e0pz3VXv9eAgsDPA1caBRK ulsSGuWAKMYYrlBwxqcVV2FeGqw5JPXPZk1D8HVT1h+3tnW2W8USBHIeNRt9ElUx0VDr U/spS4xVycAfdh73k+Z0ldkwpzx7tDJPfiV+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3MAOzR6LOCJt++ofCZuUAgfpHuME7Ee1ftRjmgI42/o=; b=mh+uOJeiDnEzJ0EIm80AFeH4w85aiV3s/yytOGMqAek3eEsVFCGxzau5wJO4MYVolh btW/bTLkdqxThedbISmCrTno5uHuzpXPI1ex1grFEulvBNubbrsl+xIbQ1/ZlBSQef3t vU4REumj98EmFKaZbnhXoM43jRRhGWLSvfGIQEkQeqjKC8zE+cB+V4+2dZEWsCXYURMv Jt6xwS2fIAQPC08197JtmQ4cGhhKUiqesB2d/MIZNnAEvHbUt6hlVsI4SPf0iA2GtuxC ImZ0s0n0/pZeq2Jk1d7vlSW+xOurkRNGZzx6cQ+II/iEE46h9cm5Bl3xrRfjt2qfe1ee 2Q3g== X-Gm-Message-State: AGRZ1gLlTxr1nnhNc3hXDin8cnC6ay6bOak/251dUEzcsC8y4iqcBTiA HOAdsM4+Ow+Cz8xi/lUPrBIFdNY4u2ZqNham/cM4dA== X-Received: by 2002:a19:ca51:: with SMTP id h17mr81759lfj.126.1540432635951; Wed, 24 Oct 2018 18:57:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:95d7:0:0:0:0:0 with HTTP; Wed, 24 Oct 2018 18:57:15 -0700 (PDT) In-Reply-To: <20181025003456.GB2737@piout.net> References: <20181025003456.GB2737@piout.net> From: Baolin Wang Date: Thu, 25 Oct 2018 09:57:15 +0800 Message-ID: Subject: Re: [PATCH 5/5] rtc: sc27xx: Always read normal alarm when registering RTC device To: Alexandre Belloni Cc: Alessandro Zummo , Mark Brown , linux-rtc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, On 25 October 2018 at 08:34, Alexandre Belloni wrote: > 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. Yes, I understand your concern. I will glad to help to test if you introduce new APIs for multiple alarms to see if they can help in our case. Thanks. -- Baolin Wang Best Regards