All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: Kukjin Kim <kgene.kim@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, rtc-linux@googlegroups.com,
	p_gortmaker@yahoo.com, Wan ZongShun <mcuos.com@gmail.com>,
	a.zummo@towertech.it, ben-linux@fluff.org,
	Changhwan Youn <chaos.youn@samsung.com>
Subject: Re: [PATCH 4/5] rtc: rtc-s3c: Fix on RTC initialization method
Date: Wed, 08 Sep 2010 00:24:50 +0100	[thread overview]
Message-ID: <4C86C9C2.20603@fluff.org> (raw)
In-Reply-To: <1283837381-9575-5-git-send-email-kgene.kim@samsung.com>

On 07/09/10 06:29, Kukjin Kim wrote:
> From: Changhwan Youn <chaos.youn@samsung.com>
> 
> This patch changes RTC initialization method on probe() as
> per Wan ZongShun's suggestion. The 'rtc_valid_tm(tm)' can
> check whether RTC BCD is valid or not.
> 
> And should be changed the method of check because previous
> method cannot validate RTC BCD registers properly.
> 
> Signed-off-by: Changhwan Youn <chaos.youn@samsung.com>
> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> ---
>  drivers/rtc/rtc-s3c.c |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index c078548..7f15073 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -458,8 +458,8 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
>  static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>  {
>  	struct rtc_device *rtc;
> +	struct rtc_time rtc_tm;
>  	struct resource *res;
> -	unsigned int tmp, i;
>  	int ret;
>  
>  	pr_debug("%s: probe=%p\n", __func__, pdev);
> @@ -540,11 +540,17 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>  
>  	/* Check RTC Time */
>  
> -	for (i = S3C2410_RTCSEC; i <= S3C2410_RTCYEAR; i += 0x4) {
> -		tmp = readb(s3c_rtc_base + i);
> +	s3c_rtc_gettime(NULL, &rtc_tm);
>  
> -		if ((tmp & 0xf) > 0x9 || ((tmp >> 4) & 0xf) > 0x9)
> -			writeb(0, s3c_rtc_base + i);
> +	if (rtc_valid_tm(&rtc_tm)) {
> +		rtc_tm.tm_year	= 100;
> +		rtc_tm.tm_mon	= 0;
> +		rtc_tm.tm_mday	= 1;
> +		rtc_tm.tm_hour	= 0;
> +		rtc_tm.tm_min	= 0;
> +		rtc_tm.tm_sec	= 0;
> +
> +		s3c_rtc_settime(NULL, &rtc_tm);

I think a dev_warn() in this path is good to alert the user
to bad things happening, esp if the system should have a valid
time, it marks he posibility the rtc battery has gone.

WARNING: multiple messages have this Message-ID (diff)
From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/5] rtc: rtc-s3c: Fix on RTC initialization method
Date: Wed, 08 Sep 2010 00:24:50 +0100	[thread overview]
Message-ID: <4C86C9C2.20603@fluff.org> (raw)
In-Reply-To: <1283837381-9575-5-git-send-email-kgene.kim@samsung.com>

On 07/09/10 06:29, Kukjin Kim wrote:
> From: Changhwan Youn <chaos.youn@samsung.com>
> 
> This patch changes RTC initialization method on probe() as
> per Wan ZongShun's suggestion. The 'rtc_valid_tm(tm)' can
> check whether RTC BCD is valid or not.
> 
> And should be changed the method of check because previous
> method cannot validate RTC BCD registers properly.
> 
> Signed-off-by: Changhwan Youn <chaos.youn@samsung.com>
> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> ---
>  drivers/rtc/rtc-s3c.c |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index c078548..7f15073 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -458,8 +458,8 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
>  static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>  {
>  	struct rtc_device *rtc;
> +	struct rtc_time rtc_tm;
>  	struct resource *res;
> -	unsigned int tmp, i;
>  	int ret;
>  
>  	pr_debug("%s: probe=%p\n", __func__, pdev);
> @@ -540,11 +540,17 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>  
>  	/* Check RTC Time */
>  
> -	for (i = S3C2410_RTCSEC; i <= S3C2410_RTCYEAR; i += 0x4) {
> -		tmp = readb(s3c_rtc_base + i);
> +	s3c_rtc_gettime(NULL, &rtc_tm);
>  
> -		if ((tmp & 0xf) > 0x9 || ((tmp >> 4) & 0xf) > 0x9)
> -			writeb(0, s3c_rtc_base + i);
> +	if (rtc_valid_tm(&rtc_tm)) {
> +		rtc_tm.tm_year	= 100;
> +		rtc_tm.tm_mon	= 0;
> +		rtc_tm.tm_mday	= 1;
> +		rtc_tm.tm_hour	= 0;
> +		rtc_tm.tm_min	= 0;
> +		rtc_tm.tm_sec	= 0;
> +
> +		s3c_rtc_settime(NULL, &rtc_tm);

I think a dev_warn() in this path is good to alert the user
to bad things happening, esp if the system should have a valid
time, it marks he posibility the rtc battery has gone.

  parent reply	other threads:[~2010-09-07 23:24 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-07  5:29 [PATCH 0/5] rtc: rtc-s3c: Fix RTC bugs for RTC-S3C Kukjin Kim
2010-09-07  5:29 ` Kukjin Kim
2010-09-07  5:29 ` [PATCH 1/5] rtc: rtc-s3c: Fix access unit from byte to word on RTCCON Kukjin Kim
2010-09-07  5:29   ` Kukjin Kim
2010-09-07 23:17   ` Ben Dooks
2010-09-07 23:17     ` Ben Dooks
2010-09-07  5:29 ` [PATCH 2/5] rtc: rtc-s3c: Fix setting missing field of getalarm Kukjin Kim
2010-09-07  5:29   ` Kukjin Kim
2010-09-07 23:21   ` Ben Dooks
2010-09-07 23:21     ` Ben Dooks
2010-09-07  5:29 ` [PATCH 3/5] rtc: rtc-s3c: Fix on support RTC Alarm Kukjin Kim
2010-09-07  5:29   ` Kukjin Kim
2010-09-07 23:22   ` Ben Dooks
2010-09-07 23:22     ` Ben Dooks
2010-09-07  5:29 ` [PATCH 4/5] rtc: rtc-s3c: Fix on RTC initialization method Kukjin Kim
2010-09-07  5:29   ` Kukjin Kim
2010-09-07  8:56   ` Kyungmin Park
2010-09-07  8:56     ` Kyungmin Park
2010-09-07 23:24   ` Ben Dooks [this message]
2010-09-07 23:24     ` Ben Dooks
2010-09-08  1:55     ` Wan ZongShun
2010-09-08  1:55       ` Wan ZongShun
2010-09-09  1:03       ` Kukjin Kim
2010-09-09  1:03         ` Kukjin Kim
2010-09-09  1:04     ` Kukjin Kim
2010-09-09  1:04       ` Kukjin Kim
2010-09-07  5:29 ` [PATCH 5/5] rtc: rtc-s3c: Fix debug message format on RTC Kukjin Kim
2010-09-07  5:29   ` Kukjin Kim
2010-09-07 23:29   ` Ben Dooks
2010-09-07 23:29     ` Ben Dooks
2010-09-09  1:11     ` Kukjin Kim
2010-09-09  1:11       ` Kukjin Kim
2010-09-10  9:05       ` [rtc-linux] " Wan ZongShun
2010-09-10  9:05         ` Wan ZongShun
2010-09-10 11:38         ` Kukjin Kim
2010-09-10 11:38           ` Kukjin Kim
2010-09-10 23:23           ` Andrew Morton
2010-09-10 23:23             ` Andrew Morton
2010-09-10 23:35             ` Kukjin Kim
2010-09-10 23:35               ` Kukjin Kim
2010-10-07 23:16             ` Kukjin Kim
2010-10-07 23:16               ` Kukjin Kim
2010-10-07 23:28               ` Andrew Morton
2010-10-07 23:28                 ` Andrew Morton
2010-10-07 23:46                 ` Kukjin Kim
2010-10-07 23:46                   ` Kukjin Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C86C9C2.20603@fluff.org \
    --to=ben-linux@fluff.org \
    --cc=a.zummo@towertech.it \
    --cc=chaos.youn@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mcuos.com@gmail.com \
    --cc=p_gortmaker@yahoo.com \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.