aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1029.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1029.c')
-rw-r--r--drivers/hwmon/adm1029.c55
1 files changed, 16 insertions, 39 deletions
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index e845b75ccee4..ef91e2a4a567 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -301,59 +301,36 @@ static int adm1029_detect(struct i2c_client *client, int kind,
301 struct i2c_board_info *info) 301 struct i2c_board_info *info)
302{ 302{
303 struct i2c_adapter *adapter = client->adapter; 303 struct i2c_adapter *adapter = client->adapter;
304 u8 man_id, chip_id, temp_devices_installed, nb_fan_support;
304 305
305 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 306 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
306 return -ENODEV; 307 return -ENODEV;
307 308
308 /* Now we do the detection and identification. A negative kind
309 * means that the driver was loaded with no force parameter
310 * (default), so we must both detect and identify the chip
311 * (actually there is only one possible kind of chip for now, adm1029).
312 * A zero kind means that the driver was loaded with the force
313 * parameter, the detection step shall be skipped. A positive kind
314 * means that the driver was loaded with the force parameter and a
315 * given kind of chip is requested, so both the detection and the
316 * identification steps are skipped. */
317
318 /* Default to an adm1029 if forced */
319 if (kind == 0)
320 kind = adm1029;
321
322 /* ADM1029 doesn't have CHIP ID, check just MAN ID 309 /* ADM1029 doesn't have CHIP ID, check just MAN ID
323 * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, 310 * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED,
324 * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values 311 * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values
325 * documented 312 * documented
326 */ 313 */
327 314
328 if (kind <= 0) { /* identification */ 315 man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID);
329 u8 man_id, chip_id, temp_devices_installed, nb_fan_support; 316 chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID);
330 317 temp_devices_installed = i2c_smbus_read_byte_data(client,
331 man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID);
332 chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID);
333 temp_devices_installed = i2c_smbus_read_byte_data(client,
334 ADM1029_REG_TEMP_DEVICES_INSTALLED); 318 ADM1029_REG_TEMP_DEVICES_INSTALLED);
335 nb_fan_support = i2c_smbus_read_byte_data(client, 319 nb_fan_support = i2c_smbus_read_byte_data(client,
336 ADM1029_REG_NB_FAN_SUPPORT); 320 ADM1029_REG_NB_FAN_SUPPORT);
337 /* 0x41 is Analog Devices */ 321 /* 0x41 is Analog Devices */
338 if (man_id == 0x41 && (temp_devices_installed & 0xf9) == 0x01 322 if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01
339 && nb_fan_support == 0x03) { 323 || nb_fan_support != 0x03)
340 if ((chip_id & 0xF0) == 0x00) { 324 return -ENODEV;
341 kind = adm1029;
342 } else {
343 /* There are no "official" CHIP ID, so actually
344 * we use Major/Minor revision for that */
345 printk(KERN_INFO
346 "adm1029: Unknown major revision %x, "
347 "please let us know\n", chip_id);
348 }
349 }
350 325
351 if (kind <= 0) { /* identification failed */ 326 if ((chip_id & 0xF0) != 0x00) {
352 pr_debug("adm1029: Unsupported chip (man_id=0x%02X, " 327 /* There are no "official" CHIP ID, so actually
353 "chip_id=0x%02X)\n", man_id, chip_id); 328 * we use Major/Minor revision for that */
354 return -ENODEV; 329 pr_info("adm1029: Unknown major revision %x, "
355 } 330 "please let us know\n", chip_id);
331 return -ENODEV;
356 } 332 }
333
357 strlcpy(info->type, "adm1029", I2C_NAME_SIZE); 334 strlcpy(info->type, "adm1029", I2C_NAME_SIZE);
358 335
359 return 0; 336 return 0;