Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] rtc: cros-ec: remove superfluous error message
@ 2019-10-16 20:14 Alexandre Belloni
  2019-10-16 20:14 ` [PATCH 2/2] rtc: cros-ec: let the core handle rtc range Alexandre Belloni
  2019-10-22  7:48 ` [PATCH 1/2] rtc: cros-ec: remove superfluous error message Enric Balletbo i Serra
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-10-16 20:14 UTC (permalink / raw)
  To: linux-rtc
  Cc: Benson Leung, Enric Balletbo i Serra, Guenter Roeck,
	linux-kernel, Alexandre Belloni

The RTC core now has error messages in case of registration failure, there
is no need to have other messages in the drivers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-cros-ec.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-cros-ec.c b/drivers/rtc/rtc-cros-ec.c
index 6909e01936d9..da209d00731e 100644
--- a/drivers/rtc/rtc-cros-ec.c
+++ b/drivers/rtc/rtc-cros-ec.c
@@ -351,11 +351,8 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
 	cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME,
 						    &cros_ec_rtc_ops,
 						    THIS_MODULE);
-	if (IS_ERR(cros_ec_rtc->rtc)) {
-		ret = PTR_ERR(cros_ec_rtc->rtc);
-		dev_err(&pdev->dev, "failed to register rtc device\n");
-		return ret;
-	}
+	if (IS_ERR(cros_ec_rtc->rtc))
+		return PTR_ERR(cros_ec_rtc->rtc);
 
 	/* Get RTC events from the EC. */
 	cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rtc: cros-ec: let the core handle rtc range
  2019-10-16 20:14 [PATCH 1/2] rtc: cros-ec: remove superfluous error message Alexandre Belloni
@ 2019-10-16 20:14 ` Alexandre Belloni
  2019-10-22  7:50   ` Enric Balletbo i Serra
  2019-10-22  7:48 ` [PATCH 1/2] rtc: cros-ec: remove superfluous error message Enric Balletbo i Serra
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2019-10-16 20:14 UTC (permalink / raw)
  To: linux-rtc
  Cc: Benson Leung, Enric Balletbo i Serra, Guenter Roeck,
	linux-kernel, Alexandre Belloni

Let the rtc core check the date/time against the RTC range.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] rtc: cros-ec: remove superfluous error message
  2019-10-16 20:14 [PATCH 1/2] rtc: cros-ec: remove superfluous error message Alexandre Belloni
  2019-10-16 20:14 ` [PATCH 2/2] rtc: cros-ec: let the core handle rtc range Alexandre Belloni
@ 2019-10-22  7:48 ` Enric Balletbo i Serra
  1 sibling, 0 replies; 4+ messages in thread
From: Enric Balletbo i Serra @ 2019-10-22  7:48 UTC (permalink / raw)
  To: Alexandre Belloni, linux-rtc; +Cc: Benson Leung, Guenter Roeck, linux-kernel

Hi Alexandre,

On 16/10/19 22:14, Alexandre Belloni wrote:
> The RTC core now has error messages in case of registration failure, there
> is no need to have other messages in the drivers.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

That makes totally sense for me.

Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> ---
>  drivers/rtc/rtc-cros-ec.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-cros-ec.c b/drivers/rtc/rtc-cros-ec.c
> index 6909e01936d9..da209d00731e 100644
> --- a/drivers/rtc/rtc-cros-ec.c
> +++ b/drivers/rtc/rtc-cros-ec.c
> @@ -351,11 +351,8 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
>  	cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME,
>  						    &cros_ec_rtc_ops,
>  						    THIS_MODULE);
> -	if (IS_ERR(cros_ec_rtc->rtc)) {
> -		ret = PTR_ERR(cros_ec_rtc->rtc);
> -		dev_err(&pdev->dev, "failed to register rtc device\n");
> -		return ret;
> -	}
> +	if (IS_ERR(cros_ec_rtc->rtc))
> +		return PTR_ERR(cros_ec_rtc->rtc);
>  
>  	/* Get RTC events from the EC. */
>  	cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] rtc: cros-ec: let the core handle rtc range
  2019-10-16 20:14 ` [PATCH 2/2] rtc: cros-ec: let the core handle rtc range Alexandre Belloni
@ 2019-10-22  7:50   ` Enric Balletbo i Serra
  0 siblings, 0 replies; 4+ messages in thread
From: Enric Balletbo i Serra @ 2019-10-22  7:50 UTC (permalink / raw)
  To: Alexandre Belloni, linux-rtc; +Cc: Benson Leung, Guenter Roeck, linux-kernel

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 <alexandre.belloni@bootlin.com>

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 <enric.balletbo@collabora.com>


> ---
>  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,
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 20:14 [PATCH 1/2] rtc: cros-ec: remove superfluous error message Alexandre Belloni
2019-10-16 20:14 ` [PATCH 2/2] rtc: cros-ec: let the core handle rtc range Alexandre Belloni
2019-10-22  7:50   ` Enric Balletbo i Serra
2019-10-22  7:48 ` [PATCH 1/2] rtc: cros-ec: remove superfluous error message Enric Balletbo i Serra

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git