This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / i2c / chips / lm78.c
index a145346..b3cab5f 100644 (file)
 #include <asm/io.h>
 
 /* Addresses to scan */
-static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
-                                       0x25, 0x26, 0x27, 0x28, 0x29,
-                                       0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
-                                       0x2f, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x20, 0x2f, I2C_CLIENT_END };
 static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
 SENSORS_INSMOD_3(lm78, lm78j, lm79);
@@ -230,29 +229,29 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
 static ssize_t                                                 \
        show_in##offset (struct device *dev, char *buf)         \
 {                                                              \
-       return show_in(dev, buf, offset);                       \
+       return show_in(dev, buf, 0x##offset);                   \
 }                                                              \
 static DEVICE_ATTR(in##offset##_input, S_IRUGO,                \
                show_in##offset, NULL);                         \
 static ssize_t                                                 \
        show_in##offset##_min (struct device *dev, char *buf)   \
 {                                                              \
-       return show_in_min(dev, buf, offset);                   \
+       return show_in_min(dev, buf, 0x##offset);               \
 }                                                              \
 static ssize_t                                                 \
        show_in##offset##_max (struct device *dev, char *buf)   \
 {                                                              \
-       return show_in_max(dev, buf, offset);                   \
+       return show_in_max(dev, buf, 0x##offset);               \
 }                                                              \
 static ssize_t set_in##offset##_min (struct device *dev,       \
                const char *buf, size_t count)                  \
 {                                                              \
-       return set_in_min(dev, buf, count, offset);             \
+       return set_in_min(dev, buf, count, 0x##offset);         \
 }                                                              \
 static ssize_t set_in##offset##_max (struct device *dev,       \
                const char *buf, size_t count)                  \
 {                                                              \
-       return set_in_max(dev, buf, count, offset);             \
+       return set_in_max(dev, buf, count, 0x##offset);         \
 }                                                              \
 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR,                \
                show_in##offset##_min, set_in##offset##_min);   \
@@ -376,20 +375,20 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
 #define show_fan_offset(offset)                                                \
 static ssize_t show_fan_##offset (struct device *dev, char *buf)       \
 {                                                                      \
-       return show_fan(dev, buf, offset - 1);                          \
+       return show_fan(dev, buf, 0x##offset - 1);                      \
 }                                                                      \
 static ssize_t show_fan_##offset##_min (struct device *dev, char *buf)  \
 {                                                                      \
-       return show_fan_min(dev, buf, offset - 1);                      \
+       return show_fan_min(dev, buf, 0x##offset - 1);                  \
 }                                                                      \
 static ssize_t show_fan_##offset##_div (struct device *dev, char *buf)  \
 {                                                                      \
-       return show_fan_div(dev, buf, offset - 1);                      \
+       return show_fan_div(dev, buf, 0x##offset - 1);                  \
 }                                                                      \
 static ssize_t set_fan_##offset##_min (struct device *dev,             \
                const char *buf, size_t count)                          \
 {                                                                      \
-       return set_fan_min(dev, buf, count, offset - 1);                \
+       return set_fan_min(dev, buf, count, 0x##offset - 1);            \
 }                                                                      \
 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,               \
@@ -693,12 +692,26 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
 /* Called when we have found a new LM78. It should set limits, etc. */
 static void lm78_init_client(struct i2c_client *client)
 {
-       u8 config = lm78_read_value(client, LM78_REG_CONFIG);
+       struct lm78_data *data = i2c_get_clientdata(client);
+       int vid;
+
+       /* Reset all except Watchdog values and last conversion values
+          This sets fan-divs to 2, among others */
+       lm78_write_value(client, LM78_REG_CONFIG, 0x80);
+
+       vid = lm78_read_value(client, LM78_REG_VID_FANDIV) & 0x0f;
+       if (data->type == lm79)
+               vid |=
+                   (lm78_read_value(client, LM78_REG_CHIPID) & 0x01) << 4;
+       else
+               vid |= 0x10;
+       vid = VID_FROM_REG(vid);
 
        /* Start monitoring */
-       if (!(config & 0x01))
-               lm78_write_value(client, LM78_REG_CONFIG,
-                                (config & 0xf7) | 0x01);
+       lm78_write_value(client, LM78_REG_CONFIG,
+                        (lm78_read_value(client, LM78_REG_CONFIG) & 0xf7)
+                        | 0x01);
+
 }
 
 static struct lm78_data *lm78_update_device(struct device *dev)