Patchwork [1/2] RTC: s3c: Initialize driver data before using it

login
register
mail settings
Submitter Maurus Cuelenaere
Date May 27, 2010, 9:28 p.m.
Message ID <4BFEE40D.4030807@gmail.com>
Download mbox | patch
Permalink /patch/53814/
State New
Headers show

Comments

Maurus Cuelenaere - May 27, 2010, 9:28 p.m.
s3c_rtc_setfreq() uses the platform driver data to derive struct rtc_device,
so make sure drvdata is set _before_ s3c_rtc_setfreq() is called.

Signed-off-by: Maurus Cuelenaere <mcuelenaere@gmail.com>
---
 drivers/rtc/rtc-s3c.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Andrew Morton - May 27, 2010, 9:51 p.m.
On Thu, 27 May 2010 23:28:45 +0200
Maurus Cuelenaere <mcuelenaere@gmail.com> wrote:

> s3c_rtc_setfreq() uses the platform driver data to derive struct rtc_device,
> so make sure drvdata is set _before_ s3c_rtc_setfreq() is called.
> 
> Signed-off-by: Maurus Cuelenaere <mcuelenaere@gmail.com>
> ---
>  drivers/rtc/rtc-s3c.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index e5972b2..6adebf3 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -495,8 +495,6 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>   	pr_debug("s3c2410_rtc: RTCCON=%02x\n",
>  		 readb(s3c_rtc_base + S3C2410_RTCCON));
>  
> -	s3c_rtc_setfreq(&pdev->dev, 1);
> -
>  	device_init_wakeup(&pdev->dev, 1);
>  
>  	/* register RTC and exit */
> @@ -518,6 +516,9 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
>  	s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
>  
>  	platform_set_drvdata(pdev, rtc);
> +
> +	s3c_rtc_setfreq(&pdev->dev, 1);
> +
>  	return 0;
>  
>   err_nortc:

This one I tagged for a -stable backport.

Patch

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index e5972b2..6adebf3 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -495,8 +495,6 @@  static int __devinit s3c_rtc_probe(struct platform_device *pdev)
  	pr_debug("s3c2410_rtc: RTCCON=%02x\n",
 		 readb(s3c_rtc_base + S3C2410_RTCCON));
 
-	s3c_rtc_setfreq(&pdev->dev, 1);
-
 	device_init_wakeup(&pdev->dev, 1);
 
 	/* register RTC and exit */
@@ -518,6 +516,9 @@  static int __devinit s3c_rtc_probe(struct platform_device *pdev)
 	s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
 
 	platform_set_drvdata(pdev, rtc);
+
+	s3c_rtc_setfreq(&pdev->dev, 1);
+
 	return 0;
 
  err_nortc: