From: r.marek@sh.cvut.cz (Rudolf Marek)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [Ticket #2078] sensor values are sometimes wrong
Date: Tue, 25 Oct 2005 22:49:27 +0000 [thread overview]
Message-ID: <435E9A4A.2040503@sh.cvut.cz> (raw)
In-Reply-To: <20051021083606.GB19748@westend.com>
> There are no related syslog messages and I'm not aware of any other
> application using the i2c bus. There's no TV card in this server, are
> there other likely candidates?
OK,
This ASB100 chip was reverse engineered it is very hard to support such chip. We can try last thing. Please apply patch from attachment to asb100.c
It should retry the reading when failed. I hope you know C, please fix the typos in code if any. If not just post the errors back to the list. I'm very busy nowdays so I'm
sorry I cant test it...
Please let it run with the patch for some time, ideally until you see strange values. Check the system log for details. It might happen that we wont see
any problems because this patch solved them :) In this case please change dev_dbg to dev_err and we will see.
I hope this helps,
regards
Rudolf
-------------- next part --------------
diff -Naur a/asb100.c b/asb100.c
--- a/asb100.c 2005-10-20 08:23:05.000000000 +0200
+++ b/asb100.c 2005-10-25 22:44:53.352492250 +0200
@@ -880,6 +880,54 @@
return 0;
}
+#define MAX_RETRIES 30
+static int do_read_8(struct i2c_client *client, u8 reg, u8 defval)
+{
+ int value, i;
+
+ /* 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++) {
+ value = i2c_smbus_read_byte_data(client, reg);
+ if (value >= 0) {
+ dev_dbg(&client->dev, "Read 0x%02x from register "
+ "0x%02x.\n", value, reg);
+ return value;
+ }
+ dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i);
+ msleep(i);
+ }
+
+ dev_err(&client->dev, "Couldn't read value from register 0x%02x. "
+ "Please report.\n", reg);
+ return defval;
+}
+
+static int do_read_16(struct i2c_client *client, u16 reg, u8 defval)
+{
+ int value, i;
+
+ /* 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++) {
+ value = i2c_smbus_read_word_data(client, reg);
+ if (value >= 0) {
+ dev_dbg(&client->dev, "Read 0x%02x from register "
+ "0x%02x.\n", value, reg);
+ return value;
+ }
+ dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i);
+ msleep(i);
+ }
+
+ dev_err(&client->dev, "Couldn't read value from register 0x%02x. "
+ "Please report.\n", reg);
+ return defval;
+}
+
+
/* The SMBus locks itself, usually, but nothing may access the chip between
bank switches. */
static int asb100_read_value(struct i2c_client *client, u16 reg)
@@ -896,7 +944,7 @@
i2c_smbus_write_byte_data(client, ASB100_REG_BANK, bank);
if (bank = 0 || bank > 2) {
- res = i2c_smbus_read_byte_data(client, reg & 0xff);
+ res = do_read_8(client, reg & 0xff,0x0);
} else {
/* switch to subclient */
cl = data->lm75[bank - 1];
@@ -904,17 +952,17 @@
/* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) {
case 0x50: /* TEMP */
- res = swab16(i2c_smbus_read_word_data (cl, 0));
+ res = swab16(do_read_16(cl, 0,0x0));
break;
case 0x52: /* CONFIG */
- res = i2c_smbus_read_byte_data(cl, 1);
+ res = do_read_8(cl, 1,0x0);
break;
case 0x53: /* HYST */
- res = swab16(i2c_smbus_read_word_data (cl, 2));
+ res = swab16(do_read_16(cl, 2,0x0));
break;
case 0x55: /* MAX */
default:
- res = swab16(i2c_smbus_read_word_data (cl, 3));
+ res = swab16(do_read_16 (cl, 3,0x0));
break;
}
}
prev parent reply other threads:[~2005-10-25 22:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-21 10:37 [lm-sensors] [Ticket #2078] sensor values are sometimes wrong Christian Hammers
2005-10-21 11:39 ` Grant Coady
2005-10-21 12:07 ` Christian Hammers
2005-10-23 22:40 ` Rudolf Marek
2005-10-24 10:11 ` Christian Hammers
2005-10-25 22:49 ` Rudolf Marek [this message]
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=435E9A4A.2040503@sh.cvut.cz \
--to=r.marek@sh.cvut.cz \
--cc=lm-sensors@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.