hwmon: (tmp421) Restore missing inputs
[safe/jmp/linux-2.6] / drivers / hwmon / adt7462.c
index 66107b4..b8156b4 100644 (file)
@@ -32,9 +32,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(adt7462);
-
 /* ADT7462 registers */
 #define ADT7462_REG_DEVICE                     0x3D
 #define ADT7462_REG_VENDOR                     0x3E
@@ -97,7 +94,7 @@ I2C_CLIENT_INSMOD_1(adt7462);
 #define                ADT7462_PIN24_SHIFT             6
 #define                ADT7462_PIN26_VOLT_INPUT        0x08
 #define                ADT7462_PIN25_VOLT_INPUT        0x20
-#define                ADT7462_PIN28_SHIFT             6       /* cfg3 */
+#define                ADT7462_PIN28_SHIFT             4       /* cfg3 */
 #define                ADT7462_PIN28_VOLT              0x5
 
 #define ADT7462_REG_ALARM1                     0xB8
@@ -182,7 +179,7 @@ I2C_CLIENT_INSMOD_1(adt7462);
  *
  * Some, but not all, of these voltages have low/high limits.
  */
-#define ADT7462_VOLT_COUNT     12
+#define ADT7462_VOLT_COUNT     13
 
 #define ADT7462_VENDOR         0x41
 #define ADT7462_DEVICE         0x62
@@ -204,8 +201,6 @@ I2C_CLIENT_INSMOD_1(adt7462);
 #define MASK_AND_SHIFT(value, prefix)  \
        (((value) & prefix##_MASK) >> prefix##_SHIFT)
 
-#define ROUND_DIV(x, divisor)  (((x) + ((divisor) / 2)) / (divisor))
-
 struct adt7462_data {
        struct device           *hwmon_dev;
        struct attribute_group  attrs;
@@ -239,12 +234,12 @@ struct adt7462_data {
 
 static int adt7462_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adt7462_detect(struct i2c_client *client, int kind,
+static int adt7462_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adt7462_remove(struct i2c_client *client);
 
 static const struct i2c_device_id adt7462_id[] = {
-       { "adt7462", adt7462 },
+       { "adt7462", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adt7462_id);
@@ -258,7 +253,7 @@ static struct i2c_driver adt7462_driver = {
        .remove         = adt7462_remove,
        .id_table       = adt7462_id,
        .detect         = adt7462_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -840,7 +835,7 @@ static ssize_t set_temp_min(struct device *dev,
        if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
                return -EINVAL;
 
-       temp = ROUND_DIV(temp, 1000) + 64;
+       temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
        temp = SENSORS_LIMIT(temp, 0, 255);
 
        mutex_lock(&data->lock);
@@ -878,7 +873,7 @@ static ssize_t set_temp_max(struct device *dev,
        if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
                return -EINVAL;
 
-       temp = ROUND_DIV(temp, 1000) + 64;
+       temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
        temp = SENSORS_LIMIT(temp, 0, 255);
 
        mutex_lock(&data->lock);
@@ -943,7 +938,7 @@ static ssize_t set_volt_max(struct device *dev,
                return -EINVAL;
 
        temp *= 1000; /* convert mV to uV */
-       temp = ROUND_DIV(temp, x);
+       temp = DIV_ROUND_CLOSEST(temp, x);
        temp = SENSORS_LIMIT(temp, 0, 255);
 
        mutex_lock(&data->lock);
@@ -985,7 +980,7 @@ static ssize_t set_volt_min(struct device *dev,
                return -EINVAL;
 
        temp *= 1000; /* convert mV to uV */
-       temp = ROUND_DIV(temp, x);
+       temp = DIV_ROUND_CLOSEST(temp, x);
        temp = SENSORS_LIMIT(temp, 0, 255);
 
        mutex_lock(&data->lock);
@@ -1250,7 +1245,7 @@ static ssize_t set_pwm_hyst(struct device *dev,
        if (strict_strtol(buf, 10, &temp))
                return -EINVAL;
 
-       temp = ROUND_DIV(temp, 1000);
+       temp = DIV_ROUND_CLOSEST(temp, 1000);
        temp = SENSORS_LIMIT(temp, 0, 15);
 
        /* package things up */
@@ -1337,7 +1332,7 @@ static ssize_t set_pwm_tmin(struct device *dev,
        if (strict_strtol(buf, 10, &temp))
                return -EINVAL;
 
-       temp = ROUND_DIV(temp, 1000) + 64;
+       temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
        temp = SENSORS_LIMIT(temp, 0, 255);
 
        mutex_lock(&data->lock);
@@ -1904,31 +1899,26 @@ static struct attribute *adt7462_attr[] =
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adt7462_detect(struct i2c_client *client, int kind,
+static int adt7462_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
+       int vendor, device, revision;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -ENODEV;
 
-       if (kind <= 0) {
-               int vendor, device, revision;
-
-               vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR);
-               if (vendor != ADT7462_VENDOR)
-                       return -ENODEV;
+       vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR);
+       if (vendor != ADT7462_VENDOR)
+               return -ENODEV;
 
-               device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE);
-               if (device != ADT7462_DEVICE)
-                       return -ENODEV;
+       device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE);
+       if (device != ADT7462_DEVICE)
+               return -ENODEV;
 
-               revision = i2c_smbus_read_byte_data(client,
-                                                   ADT7462_REG_REVISION);
-               if (revision != ADT7462_REVISION)
-                       return -ENODEV;
-       } else
-               dev_dbg(&adapter->dev, "detection forced\n");
+       revision = i2c_smbus_read_byte_data(client, ADT7462_REG_REVISION);
+       if (revision != ADT7462_REVISION)
+               return -ENODEV;
 
        strlcpy(info->type, "adt7462", I2C_NAME_SIZE);