Skip to contentSkip to conversation

polling loops: change exit condition to

PATCH In review Marcin Slusarz 2 participants 2 messages Dec 4, 2005 – Dec 10, 2005

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

PATCH 5/21 polling loops: change exit condition to

HARDWARE MONITORING
P: Jean Delvare
M: [email protected]

drivers/hwmon/hdaps.c +4 -2
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/hwmon/hdaps.c linux-2.6.15-rc4/drivers/hwmon/hdaps.c
@@ -211,7 +211,8 @@ static int hdaps_read_pair(unsigned int 
  */
 static int hdaps_device_init(void)
 {
-	int total, ret = -ENXIO;
+	int ret = -ENXIO;
+	unsigned long end_time;
 
 	down(&hdaps_sem);
 
@@ -265,7 +266,8 @@ static int hdaps_device_init(void)
 		goto out;
 
 	/* we have done our dance, now let's wait for the applause */
-	for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
+	end_time = jiffies + msecs_to_jiffies(INIT_TIMEOUT_MSECS);
+	while (time_before(jiffies, end_time)) {
 		int x, y;
 
 		/* a read of the device helps push it into action */
drivers/hwmon/w83l785ts.c +6 -4
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/hwmon/w83l785ts.c linux-2.6.15-rc4/drivers/hwmon/w83l785ts.c
@@ -40,8 +40,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
 
-/* How many retries on register read error */
-#define MAX_RETRIES	5
+#define MAX_TIMEOUT	15
 
 /*
  * Address to scan
@@ -273,12 +272,14 @@ static int w83l785ts_detach_client(struc
 
 static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval)
 {
-	int value, i;
+	int value, i = 1;
+	unsigned long end_time;
 
 	/* Frequent read errors have been reported on Asus boards, so we
 	 * retry on read errors. If it still fails (unlikely), return the
 	 * default value requested by the caller. */
-	for (i = 1; i <= MAX_RETRIES; i++) {
+	end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT);
+	while (time_before_eq(jiffies, end_time)) {
 		value = i2c_smbus_read_byte_data(client, reg);
 		if (value >= 0) {
 			dev_dbg(&client->dev, "Read 0x%02x from register "
@@ -287,6 +288,7 @@ static u8 w83l785ts_read_value(struct i2
 		}
 		dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i);
 		msleep(i);
+		++i;
 	}
 
 	dev_err(&client->dev, "Couldn't read value from register 0x%02x. "

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

drivers/hwmon/w83l785ts.c line 43

Quoted 5 lines · Marcin Slusarz
drivers/hwmon/w83l785ts.c +1 -2
-/* How many retries on register read error */
-#define MAX_RETRIES	5
+#define MAX_TIMEOUT	15

This is used only once too.

Quoted 12 lines

static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval) {

drivers/hwmon/w83l785ts.c +2 -1
-	int value, i;
+	int value, i = 1;
+	unsigned long end_time;

/* Frequent read errors have been reported on Asus boards, so we
* retry on read errors. If it still fails (unlikely), return the
* default value requested by the caller. */

drivers/hwmon/w83l785ts.c +2 -1
-	for (i = 1; i <= MAX_RETRIES; i++) {
+	end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT);
+	while (time_before_eq(jiffies, end_time)) {
Quoted 3 lines
		value = i2c_smbus_read_byte_data(client, reg);
		if (value >= 0) {
			dev_dbg(&client->dev, "Read 0x%02x from register "

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors