Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5502715ybg; Tue, 22 Oct 2019 04:20:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxn03KukjmQVBkD6RLhrkZOmT489mny8c72pKilQ5yfkGbSiZ7gAxi8Tm8pc/YLknnx8v22 X-Received: by 2002:a17:906:e0b:: with SMTP id l11mr6640772eji.245.1571743232087; Tue, 22 Oct 2019 04:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571743232; cv=none; d=google.com; s=arc-20160816; b=JsTaxNs5FhgcIOCcKNksOSSrDS5cgURqX7hQMQ5MLnD8dDRQp9unYppnO0LxloB0Mm L8jPA2kIQZ0/abPCSIpuo3L3yFwoweUOi57UdcdkTuRUq8JuHxGlac06rgk7W6PDEXA5 cq++bw2Ao6em/ly4d6nBYJoupCZy4h7CmKdtr+fMYrLF5LWprvcflOhZ9sI3AmdLbQcZ U1650gB12ebApl9yMLuf/vvrFzkfX75FNGP6Y5DVdZlOBm2mGucVpSVpyA+qj6FO9OMY dSjMuxJTd7pcaWZCm6AHA/DWnfwwG0VE1NVmDfFehCm4Vz8t+HZOttLZx2nSlyQFPXu/ +VJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=k1iZIYfxMZoov4U8wQ/btwm0c5HY0Io86Ign9XcU3Vw=; b=ujc+MzIpcrEDHjRU64DehXVSR1u0XRfFUvIWeSBYRMj9Pduf/qsf/wVpLW9I4a3IJc bD0shbjSkCvbN+PXrAV4louRnssJLf03+Dmp88fERvpnIIVTtC6iujPDmPkdV/fMHX/+ wILtEOGuNlw27ffes0gflQrgx6DWsiMx2tZPZGoKtcW6yV463Fk14Rfwgu04TEipyn/K AvJGTw/rI0sTPHyFfsWsGWlwq+ld3n2QLhS6muFEzKs9gscW42v8rM/xLU3bSEpPWNFU xVL2o6Gp8aJI0VnSaR2P9Xe1YEco9zowE/NqtipmChYunPnQjUFCFG5oXr/HZglujNdq cHwg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k43si1268356edb.150.2019.10.22.04.20.07; Tue, 22 Oct 2019 04:20:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387981AbfJVHu1 (ORCPT + 99 others); Tue, 22 Oct 2019 03:50:27 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44820 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387938AbfJVHu1 (ORCPT ); Tue, 22 Oct 2019 03:50:27 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 05D0D28C273 Subject: Re: [PATCH 2/2] rtc: cros-ec: let the core handle rtc range To: Alexandre Belloni , linux-rtc@vger.kernel.org Cc: Benson Leung , Guenter Roeck , linux-kernel@vger.kernel.org References: <20191016201414.30934-1-alexandre.belloni@bootlin.com> <20191016201414.30934-2-alexandre.belloni@bootlin.com> From: Enric Balletbo i Serra Message-ID: Date: Tue, 22 Oct 2019 09:50:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191016201414.30934-2-alexandre.belloni@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, On 16/10/19 22:14, Alexandre Belloni wrote: > Let the rtc core check the date/time against the RTC range. > > Signed-off-by: Alexandre Belloni Tested on few devices just to make sure nothing is broken, the change looks good to me and works as expected. Reviewed-by: Enric Balletbo i Serra > --- > drivers/rtc/rtc-cros-ec.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/drivers/rtc/rtc-cros-ec.c b/drivers/rtc/rtc-cros-ec.c > index da209d00731e..d043d30f05bc 100644 > --- a/drivers/rtc/rtc-cros-ec.c > +++ b/drivers/rtc/rtc-cros-ec.c > @@ -107,11 +107,7 @@ static int cros_ec_rtc_set_time(struct device *dev, struct rtc_time *tm) > struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev); > struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec; > int ret; > - time64_t time; > - > - time = rtc_tm_to_time64(tm); > - if (time < 0 || time > U32_MAX) > - return -EINVAL; > + time64_t time = rtc_tm_to_time64(tm); > > ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time); > if (ret < 0) { > @@ -348,12 +344,17 @@ static int cros_ec_rtc_probe(struct platform_device *pdev) > return ret; > } > > - cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME, > - &cros_ec_rtc_ops, > - THIS_MODULE); > + cros_ec_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); > if (IS_ERR(cros_ec_rtc->rtc)) > return PTR_ERR(cros_ec_rtc->rtc); > > + cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops; > + cros_ec_rtc->rtc->range_max = U32_MAX; > + > + ret = rtc_register_device(cros_ec_rtc->rtc); > + if (ret) > + return ret; > + > /* Get RTC events from the EC. */ > cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event; > ret = blocking_notifier_chain_register(&cros_ec->event_notifier, >