diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-09 14:35:57 -0500 |
commit | 52df6440a29123eed912183fe785bbe174ef14b9 (patch) | |
tree | 3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/w83793.c | |
parent | a1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (diff) |
hwmon: Clean up detect functions
As kind is now hard-coded to -1, there is room for code clean-ups.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Corentin Labbe <corentin.labbe@geomatys.fr>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Juerg Haefliger <juergh@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Acked-by: "Hans J. Koch" <hjk@linutronix.de>
Cc: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'drivers/hwmon/w83793.c')
-rw-r--r-- | drivers/hwmon/w83793.c | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 47dd398f7258..80a2191bf127 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c | |||
@@ -1164,7 +1164,7 @@ ERROR_SC_0: | |||
1164 | static int w83793_detect(struct i2c_client *client, int kind, | 1164 | static int w83793_detect(struct i2c_client *client, int kind, |
1165 | struct i2c_board_info *info) | 1165 | struct i2c_board_info *info) |
1166 | { | 1166 | { |
1167 | u8 tmp, bank; | 1167 | u8 tmp, bank, chip_id; |
1168 | struct i2c_adapter *adapter = client->adapter; | 1168 | struct i2c_adapter *adapter = client->adapter; |
1169 | unsigned short address = client->addr; | 1169 | unsigned short address = client->addr; |
1170 | 1170 | ||
@@ -1174,44 +1174,27 @@ static int w83793_detect(struct i2c_client *client, int kind, | |||
1174 | 1174 | ||
1175 | bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); | 1175 | bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); |
1176 | 1176 | ||
1177 | if (kind < 0) { | 1177 | tmp = bank & 0x80 ? 0x5c : 0xa3; |
1178 | tmp = bank & 0x80 ? 0x5c : 0xa3; | 1178 | /* Check Winbond vendor ID */ |
1179 | /* Check Winbond vendor ID */ | 1179 | if (tmp != i2c_smbus_read_byte_data(client, W83793_REG_VENDORID)) { |
1180 | if (tmp != i2c_smbus_read_byte_data(client, | 1180 | pr_debug("w83793: Detection failed at check vendor id\n"); |
1181 | W83793_REG_VENDORID)) { | 1181 | return -ENODEV; |
1182 | pr_debug("w83793: Detection failed at check " | ||
1183 | "vendor id\n"); | ||
1184 | return -ENODEV; | ||
1185 | } | ||
1186 | |||
1187 | /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR | ||
1188 | should match */ | ||
1189 | if ((bank & 0x07) == 0 | ||
1190 | && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != | ||
1191 | (address << 1)) { | ||
1192 | pr_debug("w83793: Detection failed at check " | ||
1193 | "i2c addr\n"); | ||
1194 | return -ENODEV; | ||
1195 | } | ||
1196 | |||
1197 | } | 1182 | } |
1198 | 1183 | ||
1199 | /* We have either had a force parameter, or we have already detected the | 1184 | /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR |
1200 | Winbond. Determine the chip type now */ | 1185 | should match */ |
1201 | 1186 | if ((bank & 0x07) == 0 | |
1202 | if (kind <= 0) { | 1187 | && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != |
1203 | if (0x7b == i2c_smbus_read_byte_data(client, | 1188 | (address << 1)) { |
1204 | W83793_REG_CHIPID)) { | 1189 | pr_debug("w83793: Detection failed at check i2c addr\n"); |
1205 | kind = w83793; | 1190 | return -ENODEV; |
1206 | } else { | ||
1207 | if (kind == 0) | ||
1208 | dev_warn(&adapter->dev, "w83793: Ignoring " | ||
1209 | "'force' parameter for unknown chip " | ||
1210 | "at address 0x%02x\n", address); | ||
1211 | return -ENODEV; | ||
1212 | } | ||
1213 | } | 1191 | } |
1214 | 1192 | ||
1193 | /* Determine the chip type now */ | ||
1194 | chip_id = i2c_smbus_read_byte_data(client, W83793_REG_CHIPID); | ||
1195 | if (chip_id != 0x7b) | ||
1196 | return -ENODEV; | ||
1197 | |||
1215 | strlcpy(info->type, "w83793", I2C_NAME_SIZE); | 1198 | strlcpy(info->type, "w83793", I2C_NAME_SIZE); |
1216 | 1199 | ||
1217 | return 0; | 1200 | return 0; |