Skip to contentSkip to conversation

NUC900/rtc: change the waiting for device ready implement

PATCH New Wan ZongShun 1 participant 2 messages May 18, 2010 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NUC900/rtc: change the waiting for device ready implement

Dear Alessandro,

This patch is to change the waiting for device ready implement for winbond nuc900 platform.

Thanks!

---
 drivers/rtc/rtc-nuc900.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
drivers/rtc/rtc-nuc900.c +7 -8
index a351bd5..8684051 100644
@@ -85,22 +85,21 @@ static irqreturn_t nuc900_rtc_interrupt(int irq, void *_rtc)
 
 static int *check_rtc_access_enable(struct nuc900_rtc *nuc900_rtc)
 {
-	unsigned int i;
+	unsigned int i, timeout = 0x1000, val;
 	__raw_writel(INIRRESET, nuc900_rtc->rtc_reg + REG_RTC_INIR);
 
 	mdelay(10);
 
 	__raw_writel(AERPOWERON, nuc900_rtc->rtc_reg + REG_RTC_AER);
 
-	for (i = 0; i < 1000; i++) {
-		if (__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
-			return 0;
-	}
+	while (!(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
+								&& timeout--)
+		mdelay(1);
 
-	if ((__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB) == 0x0)
-		return ERR_PTR(-ENODEV);
+	if (timeout == 0x1000)
+		return ERR_PTR(-EPERM);
 
-	return ERR_PTR(-EPERM);
+	return 0;
 }
 
 static void nuc900_rtc_bcd2bin(unsigned int timereg,
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 NUC900/rtc: change the waiting for device ready implement

Dear sir,

Re-submitting the patch to fix careless bug.

---
 drivers/rtc/rtc-nuc900.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
drivers/rtc/rtc-nuc900.c +7 -8
index a351bd5..21d1330 100644
@@ -85,22 +85,21 @@ static irqreturn_t nuc900_rtc_interrupt(int irq, void *_rtc)
 
 static int *check_rtc_access_enable(struct nuc900_rtc *nuc900_rtc)
 {
-	unsigned int i;
+	unsigned int i, timeout = 0x1000;
 	__raw_writel(INIRRESET, nuc900_rtc->rtc_reg + REG_RTC_INIR);
 
 	mdelay(10);
 
 	__raw_writel(AERPOWERON, nuc900_rtc->rtc_reg + REG_RTC_AER);
 
-	for (i = 0; i < 1000; i++) {
-		if (__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
-			return 0;
-	}
+	while (!(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
+								&& timeout--)
+		mdelay(1);
 
-	if ((__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB) == 0x0)
-		return ERR_PTR(-ENODEV);
+	if (!timeout)
+		return ERR_PTR(-EPERM);
 
-	return ERR_PTR(-EPERM);
+	return 0;
 }
 
 static void nuc900_rtc_bcd2bin(unsigned int timereg,
Signature · 1 line
1.6.3.3