Skip to contentSkip to conversation

RTC: s3c: Initialize driver data before using it

PATCH In review Maurus Cuelenaere 2 participants 5 messages May 27, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 RTC: s3c: Initialize driver data before using it

In reply to a message not in the archive

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.

---
 drivers/rtc/rtc-s3c.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-s3c.c +3 -2
index e5972b2..6adebf3 100644
@@ -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:
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/2 RTC: s3c: Initialize s3c_rtc_cpu_type before using it

In reply to a message not in the archive

Make sure s3c_rtc_cpu_type is initialised _before_ it's used in an if() check.

This was probably caused due to a merge mistake.

---
 drivers/rtc/rtc-s3c.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-s3c.c +2 -2
index 6adebf3..70b68d3 100644
@@ -508,13 +508,13 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
 		goto err_nortc;
 	}
 
+	s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
+
 	if (s3c_rtc_cpu_type == TYPE_S3C64XX)
 		rtc->max_user_freq = 32768;
 	else
 		rtc->max_user_freq = 128;
 
-	s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
-
 	platform_set_drvdata(pdev, rtc);
 
 	s3c_rtc_setfreq(&pdev->dev, 1);
Signature · 1 line
1.7.1
#2 lore raw
In reply to Maurus Cuelenaere
Quoted 22 lines · On Thu, 27 May 2010 23:28:45 +0200 Maurus Cuelenaere <[email protected]>…

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.

---
 drivers/rtc/rtc-s3c.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-s3c.c +0 -2
index e5972b2..6adebf3 100644
@@ -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 */

drivers/rtc/rtc-s3c.c static int __devinit s3c_rtc_probe(struct platform_device *pdev) · line 524

Quoted 9 lines
drivers/rtc/rtc-s3c.c +3 -0
@@ -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.

#4 lore raw

Re: [PATCH 2/2] RTC: s3c: Initialize s3c_rtc_cpu_type before using it

In reply to Maurus Cuelenaere
Quoted 3 lines · On Thu, 27 May 2010 23:28:47 +0200 Maurus Cuelenaere <[email protected]>…

Make sure s3c_rtc_cpu_type is initialised _before_ it's used in an if() check.

This was probably caused due to a merge mistake.

Nope, I went back to your original email:

@@ -471,7 +509,12 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)

                goto err_nortc;
        }

- rtc->max_user_freq = 128;
+ if (s3c_rtc_cpu_type == TYPE_S3C64XX)
+ rtc->max_user_freq = 32768;
+ else
+ rtc->max_user_freq = 128;
+
+ s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;

#5 lore raw

Re: [PATCH 2/2] RTC: s3c: Initialize s3c_rtc_cpu_type before using it

Op 27-05-10 23:52, Andrew Morton schreef:

Quoted 13 lines
Quoted 4 lines · On Thu, 27 May 2010 23:28:47 +0200 Maurus Cuelenaere <[email protected]>…

Make sure s3c_rtc_cpu_type is initialised _before_ it's used in an if() check.

This was probably caused due to a merge mistake.

Nope, I went back to your original email:

(quoted diff) +0 -0
@@ -471,7 +509,12 @@ static int __devinit s3c_rtc_probe(struct
 platform_device *pdev)
                goto err_nortc;

Review static int __devinit s3c_rtc_probe(struct · line 519

Quoted 10 lines
(quoted diff) +6 -1
        }
 
-       rtc->max_user_freq = 128;
+       if (s3c_rtc_cpu_type == TYPE_S3C64XX)
+               rtc->max_user_freq = 32768;
+       else
+               rtc->max_user_freq = 128;
+
+       s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
 

Hmm, odd. Ok, I apologize for this (obvious) mistake then.

Signature · 1 line
Maurus Cuelenaere