All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH 5/21] polling loops: change exit condition to
Date: Sun, 04 Dec 2005 00:15:13 +0000	[thread overview]
Message-ID: <43923511.1040804@gmail.com> (raw)

HARDWARE MONITORING
P:	Jean Delvare
M:	khali@linux-fr.org

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
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
--- linux-2.6.15-rc4-orig/drivers/hwmon/hdaps.c	2005-12-03 15:22:32.000000000 +0100
+++ linux-2.6.15-rc4/drivers/hwmon/hdaps.c	2005-12-03 16:53:10.000000000 +0100
@@ -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 */
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
--- linux-2.6.15-rc4-orig/drivers/hwmon/w83l785ts.c	2005-12-03 15:22:32.000000000 +0100
+++ linux-2.6.15-rc4/drivers/hwmon/w83l785ts.c	2005-12-03 19:56:20.000000000 +0100
@@ -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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

             reply	other threads:[~2005-12-04  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-04  0:15 Marcin Slusarz [this message]
2005-12-10 17:55 ` [KJ] [PATCH 5/21] polling loops: change exit condition to Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43923511.1040804@gmail.com \
    --to=marcin.slusarz@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.