aboutsummaryrefslogtreecommitdiffstats
path: root/i2c
diff options
context:
space:
mode:
author <greg@echidna.(none)>2005-09-26 14:25:31 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-26 14:25:31 -0700
commit91a58b314302947ce21404c0c7e803661a0bf2db (patch)
tree3508ebb6d565a2b73224732a53ead7d02e6b7e45 /i2c
downloadpatches-91a58b314302947ce21404c0c7e803661a0bf2db.tar.gz
initial creation of the patch set, based on 2.6.14-rc2-git3
Diffstat (limited to 'i2c')
-rw-r--r--i2c/hwmon-adm9240-update-01.patch267
-rw-r--r--i2c/hwmon-adm9240-update-02.patch483
-rw-r--r--i2c/hwmon-via686a-save-memory.patch39
3 files changed, 789 insertions, 0 deletions
diff --git a/i2c/hwmon-adm9240-update-01.patch b/i2c/hwmon-adm9240-update-01.patch
new file mode 100644
index 0000000000000..8e83e8887cb27
--- /dev/null
+++ b/i2c/hwmon-adm9240-update-01.patch
@@ -0,0 +1,267 @@
+From grant_lkml@dodo.com.au Fri Sep 16 13:57:15 2005
+From: Grant Coady <grant_lkml@dodo.com.au>
+Cc: <khali@linux-fr.org>, Greg KH <gregkh@suse.de>
+Subject: hwmon: adm9240 driver update - cleanups
+Date: Sat, 17 Sep 2005 05:32:55 +1000
+Message-ID: <947mi1lbnr076k5mgac360btfco7uiumg2@4ax.com>
+
+
+hwmon: adm9240 update 1/2: cleanups:
+
+o remove i2c read/write wrapper interface as it does nothing,
+o change kmalloc + memset to kzalloc
+
+Signed-off-by: Grant Coady <gcoady@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/hwmon/adm9240.c | 92 ++++++++++++++++++++++--------------------------
+ 1 file changed, 44 insertions(+), 48 deletions(-)
+
+--- gregkh-2.6.orig/drivers/hwmon/adm9240.c 2005-09-12 23:05:04.000000000 -0700
++++ gregkh-2.6/drivers/hwmon/adm9240.c 2005-09-17 09:21:29.000000000 -0700
+@@ -170,17 +170,6 @@ struct adm9240_data {
+ u8 vrm; /* -- vrm set on startup, no accessor */
+ };
+
+-/* i2c byte read/write interface */
+-static int adm9240_read_value(struct i2c_client *client, u8 reg)
+-{
+- return i2c_smbus_read_byte_data(client, reg);
+-}
+-
+-static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value)
+-{
+- return i2c_smbus_write_byte_data(client, reg, value);
+-}
+-
+ /*** sysfs accessors ***/
+
+ /* temperature */
+@@ -207,7 +196,7 @@ static ssize_t set_##value(struct device
+ \
+ down(&data->update_lock); \
+ data->value = TEMP_TO_REG(temp); \
+- adm9240_write_value(client, reg, data->value); \
++ i2c_smbus_write_byte_data(client, reg, data->value); \
+ up(&data->update_lock); \
+ return count; \
+ }
+@@ -249,7 +238,8 @@ static ssize_t set_in_min(struct device
+
+ down(&data->update_lock);
+ data->in_min[nr] = IN_TO_REG(val, nr);
+- adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(nr),
++ data->in_min[nr]);
+ up(&data->update_lock);
+ return count;
+ }
+@@ -263,7 +253,8 @@ static ssize_t set_in_max(struct device
+
+ down(&data->update_lock);
+ data->in_max[nr] = IN_TO_REG(val, nr);
+- adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(nr),
++ data->in_max[nr]);
+ up(&data->update_lock);
+ return count;
+ }
+@@ -341,11 +332,11 @@ static void adm9240_write_fan_div(struct
+ {
+ u8 reg, old, shift = (nr + 2) * 2;
+
+- reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);
++ reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
+ old = (reg >> shift) & 3;
+ reg &= ~(3 << shift);
+ reg |= (fan_div << shift);
+- adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg);
+ dev_dbg(&client->dev, "fan%d clock divider changed from %u "
+ "to %u\n", nr + 1, 1 << old, 1 << fan_div);
+ }
+@@ -406,7 +397,7 @@ static ssize_t set_fan_min(struct device
+ data->fan_div[nr] = new_div;
+ adm9240_write_fan_div(client, nr, new_div);
+ }
+- adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr),
++ i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
+ data->fan_min[nr]);
+
+ up(&data->update_lock);
+@@ -479,7 +470,7 @@ static ssize_t set_aout(struct device *d
+
+ down(&data->update_lock);
+ data->aout = AOUT_TO_REG(val);
+- adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
+ up(&data->update_lock);
+ return count;
+ }
+@@ -492,7 +483,8 @@ static ssize_t chassis_clear(struct devi
+ unsigned long val = simple_strtol(buf, NULL, 10);
+
+ if (val == 1) {
+- adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80);
++ i2c_smbus_write_byte_data(client,
++ ADM9240_REG_CHASSIS_CLEAR, 0x80);
+ dev_dbg(&client->dev, "chassis intrusion latch cleared\n");
+ }
+ return count;
+@@ -513,11 +505,10 @@ static int adm9240_detect(struct i2c_ada
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+ goto exit;
+
+- if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) {
++ if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {
+ err = -ENOMEM;
+ goto exit;
+ }
+- memset(data, 0, sizeof(struct adm9240_data));
+
+ new_client = &data->client;
+ i2c_set_clientdata(new_client, data);
+@@ -533,7 +524,7 @@ static int adm9240_detect(struct i2c_ada
+ if (kind < 0) {
+
+ /* verify chip: reg address should match i2c address */
+- if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR)
++ if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR)
+ != address) {
+ dev_err(&adapter->dev, "detect fail: address match, "
+ "0x%02x\n", address);
+@@ -541,8 +532,8 @@ static int adm9240_detect(struct i2c_ada
+ }
+
+ /* check known chip manufacturer */
+- man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID);
+-
++ man_id = i2c_smbus_read_byte_data(new_client,
++ ADM9240_REG_MAN_ID);
+ if (man_id == 0x23) {
+ kind = adm9240;
+ } else if (man_id == 0xda) {
+@@ -556,7 +547,8 @@ static int adm9240_detect(struct i2c_ada
+ }
+
+ /* successful detect, print chip info */
+- die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV);
++ die_rev = i2c_smbus_read_byte_data(new_client,
++ ADM9240_REG_DIE_REV);
+ dev_info(&adapter->dev, "found %s revision %u\n",
+ man_id == 0x23 ? "ADM9240" :
+ man_id == 0xda ? "DS1780" : "LM81", die_rev);
+@@ -654,8 +646,8 @@ static int adm9240_detach_client(struct
+ static void adm9240_init_client(struct i2c_client *client)
+ {
+ struct adm9240_data *data = i2c_get_clientdata(client);
+- u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG);
+- u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3;
++ u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG);
++ u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3;
+
+ data->vrm = vid_which_vrm(); /* need this to report vid as mV */
+
+@@ -672,18 +664,22 @@ static void adm9240_init_client(struct i
+
+ for (i = 0; i < 6; i++)
+ {
+- adm9240_write_value(client,
++ i2c_smbus_write_byte_data(client,
+ ADM9240_REG_IN_MIN(i), 0);
+- adm9240_write_value(client,
++ i2c_smbus_write_byte_data(client,
+ ADM9240_REG_IN_MAX(i), 255);
+ }
+- adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255);
+- adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255);
+- adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127);
+- adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127);
++ i2c_smbus_write_byte_data(client,
++ ADM9240_REG_FAN_MIN(0), 255);
++ i2c_smbus_write_byte_data(client,
++ ADM9240_REG_FAN_MIN(1), 255);
++ i2c_smbus_write_byte_data(client,
++ ADM9240_REG_TEMP_HIGH, 127);
++ i2c_smbus_write_byte_data(client,
++ ADM9240_REG_TEMP_HYST, 127);
+
+ /* start measurement cycle */
+- adm9240_write_value(client, ADM9240_REG_CONFIG, 1);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1);
+
+ dev_info(&client->dev, "cold start: config was 0x%02x "
+ "mode %u\n", conf, mode);
+@@ -704,25 +700,25 @@ static struct adm9240_data *adm9240_upda
+
+ for (i = 0; i < 6; i++) /* read voltages */
+ {
+- data->in[i] = adm9240_read_value(client,
++ data->in[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_IN(i));
+ }
+- data->alarms = adm9240_read_value(client,
++ data->alarms = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_INT(0)) |
+- adm9240_read_value(client,
++ i2c_smbus_read_byte_data(client,
+ ADM9240_REG_INT(1)) << 8;
+
+ /* read temperature: assume temperature changes less than
+ * 0.5'C per two measurement cycles thus ignore possible
+ * but unlikely aliasing error on lsb reading. --Grant */
+- data->temp = ((adm9240_read_value(client,
++ data->temp = ((i2c_smbus_read_byte_data(client,
+ ADM9240_REG_TEMP) << 8) |
+- adm9240_read_value(client,
++ i2c_smbus_read_byte_data(client,
+ ADM9240_REG_TEMP_CONF)) / 128;
+
+ for (i = 0; i < 2; i++) /* read fans */
+ {
+- data->fan[i] = adm9240_read_value(client,
++ data->fan[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_FAN(i));
+
+ /* adjust fan clock divider on overflow */
+@@ -747,30 +743,30 @@ static struct adm9240_data *adm9240_upda
+
+ for (i = 0; i < 6; i++)
+ {
+- data->in_min[i] = adm9240_read_value(client,
++ data->in_min[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_IN_MIN(i));
+- data->in_max[i] = adm9240_read_value(client,
++ data->in_max[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_IN_MAX(i));
+ }
+ for (i = 0; i < 2; i++)
+ {
+- data->fan_min[i] = adm9240_read_value(client,
++ data->fan_min[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_FAN_MIN(i));
+ }
+- data->temp_high = adm9240_read_value(client,
++ data->temp_high = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_TEMP_HIGH);
+- data->temp_hyst = adm9240_read_value(client,
++ data->temp_hyst = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_TEMP_HYST);
+
+ /* read fan divs and 5-bit VID */
+- i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);
++ i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
+ data->fan_div[0] = (i >> 4) & 3;
+ data->fan_div[1] = (i >> 6) & 3;
+ data->vid = i & 0x0f;
+- data->vid |= (adm9240_read_value(client,
++ data->vid |= (i2c_smbus_read_byte_data(client,
+ ADM9240_REG_VID4) & 1) << 4;
+ /* read analog out */
+- data->aout = adm9240_read_value(client,
++ data->aout = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_ANALOG_OUT);
+
+ data->last_updated_config = jiffies;
diff --git a/i2c/hwmon-adm9240-update-02.patch b/i2c/hwmon-adm9240-update-02.patch
new file mode 100644
index 0000000000000..3f4d2b54c2a22
--- /dev/null
+++ b/i2c/hwmon-adm9240-update-02.patch
@@ -0,0 +1,483 @@
+From grant_lkml@dodo.com.au Fri Sep 16 13:57:16 2005
+From: Grant Coady <grant_lkml@dodo.com.au>
+Cc: <khali@linux-fr.org>, Greg KH <gregkh@suse.de>
+Subject: hwmon: adm9240 driver update - dynamic sysfs
+Date: Sat, 17 Sep 2005 05:32:57 +1000
+Message-ID: <p87mi1ddqd684ueg9p6a4mqhlmjelminl6@4ax.com>
+
+
+hwmon: adm9240 update 2/2: convert to use dynamic sysfs accessors
+
+This patch converts adm9240 to use Yani Ioannou's dynamic sysfs callbacks,
+reducing driver memory footprint from 16312 to 14104 bytes on 2.6.14-rc1,
+removing the old driver macro mess.
+
+Run tested on Intel SE440BX-2 mobo.
+
+Signed-off-by: Grant Coady <gcoady@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/hwmon/adm9240.c | 340 +++++++++++++++++++++++-------------------------
+ 1 file changed, 165 insertions(+), 175 deletions(-)
+
+--- gregkh-2.6.orig/drivers/hwmon/adm9240.c 2005-09-17 09:21:29.000000000 -0700
++++ gregkh-2.6/drivers/hwmon/adm9240.c 2005-09-17 09:21:30.000000000 -0700
+@@ -45,6 +45,7 @@
+ #include <linux/module.h>
+ #include <linux/slab.h>
+ #include <linux/i2c.h>
++#include <linux/hwmon-sysfs.h>
+ #include <linux/hwmon.h>
+ #include <linux/hwmon-vid.h>
+ #include <linux/err.h>
+@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm8
+ #define ADM9240_REG_INT(nr) (0x41 + (nr))
+ #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr))
+ #define ADM9240_REG_TEMP 0x27
+-#define ADM9240_REG_TEMP_HIGH 0x39
+-#define ADM9240_REG_TEMP_HYST 0x3a
++#define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */
+ #define ADM9240_REG_ANALOG_OUT 0x19
+ #define ADM9240_REG_CHASSIS_CLEAR 0x46
+ #define ADM9240_REG_VID_FAN_DIV 0x47
+@@ -162,8 +162,7 @@ struct adm9240_data {
+ u8 fan_min[2]; /* rw fan1_min */
+ u8 fan_div[2]; /* rw fan1_div, read-only accessor */
+ s16 temp; /* ro temp1_input, 9-bit sign-extended */
+- s8 temp_high; /* rw temp1_max */
+- s8 temp_hyst; /* rw temp1_max_hyst */
++ s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */
+ u16 alarms; /* ro alarms */
+ u8 aout; /* rw aout_output */
+ u8 vid; /* ro vid */
+@@ -173,157 +172,143 @@ struct adm9240_data {
+ /*** sysfs accessors ***/
+
+ /* temperature */
+-#define show_temp(value, scale) \
+-static ssize_t show_##value(struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+- struct adm9240_data *data = adm9240_update_device(dev); \
+- return sprintf(buf, "%d\n", data->value * scale); \
+-}
+-show_temp(temp_high, 1000);
+-show_temp(temp_hyst, 1000);
+-show_temp(temp, 500); /* 0.5'C per bit */
+-
+-#define set_temp(value, reg) \
+-static ssize_t set_##value(struct device *dev, \
+- struct device_attribute *attr, \
+- const char *buf, size_t count) \
+-{ \
+- struct i2c_client *client = to_i2c_client(dev); \
+- struct adm9240_data *data = adm9240_update_device(dev); \
+- long temp = simple_strtoul(buf, NULL, 10); \
+- \
+- down(&data->update_lock); \
+- data->value = TEMP_TO_REG(temp); \
+- i2c_smbus_write_byte_data(client, reg, data->value); \
+- up(&data->update_lock); \
+- return count; \
+-}
+-
+-set_temp(temp_high, ADM9240_REG_TEMP_HIGH);
+-set_temp(temp_hyst, ADM9240_REG_TEMP_HYST);
+-
+-static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
+- show_temp_high, set_temp_high);
+-static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
+- show_temp_hyst, set_temp_hyst);
++static ssize_t show_temp(struct device *dev, struct device_attribute *dummy,
++ char *buf)
++{
++ struct adm9240_data *data = adm9240_update_device(dev);
++ return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */
++}
++
++static ssize_t show_max(struct device *dev, struct device_attribute *devattr,
++ char *buf)
++{
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
++ struct adm9240_data *data = adm9240_update_device(dev);
++ return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000);
++}
++
++static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
++ const char *buf, size_t count)
++{
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
++ struct i2c_client *client = to_i2c_client(dev);
++ struct adm9240_data *data = i2c_get_clientdata(client);
++ long val = simple_strtol(buf, NULL, 10);
++
++ down(&data->update_lock);
++ data->temp_max[attr->index] = TEMP_TO_REG(val);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
++ data->temp_max[attr->index]);
++ up(&data->update_lock);
++ return count;
++}
++
+ static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
++static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
++ show_max, set_max, 0);
++static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
++ show_max, set_max, 1);
+
+ /* voltage */
+-static ssize_t show_in(struct device *dev, char *buf, int nr)
++static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
++ char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr));
++ return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index],
++ attr->index));
+ }
+
+-static ssize_t show_in_min(struct device *dev, char *buf, int nr)
++static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr,
++ char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr));
++ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index],
++ attr->index));
+ }
+
+-static ssize_t show_in_max(struct device *dev, char *buf, int nr)
++static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr,
++ char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr));
++ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index],
++ attr->index));
+ }
+
+-static ssize_t set_in_min(struct device *dev, const char *buf,
+- size_t count, int nr)
++static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr,
++ const char *buf, size_t count)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct i2c_client *client = to_i2c_client(dev);
+ struct adm9240_data *data = i2c_get_clientdata(client);
+ unsigned long val = simple_strtoul(buf, NULL, 10);
+
+ down(&data->update_lock);
+- data->in_min[nr] = IN_TO_REG(val, nr);
+- i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(nr),
+- data->in_min[nr]);
++ data->in_min[attr->index] = IN_TO_REG(val, attr->index);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
++ data->in_min[attr->index]);
+ up(&data->update_lock);
+ return count;
+ }
+
+-static ssize_t set_in_max(struct device *dev, const char *buf,
+- size_t count, int nr)
++static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
++ const char *buf, size_t count)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct i2c_client *client = to_i2c_client(dev);
+ struct adm9240_data *data = i2c_get_clientdata(client);
+ unsigned long val = simple_strtoul(buf, NULL, 10);
+
+ down(&data->update_lock);
+- data->in_max[nr] = IN_TO_REG(val, nr);
+- i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(nr),
+- data->in_max[nr]);
++ data->in_max[attr->index] = IN_TO_REG(val, attr->index);
++ i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
++ data->in_max[attr->index]);
+ up(&data->update_lock);
+ return count;
+ }
+
+-#define show_in_offset(offset) \
+-static ssize_t show_in##offset(struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+- return show_in(dev, buf, offset); \
+-} \
+-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \
+-static ssize_t show_in##offset##_min(struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+- return show_in_min(dev, buf, offset); \
+-} \
+-static ssize_t show_in##offset##_max(struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+- return show_in_max(dev, buf, offset); \
+-} \
+-static ssize_t \
+-set_in##offset##_min(struct device *dev, \
+- struct device_attribute *attr, const char *buf, \
+- size_t count) \
+-{ \
+- return set_in_min(dev, buf, count, offset); \
+-} \
+-static ssize_t \
+-set_in##offset##_max(struct device *dev, \
+- struct device_attribute *attr, const char *buf, \
+- size_t count) \
+-{ \
+- return set_in_max(dev, buf, count, offset); \
+-} \
+-static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
+- show_in##offset##_min, set_in##offset##_min); \
+-static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
+- show_in##offset##_max, set_in##offset##_max);
+-
+-show_in_offset(0);
+-show_in_offset(1);
+-show_in_offset(2);
+-show_in_offset(3);
+-show_in_offset(4);
+-show_in_offset(5);
++#define vin(nr) \
++static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \
++ show_in, NULL, nr); \
++static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \
++ show_in_min, set_in_min, nr); \
++static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \
++ show_in_max, set_in_max, nr);
++
++vin(0);
++vin(1);
++vin(2);
++vin(3);
++vin(4);
++vin(5);
+
+ /* fans */
+-static ssize_t show_fan(struct device *dev, char *buf, int nr)
++static ssize_t show_fan(struct device *dev,
++ struct device_attribute *devattr, char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
+- 1 << data->fan_div[nr]));
++ return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
++ 1 << data->fan_div[attr->index]));
+ }
+
+-static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
++static ssize_t show_fan_min(struct device *dev,
++ struct device_attribute *devattr, char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],
+- 1 << data->fan_div[nr]));
++ return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index],
++ 1 << data->fan_div[attr->index]));
+ }
+
+-static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
++static ssize_t show_fan_div(struct device *dev,
++ struct device_attribute *devattr, char *buf)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct adm9240_data *data = adm9240_update_device(dev);
+- return sprintf(buf, "%d\n", 1 << data->fan_div[nr]);
++ return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]);
+ }
+
+ /* write new fan div, callers must hold data->update_lock */
+@@ -352,12 +337,15 @@ static void adm9240_write_fan_div(struct
+ * - otherwise: select fan clock divider to suit fan speed low limit,
+ * measurement code may adjust registers to ensure fan speed reading
+ */
+-static ssize_t set_fan_min(struct device *dev, const char *buf,
+- size_t count, int nr)
++static ssize_t set_fan_min(struct device *dev,
++ struct device_attribute *devattr,
++ const char *buf, size_t count)
+ {
++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct i2c_client *client = to_i2c_client(dev);
+ struct adm9240_data *data = i2c_get_clientdata(client);
+ unsigned long val = simple_strtoul(buf, NULL, 10);
++ int nr = attr->index;
+ u8 new_div;
+
+ down(&data->update_lock);
+@@ -404,40 +392,16 @@ static ssize_t set_fan_min(struct device
+ return count;
+ }
+
+-#define show_fan_offset(offset) \
+-static ssize_t show_fan_##offset (struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+-return show_fan(dev, buf, offset - 1); \
+-} \
+-static ssize_t show_fan_##offset##_div (struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+-return show_fan_div(dev, buf, offset - 1); \
+-} \
+-static ssize_t show_fan_##offset##_min (struct device *dev, \
+- struct device_attribute *attr, \
+- char *buf) \
+-{ \
+-return show_fan_min(dev, buf, offset - 1); \
+-} \
+-static ssize_t set_fan_##offset##_min (struct device *dev, \
+- struct device_attribute *attr, \
+- const char *buf, size_t count) \
+-{ \
+-return set_fan_min(dev, buf, count, offset - 1); \
+-} \
+-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
+- show_fan_##offset, NULL); \
+-static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
+- show_fan_##offset##_div, NULL); \
+-static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
+- show_fan_##offset##_min, set_fan_##offset##_min);
++#define fan(nr) \
++static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \
++ show_fan, NULL, nr - 1); \
++static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \
++ show_fan_div, NULL, nr - 1); \
++static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \
++ show_fan_min, set_fan_min, nr - 1);
+
+-show_fan_offset(1);
+-show_fan_offset(2);
++fan(1);
++fan(2);
+
+ /* alarms */
+ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
+@@ -580,33 +544,59 @@ static int adm9240_detect(struct i2c_ada
+ goto exit_detach;
+ }
+
+- device_create_file(&new_client->dev, &dev_attr_in0_input);
+- device_create_file(&new_client->dev, &dev_attr_in0_min);
+- device_create_file(&new_client->dev, &dev_attr_in0_max);
+- device_create_file(&new_client->dev, &dev_attr_in1_input);
+- device_create_file(&new_client->dev, &dev_attr_in1_min);
+- device_create_file(&new_client->dev, &dev_attr_in1_max);
+- device_create_file(&new_client->dev, &dev_attr_in2_input);
+- device_create_file(&new_client->dev, &dev_attr_in2_min);
+- device_create_file(&new_client->dev, &dev_attr_in2_max);
+- device_create_file(&new_client->dev, &dev_attr_in3_input);
+- device_create_file(&new_client->dev, &dev_attr_in3_min);
+- device_create_file(&new_client->dev, &dev_attr_in3_max);
+- device_create_file(&new_client->dev, &dev_attr_in4_input);
+- device_create_file(&new_client->dev, &dev_attr_in4_min);
+- device_create_file(&new_client->dev, &dev_attr_in4_max);
+- device_create_file(&new_client->dev, &dev_attr_in5_input);
+- device_create_file(&new_client->dev, &dev_attr_in5_min);
+- device_create_file(&new_client->dev, &dev_attr_in5_max);
+- device_create_file(&new_client->dev, &dev_attr_temp1_max);
+- device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in0_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in0_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in0_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in1_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in1_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in1_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in2_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in2_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in2_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in3_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in3_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in3_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in4_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in4_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in4_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in5_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in5_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_in5_max.dev_attr);
+ device_create_file(&new_client->dev, &dev_attr_temp1_input);
+- device_create_file(&new_client->dev, &dev_attr_fan1_input);
+- device_create_file(&new_client->dev, &dev_attr_fan1_div);
+- device_create_file(&new_client->dev, &dev_attr_fan1_min);
+- device_create_file(&new_client->dev, &dev_attr_fan2_input);
+- device_create_file(&new_client->dev, &dev_attr_fan2_div);
+- device_create_file(&new_client->dev, &dev_attr_fan2_min);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_temp1_max.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_temp1_max_hyst.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan1_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan1_div.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan1_min.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan2_input.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan2_div.dev_attr);
++ device_create_file(&new_client->dev,
++ &sensor_dev_attr_fan2_min.dev_attr);
+ device_create_file(&new_client->dev, &dev_attr_alarms);
+ device_create_file(&new_client->dev, &dev_attr_aout_output);
+ device_create_file(&new_client->dev, &dev_attr_chassis_clear);
+@@ -674,9 +664,9 @@ static void adm9240_init_client(struct i
+ i2c_smbus_write_byte_data(client,
+ ADM9240_REG_FAN_MIN(1), 255);
+ i2c_smbus_write_byte_data(client,
+- ADM9240_REG_TEMP_HIGH, 127);
++ ADM9240_REG_TEMP_MAX(0), 127);
+ i2c_smbus_write_byte_data(client,
+- ADM9240_REG_TEMP_HYST, 127);
++ ADM9240_REG_TEMP_MAX(1), 127);
+
+ /* start measurement cycle */
+ i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1);
+@@ -753,10 +743,10 @@ static struct adm9240_data *adm9240_upda
+ data->fan_min[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_FAN_MIN(i));
+ }
+- data->temp_high = i2c_smbus_read_byte_data(client,
+- ADM9240_REG_TEMP_HIGH);
+- data->temp_hyst = i2c_smbus_read_byte_data(client,
+- ADM9240_REG_TEMP_HYST);
++ data->temp_max[0] = i2c_smbus_read_byte_data(client,
++ ADM9240_REG_TEMP_MAX(0));
++ data->temp_max[1] = i2c_smbus_read_byte_data(client,
++ ADM9240_REG_TEMP_MAX(1));
+
+ /* read fan divs and 5-bit VID */
+ i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
diff --git a/i2c/hwmon-via686a-save-memory.patch b/i2c/hwmon-via686a-save-memory.patch
new file mode 100644
index 0000000000000..9e83414631b9e
--- /dev/null
+++ b/i2c/hwmon-via686a-save-memory.patch
@@ -0,0 +1,39 @@
+From khali@linux-fr.org Sat Sep 10 14:14:18 2005
+Date: Sat, 10 Sep 2005 23:00:46 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Cc: Denis Vlasenko <vda@ilport.com.ua>
+Subject: hwmon: via686a: save 0.5k by long v[256] -> s16 v[256]
+Message-Id: <20050910230046.724a3132.khali@linux-fr.org>
+
+We can save 0.5kB of data in the via686a driver.
+
+From: Denis Vlasenko <vda@ilport.com.ua>
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/hwmon/via686a.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- gregkh-2.6.orig/drivers/hwmon/via686a.c 2005-09-12 23:05:04.000000000 -0700
++++ gregkh-2.6/drivers/hwmon/via686a.c 2005-09-17 09:21:32.000000000 -0700
+@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, in
+ but the function is very linear in the useful range (0-80 deg C), so
+ we'll just use linear interpolation for 10-bit readings.) So, tempLUT
+ is the temp at via register values 0-255: */
+-static const long tempLUT[] =
++static const s16 tempLUT[] =
+ { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
+ -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
+ -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
+@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val)
+ }
+
+ /* for 8-bit temperature hyst and over registers */
+-#define TEMP_FROM_REG(val) (tempLUT[(val)] * 100)
++#define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100)
+
+ /* for 10-bit temperature readings */
+ static inline long TEMP_FROM_REG10(u16 val)