summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83795.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-10-28 20:31:45 +0200
committerJean Delvare <khali@endymion.delvare>2010-10-28 20:31:45 +0200
commit093d1a4794cc23dd221019eb1cdf42b16b48abcc (patch)
treec306a2d26ed2d90f3c53e26790aca495167a59a3 /drivers/hwmon/w83795.c
parent315bacfdbe5a77309c256b296f30bee13d59462b (diff)
hwmon: (w83795) Drop duplicate enum
Enum chips and chip_types are redundant, get rid of the former. Fix the detection code to properly identify the chip variant and name the client accordingly. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/w83795.c')
-rw-r--r--drivers/hwmon/w83795.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index 7b93ac296d0..d7e1d3693a2 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -38,8 +38,6 @@
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
-enum chips { w83795 };
-
static int reset;
module_param(reset, bool, 0);
@@ -1686,6 +1684,7 @@ static int w83795_detect(struct i2c_client *client,
u8 tmp, bank;
struct i2c_adapter *adapter = client->adapter;
unsigned short address = client->addr;
+ const char *chip_name;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
@@ -1718,18 +1717,21 @@ static int w83795_detect(struct i2c_client *client,
return -ENODEV;
}
-#if 0
- /* Check 795 chip type: 795G or 795ADG */
+ /* Check 795 chip type: 795G or 795ADG
+ Usually we don't write to chips during detection, but here we don't
+ quite have the choice; hopefully it's OK, we are about to return
+ success anyway */
+ if ((bank & 0x07) != 0)
+ i2c_smbus_write_byte_data(client, W83795_REG_BANKSEL,
+ bank & ~0x07);
if (W83795_REG_CONFIG_CONFIG48 &
- w83795_read(client, W83795_REG_CONFIG)) {
- data->chip_type = w83795adg;
+ i2c_smbus_read_byte_data(client, W83795_REG_CONFIG)) {
+ chip_name = "w83795adg";
} else {
- data->chip_type = w83795g;
+ chip_name = "w83795g";
}
-#endif
- /* Fill in the remaining client fields and put into the global list */
- strlcpy(info->type, "w83795", I2C_NAME_SIZE);
+ strlcpy(info->type, chip_name, I2C_NAME_SIZE);
return 0;
}
@@ -1750,20 +1752,13 @@ static int w83795_probe(struct i2c_client *client,
}
i2c_set_clientdata(client, data);
+ data->chip_type = id->driver_data;
data->bank = i2c_smbus_read_byte_data(client, W83795_REG_BANKSEL);
mutex_init(&data->update_lock);
/* Initialize the chip */
w83795_init_client(client);
- /* Check 795 chip type: 795G or 795ADG */
- if (W83795_REG_CONFIG_CONFIG48 &
- w83795_read(client, W83795_REG_CONFIG)) {
- data->chip_type = w83795adg;
- } else {
- data->chip_type = w83795g;
- }
-
data->has_in = w83795_read(client, W83795_REG_VOLT_CTRL1);
data->has_in |= w83795_read(client, W83795_REG_VOLT_CTRL2) << 8;
/* VSEN11-9 not for 795adg */
@@ -2097,7 +2092,8 @@ static int w83795_remove(struct i2c_client *client)
static const struct i2c_device_id w83795_id[] = {
- { "w83795", w83795 },
+ { "w83795g", w83795g },
+ { "w83795adg", w83795adg },
{ }
};
MODULE_DEVICE_TABLE(i2c, w83795_id);