diff options
Diffstat (limited to 'drivers/hwmon/adm1029.c')
-rw-r--r-- | drivers/hwmon/adm1029.c | 71 |
1 files changed, 21 insertions, 50 deletions
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c index 36718150b475..0b8a3b145bd2 100644 --- a/drivers/hwmon/adm1029.c +++ b/drivers/hwmon/adm1029.c | |||
@@ -44,12 +44,6 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * Insmod parameters | ||
48 | */ | ||
49 | |||
50 | I2C_CLIENT_INSMOD_1(adm1029); | ||
51 | |||
52 | /* | ||
53 | * The ADM1029 registers | 47 | * The ADM1029 registers |
54 | * Manufacturer ID is 0x41 for Analog Devices | 48 | * Manufacturer ID is 0x41 for Analog Devices |
55 | */ | 49 | */ |
@@ -117,7 +111,7 @@ static const u8 ADM1029_REG_FAN_DIV[] = { | |||
117 | 111 | ||
118 | static int adm1029_probe(struct i2c_client *client, | 112 | static int adm1029_probe(struct i2c_client *client, |
119 | const struct i2c_device_id *id); | 113 | const struct i2c_device_id *id); |
120 | static int adm1029_detect(struct i2c_client *client, int kind, | 114 | static int adm1029_detect(struct i2c_client *client, |
121 | struct i2c_board_info *info); | 115 | struct i2c_board_info *info); |
122 | static int adm1029_remove(struct i2c_client *client); | 116 | static int adm1029_remove(struct i2c_client *client); |
123 | static struct adm1029_data *adm1029_update_device(struct device *dev); | 117 | static struct adm1029_data *adm1029_update_device(struct device *dev); |
@@ -128,7 +122,7 @@ static int adm1029_init_client(struct i2c_client *client); | |||
128 | */ | 122 | */ |
129 | 123 | ||
130 | static const struct i2c_device_id adm1029_id[] = { | 124 | static const struct i2c_device_id adm1029_id[] = { |
131 | { "adm1029", adm1029 }, | 125 | { "adm1029", 0 }, |
132 | { } | 126 | { } |
133 | }; | 127 | }; |
134 | MODULE_DEVICE_TABLE(i2c, adm1029_id); | 128 | MODULE_DEVICE_TABLE(i2c, adm1029_id); |
@@ -142,7 +136,7 @@ static struct i2c_driver adm1029_driver = { | |||
142 | .remove = adm1029_remove, | 136 | .remove = adm1029_remove, |
143 | .id_table = adm1029_id, | 137 | .id_table = adm1029_id, |
144 | .detect = adm1029_detect, | 138 | .detect = adm1029_detect, |
145 | .address_data = &addr_data, | 139 | .address_list = normal_i2c, |
146 | }; | 140 | }; |
147 | 141 | ||
148 | /* | 142 | /* |
@@ -297,63 +291,40 @@ static const struct attribute_group adm1029_group = { | |||
297 | */ | 291 | */ |
298 | 292 | ||
299 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 293 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
300 | static int adm1029_detect(struct i2c_client *client, int kind, | 294 | static int adm1029_detect(struct i2c_client *client, |
301 | struct i2c_board_info *info) | 295 | struct i2c_board_info *info) |
302 | { | 296 | { |
303 | struct i2c_adapter *adapter = client->adapter; | 297 | struct i2c_adapter *adapter = client->adapter; |
298 | u8 man_id, chip_id, temp_devices_installed, nb_fan_support; | ||
304 | 299 | ||
305 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 300 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
306 | return -ENODEV; | 301 | return -ENODEV; |
307 | 302 | ||
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 | 303 | /* ADM1029 doesn't have CHIP ID, check just MAN ID |
323 | * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, | 304 | * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, |
324 | * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values | 305 | * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values |
325 | * documented | 306 | * documented |
326 | */ | 307 | */ |
327 | 308 | ||
328 | if (kind <= 0) { /* identification */ | 309 | man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID); |
329 | u8 man_id, chip_id, temp_devices_installed, nb_fan_support; | 310 | chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID); |
330 | 311 | 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); | 312 | ADM1029_REG_TEMP_DEVICES_INSTALLED); |
335 | nb_fan_support = i2c_smbus_read_byte_data(client, | 313 | nb_fan_support = i2c_smbus_read_byte_data(client, |
336 | ADM1029_REG_NB_FAN_SUPPORT); | 314 | ADM1029_REG_NB_FAN_SUPPORT); |
337 | /* 0x41 is Analog Devices */ | 315 | /* 0x41 is Analog Devices */ |
338 | if (man_id == 0x41 && (temp_devices_installed & 0xf9) == 0x01 | 316 | if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 |
339 | && nb_fan_support == 0x03) { | 317 | || nb_fan_support != 0x03) |
340 | if ((chip_id & 0xF0) == 0x00) { | 318 | 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 | 319 | ||
351 | if (kind <= 0) { /* identification failed */ | 320 | if ((chip_id & 0xF0) != 0x00) { |
352 | pr_debug("adm1029: Unsupported chip (man_id=0x%02X, " | 321 | /* There are no "official" CHIP ID, so actually |
353 | "chip_id=0x%02X)\n", man_id, chip_id); | 322 | * we use Major/Minor revision for that */ |
354 | return -ENODEV; | 323 | pr_info("adm1029: Unknown major revision %x, " |
355 | } | 324 | "please let us know\n", chip_id); |
325 | return -ENODEV; | ||
356 | } | 326 | } |
327 | |||
357 | strlcpy(info->type, "adm1029", I2C_NAME_SIZE); | 328 | strlcpy(info->type, "adm1029", I2C_NAME_SIZE); |
358 | 329 | ||
359 | return 0; | 330 | return 0; |
@@ -432,7 +403,7 @@ static int adm1029_remove(struct i2c_client *client) | |||
432 | } | 403 | } |
433 | 404 | ||
434 | /* | 405 | /* |
435 | function that update the status of the chips (temperature for exemple) | 406 | function that update the status of the chips (temperature for example) |
436 | */ | 407 | */ |
437 | static struct adm1029_data *adm1029_update_device(struct device *dev) | 408 | static struct adm1029_data *adm1029_update_device(struct device *dev) |
438 | { | 409 | { |