aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/thmc50.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-12-09 14:35:57 -0500
committerJean Delvare <khali@linux-fr.org>2009-12-09 14:35:57 -0500
commit52df6440a29123eed912183fe785bbe174ef14b9 (patch)
tree3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/thmc50.c
parenta1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (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/thmc50.c')
-rw-r--r--drivers/hwmon/thmc50.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c
index 7d97431e132f..1db9bc802f2b 100644
--- a/drivers/hwmon/thmc50.c
+++ b/drivers/hwmon/thmc50.c
@@ -289,7 +289,6 @@ static int thmc50_detect(struct i2c_client *client, int kind,
289 unsigned revision; 289 unsigned revision;
290 unsigned config; 290 unsigned config;
291 struct i2c_adapter *adapter = client->adapter; 291 struct i2c_adapter *adapter = client->adapter;
292 int err = 0;
293 const char *type_name; 292 const char *type_name;
294 293
295 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 294 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -301,31 +300,13 @@ static int thmc50_detect(struct i2c_client *client, int kind,
301 pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n", 300 pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n",
302 client->addr, i2c_adapter_id(client->adapter)); 301 client->addr, i2c_adapter_id(client->adapter));
303 302
304 /* Now, we do the remaining detection. */
305 company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID); 303 company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID);
306 revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE); 304 revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE);
307 config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); 305 config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
306 if (revision < 0xc0 || (config & 0x10))
307 return -ENODEV;
308 308
309 if (kind == 0) 309 if (company == 0x41) {
310 kind = thmc50;
311 else if (kind < 0) {
312 err = -ENODEV;
313 if (revision >= 0xc0 && ((config & 0x10) == 0)) {
314 if (company == 0x49) {
315 kind = thmc50;
316 err = 0;
317 } else if (company == 0x41) {
318 kind = adm1022;
319 err = 0;
320 }
321 }
322 }
323 if (err == -ENODEV) {
324 pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
325 return err;
326 }
327
328 if (kind == adm1022) {
329 int id = i2c_adapter_id(client->adapter); 310 int id = i2c_adapter_id(client->adapter);
330 int i; 311 int i;
331 312
@@ -340,9 +321,13 @@ static int thmc50_detect(struct i2c_client *client, int kind,
340 config); 321 config);
341 break; 322 break;
342 } 323 }
343 } else { 324 } else if (company == 0x49) {
344 type_name = "thmc50"; 325 type_name = "thmc50";
326 } else {
327 pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
328 return -ENODEV;
345 } 329 }
330
346 pr_debug("thmc50: Detected %s (version %x, revision %x)\n", 331 pr_debug("thmc50: Detected %s (version %x, revision %x)\n",
347 type_name, (revision >> 4) - 0xc, revision & 0xf); 332 type_name, (revision >> 4) - 0xc, revision & 0xf);
348 333