From: greg@kroah.com (Greg KH)
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: [PATCH] More i2c driver changes for 2.5.69
Date: Thu, 19 May 2005 06:23:56 +0000 [thread overview]
Message-ID: <10525245943578@kroah.com> (raw)
In-Reply-To: <10525245942470@kroah.com>
In-Reply-To: <1048295086481@kroah.com>
ChangeSet 1.1083.2.3, 2003/05/09 14:54:04-07:00, warp@mercury.d2dc.net
[PATCH] I2C: Another it87 patch.
This is against my last.
While the old code most definitely did /something/ to the register for
setting the fan div, the 'what' is a more interesting question.
To be honest I could not figure out what it was trying to do, because
the way it was inserting values disagreed with not only the data sheet,
but how it parsed the very same register.
This corrects the issue, and allows one to properly control the divisor
on all 3 fans, including the (much more limited) 3rd fan.
drivers/i2c/chips/it87.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003
+++ b/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003
@@ -159,7 +159,14 @@
205-(val)*5)
#define ALARMS_FROM_REG(val) (val)
-#define DIV_TO_REG(val) ((val)=8?3:(val)=4?2:(val)=1?0:1)
+static int log2(int val)
+{
+ int answer = 0;
+ while ((val >>= 1))
+ answer++;
+ return answer;
+}
+#define DIV_TO_REG(val) log2(val)
#define DIV_FROM_REG(val) (1 << (val))
/* Initial limits. Use the config file to set better limits. */
@@ -520,10 +527,25 @@
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- int old = it87_read_value(client, IT87_REG_FAN_DIV);
- data->fan_div[nr] = DIV_TO_REG(val);
- old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
- it87_write_value(client, IT87_REG_FAN_DIV, old);
+ u8 old = it87_read_value(client, IT87_REG_FAN_DIV);
+
+ switch (nr) {
+ case 0:
+ case 1:
+ data->fan_div[nr] = DIV_TO_REG(val);
+ break;
+ case 2:
+ if (val < 8)
+ data->fan_div[nr] = 1;
+ else
+ data->fan_div[nr] = 3;
+ }
+ val = old & 0x100;
+ val |= (data->fan_div[0] & 0x07);
+ val |= (data->fan_div[1] & 0x07) << 3;
+ if (data->fan_div[2] = 3)
+ val |= 0x1 << 6;
+ it87_write_value(client, IT87_REG_FAN_DIV, val);
return count;
}
@@ -961,7 +983,7 @@
i = it87_read_value(client, IT87_REG_FAN_DIV);
data->fan_div[0] = i & 0x07;
data->fan_div[1] = (i >> 3) & 0x07;
- data->fan_div[2] = 1;
+ data->fan_div[2] = (i & 0x40) ? 3 : 1;
data->alarms it87_read_value(client, IT87_REG_ALARM1) |
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] More i2c driver changes for 2.5.69
Date: Fri, 9 May 2003 16:56:34 -0700 [thread overview]
Message-ID: <10525245943578@kroah.com> (raw)
In-Reply-To: <10525245942470@kroah.com>
ChangeSet 1.1083.2.3, 2003/05/09 14:54:04-07:00, warp@mercury.d2dc.net
[PATCH] I2C: Another it87 patch.
This is against my last.
While the old code most definitely did /something/ to the register for
setting the fan div, the 'what' is a more interesting question.
To be honest I could not figure out what it was trying to do, because
the way it was inserting values disagreed with not only the data sheet,
but how it parsed the very same register.
This corrects the issue, and allows one to properly control the divisor
on all 3 fans, including the (much more limited) 3rd fan.
drivers/i2c/chips/it87.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003
+++ b/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003
@@ -159,7 +159,14 @@
205-(val)*5)
#define ALARMS_FROM_REG(val) (val)
-#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
+static int log2(int val)
+{
+ int answer = 0;
+ while ((val >>= 1))
+ answer++;
+ return answer;
+}
+#define DIV_TO_REG(val) log2(val)
#define DIV_FROM_REG(val) (1 << (val))
/* Initial limits. Use the config file to set better limits. */
@@ -520,10 +527,25 @@
struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- int old = it87_read_value(client, IT87_REG_FAN_DIV);
- data->fan_div[nr] = DIV_TO_REG(val);
- old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
- it87_write_value(client, IT87_REG_FAN_DIV, old);
+ u8 old = it87_read_value(client, IT87_REG_FAN_DIV);
+
+ switch (nr) {
+ case 0:
+ case 1:
+ data->fan_div[nr] = DIV_TO_REG(val);
+ break;
+ case 2:
+ if (val < 8)
+ data->fan_div[nr] = 1;
+ else
+ data->fan_div[nr] = 3;
+ }
+ val = old & 0x100;
+ val |= (data->fan_div[0] & 0x07);
+ val |= (data->fan_div[1] & 0x07) << 3;
+ if (data->fan_div[2] == 3)
+ val |= 0x1 << 6;
+ it87_write_value(client, IT87_REG_FAN_DIV, val);
return count;
}
@@ -961,7 +983,7 @@
i = it87_read_value(client, IT87_REG_FAN_DIV);
data->fan_div[0] = i & 0x07;
data->fan_div[1] = (i >> 3) & 0x07;
- data->fan_div[2] = 1;
+ data->fan_div[2] = (i & 0x40) ? 3 : 1;
data->alarms =
it87_read_value(client, IT87_REG_ALARM1) |
next prev parent reply other threads:[~2005-05-19 6:23 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-09 23:55 [BK PATCH] More i2c driver changes for 2.5.69 Greg KH
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` [PATCH] " Greg KH
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` Greg KH [this message]
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-05-09 23:56 ` Greg KH
2005-05-19 6:23 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2003-06-11 20:35 [BK PATCH] More i2c driver changes for 2.5.70 Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` [PATCH] " Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-11 20:36 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-06-12 2:40 ` Philip Pokorny
2005-05-19 6:23 ` Philip Pokorny
2003-04-03 0:14 [BK PATCH] More i2c driver changes for 2.5.66 Greg KH
2003-04-03 0:15 ` [PATCH] " Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 0:15 ` Greg KH
2003-04-03 6:21 ` Albert Cranford
2005-05-19 6:23 ` Albert Cranford
2003-04-03 6:33 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-04-03 13:06 ` Albert Cranford
2005-05-19 6:23 ` Albert Cranford
2003-04-03 16:37 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 [BK PATCH] More i2c driver changes for 2.5.65 Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` [PATCH] " Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-22 1:04 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-25 9:35 ` Pavel Machek
2005-05-19 6:23 ` Pavel Machek
2003-03-25 1:29 ` Greg KH
2005-05-19 6:23 ` Greg KH
2003-03-25 2:04 ` Dave Jones
2005-05-19 6:23 ` Dave Jones
2003-03-25 3:34 ` Greg KH
2005-05-19 6:23 ` Greg KH
2005-05-19 6:23 ` [PATCH] More i2c driver changes for 2.5.66 Greg KH
2005-05-19 6:23 ` Albert Cranford
2005-05-19 6:23 ` Mark M. Hoffman
2005-05-19 6:23 ` [PATCH] More i2c driver changes for 2.5.69 Philip Pokorny
2003-03-22 2:33 ` [PATCH] More i2c driver changes for 2.5.65 Petr Vandrovec
2005-05-19 6:23 ` Petr Vandrovec
2003-03-23 8:49 ` Greg KH
2005-05-19 6:23 ` Greg KH
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=10525245943578@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/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.