Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp989646ybp; Thu, 17 Oct 2019 06:32:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyP/5JDETfKKC6yy9Fhwe2JZxiGwtyAde22k8+ZUmubWCWpM/0jEwOe6/XvE7fDn3CZHrsc X-Received: by 2002:a17:906:bfcb:: with SMTP id us11mr3446478ejb.299.1571319161946; Thu, 17 Oct 2019 06:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319161; cv=none; d=google.com; s=arc-20160816; b=ykvf+dDe4sWzxXBXizpF64y4MQmQaEayqCoGlmLgobLA3YuaSnODc+nCB1eIugQIku oF4imIyQKLGoRPSaVeIdIE6rRHbzifkQ+5YbSZ4i872vuq6hIdm6L5cS7l0KtZ0he3LN /raUyJCapZhI3VozoNYWCnwJ2ldVzjrXVsIh4GXoKV9b6nFhmP76V9glhtBJSKEBAKml 6YarWPRLXDMc8FbWuqM+vfz8/qjXaCc0rh2ErXKff4sRPGcZxojVPpwUe8Y+6pIAwfMW DxHA3bG8p6hfcaCmxTDTVwzxcE/CvzrrPwITt5tB7mG/gQcWmDroeORvzarkCJ9Bk0Mu 1Ajg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IWCyivo5DFQ3dzjPJhWMEpSFXaBUnnQuDJ2jbsyfI7Y=; b=1JF7i0Q6XWXWbIYoHMLuTlSVqEFAxjYFkjnQ/lMEndGaGGimvSZ0lGWHpKL8rEQ17E ymXPdBCnOO9khseQWVBKHh9E7Mvhxy6JUzDyx7z9Tb4FvNmN2SXmtdkcsv9uauICY5/Y 5xuV/PrArqfh7uZyy3sfr8O6DnC6UeqUgy/w2OnoE0oEBVuM4nEO+CYRHg7drdDh08rw 7dMM62vIHCt/VfGGlsrqTOjd5rokPLgXNJSYtZ4LN+CegL0kRM5n+iu3HkbyfoqShMlL ooJLtjzxQ6drPhUKvl1XZpE0GsYLj5z1lohMJspomts6eMUSC4c95E8OguKjDo1JKLGp 3hdw== 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 q4si1343797ejb.136.2019.10.17.06.32.18; Thu, 17 Oct 2019 06:32:41 -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 S2436829AbfJPUOT (ORCPT + 99 others); Wed, 16 Oct 2019 16:14:19 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:52353 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394703AbfJPUOS (ORCPT ); Wed, 16 Oct 2019 16:14:18 -0400 Received: from localhost (lfbn-lyo-1-146-42.w86-202.abo.wanadoo.fr [86.202.229.42]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 1E25B240006; Wed, 16 Oct 2019 20:14:17 +0000 (UTC) From: Alexandre Belloni To: linux-rtc@vger.kernel.org Cc: Benson Leung , Enric Balletbo i Serra , Guenter Roeck , linux-kernel@vger.kernel.org, Alexandre Belloni Subject: [PATCH 2/2] rtc: cros-ec: let the core handle rtc range Date: Wed, 16 Oct 2019 22:14:14 +0200 Message-Id: <20191016201414.30934-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016201414.30934-1-alexandre.belloni@bootlin.com> References: <20191016201414.30934-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let the rtc core check the date/time against the RTC range. Signed-off-by: Alexandre Belloni --- 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, -- 2.21.0