+ rtc-rs5c313c-add-error-handling-to-avoid-hardware-hangup.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     rtc-rs5c313.c: add error handling to avoid hardware hangup
has been added to the -mm tree.  Its filename is
     rtc-rs5c313c-add-error-handling-to-avoid-hardware-hangup.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: rtc-rs5c313.c: add error handling to avoid hardware hangup
From: "kogiidena" <kogiidena@xxxxxxxxxxxxxxx>

Add error processing.  Hanging up by an infinite loop is evaded.

Signed-off-by: kogiidena <kogiidena@xxxxxxxxxxxxxxx>
Cc: Alessandro Zummo <a.zummo@xxxxxxxxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/rtc/rtc-rs5c313.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff -puN drivers/rtc/rtc-rs5c313.c~rtc-rs5c313c-add-error-handling-to-avoid-hardware-hangup drivers/rtc/rtc-rs5c313.c
--- a/drivers/rtc/rtc-rs5c313.c~rtc-rs5c313c-add-error-handling-to-avoid-hardware-hangup
+++ a/drivers/rtc/rtc-rs5c313.c
@@ -212,7 +212,9 @@ static inline void rs5c313_write_intintv
 static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	int data;
+	int cnt;
 
+	cnt = 0;
 	while (1) {
 		RS5C313_CEENABLE;	/* CE:H */
 
@@ -225,6 +227,10 @@ static int rs5c313_rtc_read_time(struct 
 		RS5C313_CEDISABLE;
 		ndelay(700);	/* CE:L */
 
+		if (cnt++ > 100) {
+			dev_err(dev, "%s: timeout error\n", __FUNCTION__);
+			return -EIO;
+		}
 	}
 
 	data = rs5c313_read_reg(RS5C313_ADDR_SEC);
@@ -266,7 +272,9 @@ static int rs5c313_rtc_read_time(struct 
 static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
 	int data;
+	int cnt;
 
+	cnt = 0;
 	/* busy check. */
 	while (1) {
 		RS5C313_CEENABLE;	/* CE:H */
@@ -279,6 +287,11 @@ static int rs5c313_rtc_set_time(struct d
 		RS5C313_MISCOP;
 		RS5C313_CEDISABLE;
 		ndelay(700);	/* CE:L */
+
+		if (cnt++ > 100) {
+			dev_err(dev, "%s: timeout error\n", __FUNCTION__);
+			return -EIO;
+		}
 	}
 
 	data = BIN2BCD(tm->tm_sec);
@@ -317,6 +330,7 @@ static int rs5c313_rtc_set_time(struct d
 static void rs5c313_check_xstp_bit(void)
 {
 	struct rtc_time tm;
+	int cnt;
 
 	RS5C313_CEENABLE;	/* CE:H */
 	if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) {
@@ -326,8 +340,11 @@ static void rs5c313_check_xstp_bit(void)
 		rs5c313_write_cntreg(0x07);
 
 		/* busy check. */
-		while (rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY)
+		for (cnt = 0; cnt < 100; cnt++) {
+			if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY))
+				break;
 			RS5C313_MISCOP;
+		}
 
 		memset(&tm, 0, sizeof(struct rtc_time));
 		tm.tm_mday 	= 1;
_

Patches currently in -mm which might be from kogiidena@xxxxxxxxxxxxxxx are

origin.patch
rtc-rs5c313c-error-and-warning-are-fixed.patch
rtc-rs5c313c-rtc_time-value-are-fixed.patch
rtc-rs5c313c-add-error-handling-to-avoid-hardware-hangup.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux