hwmon: w83627ehf updates
[pandora-kernel.git] / drivers / hwmon / thmc50.c
index 7d97431..7dfb4de 100644 (file)
@@ -35,8 +35,12 @@ MODULE_LICENSE("GPL");
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_2(thmc50, adm1022);
-I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs "
+enum chips { thmc50, adm1022 };
+
+static unsigned short adm1022_temp3[16];
+static unsigned int adm1022_temp3_num;
+module_param_array(adm1022_temp3, ushort, &adm1022_temp3_num, 0);
+MODULE_PARM_DESC(adm1022_temp3, "List of adapter,address pairs "
                        "to enable 3rd temperature (ADM1022 only)");
 
 /* Many THMC50 constants specified below */
@@ -80,7 +84,7 @@ struct thmc50_data {
        u8 alarms;
 };
 
-static int thmc50_detect(struct i2c_client *client, int kind,
+static int thmc50_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int thmc50_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
@@ -104,7 +108,7 @@ static struct i2c_driver thmc50_driver = {
        .remove = thmc50_remove,
        .id_table = thmc50_id,
        .detect = thmc50_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 static ssize_t show_analog_out(struct device *dev,
@@ -282,14 +286,13 @@ static const struct attribute_group temp3_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int thmc50_detect(struct i2c_client *client, int kind,
+static int thmc50_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        unsigned company;
        unsigned revision;
        unsigned config;
        struct i2c_adapter *adapter = client->adapter;
-       int err = 0;
        const char *type_name;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -301,31 +304,13 @@ static int thmc50_detect(struct i2c_client *client, int kind,
        pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n",
                 client->addr, i2c_adapter_id(client->adapter));
 
-       /* Now, we do the remaining detection. */
        company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID);
        revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE);
        config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
+       if (revision < 0xc0 || (config & 0x10))
+               return -ENODEV;
 
-       if (kind == 0)
-               kind = thmc50;
-       else if (kind < 0) {
-               err = -ENODEV;
-               if (revision >= 0xc0 && ((config & 0x10) == 0)) {
-                       if (company == 0x49) {
-                               kind = thmc50;
-                               err = 0;
-                       } else if (company == 0x41) {
-                               kind = adm1022;
-                               err = 0;
-                       }
-               }
-       }
-       if (err == -ENODEV) {
-               pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
-               return err;
-       }
-
-       if (kind == adm1022) {
+       if (company == 0x41) {
                int id = i2c_adapter_id(client->adapter);
                int i;
 
@@ -340,9 +325,13 @@ static int thmc50_detect(struct i2c_client *client, int kind,
                                                          config);
                                break;
                        }
-       } else {
+       } else if (company == 0x49) {
                type_name = "thmc50";
+       } else {
+               pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
+               return -ENODEV;
        }
+
        pr_debug("thmc50: Detected %s (version %x, revision %x)\n",
                 type_name, (revision >> 4) - 0xc, revision & 0xf);