diff options
Diffstat (limited to 'drivers/hwmon/max1619.c')
-rw-r--r-- | drivers/hwmon/max1619.c | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 7897754f3a5c..7fcf5ff89e7f 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -226,58 +226,34 @@ static const struct attribute_group max1619_group = { | |||
226 | */ | 226 | */ |
227 | 227 | ||
228 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 228 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
229 | static int max1619_detect(struct i2c_client *new_client, int kind, | 229 | static int max1619_detect(struct i2c_client *client, int kind, |
230 | struct i2c_board_info *info) | 230 | struct i2c_board_info *info) |
231 | { | 231 | { |
232 | struct i2c_adapter *adapter = new_client->adapter; | 232 | struct i2c_adapter *adapter = client->adapter; |
233 | u8 reg_config=0, reg_convrate=0, reg_status=0; | 233 | u8 reg_config, reg_convrate, reg_status, man_id, chip_id; |
234 | 234 | ||
235 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 235 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
236 | return -ENODEV; | 236 | return -ENODEV; |
237 | 237 | ||
238 | /* | 238 | /* detection */ |
239 | * Now we do the remaining detection. A negative kind means that | 239 | reg_config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG); |
240 | * the driver was loaded with no force parameter (default), so we | 240 | reg_convrate = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONVRATE); |
241 | * must both detect and identify the chip. A zero kind means that | 241 | reg_status = i2c_smbus_read_byte_data(client, MAX1619_REG_R_STATUS); |
242 | * the driver was loaded with the force parameter, the detection | 242 | if ((reg_config & 0x03) != 0x00 |
243 | * step shall be skipped. A positive kind means that the driver | 243 | || reg_convrate > 0x07 || (reg_status & 0x61) != 0x00) { |
244 | * was loaded with the force parameter and a given kind of chip is | 244 | dev_dbg(&adapter->dev, "MAX1619 detection failed at 0x%02x\n", |
245 | * requested, so both the detection and the identification steps | 245 | client->addr); |
246 | * are skipped. | 246 | return -ENODEV; |
247 | */ | ||
248 | if (kind < 0) { /* detection */ | ||
249 | reg_config = i2c_smbus_read_byte_data(new_client, | ||
250 | MAX1619_REG_R_CONFIG); | ||
251 | reg_convrate = i2c_smbus_read_byte_data(new_client, | ||
252 | MAX1619_REG_R_CONVRATE); | ||
253 | reg_status = i2c_smbus_read_byte_data(new_client, | ||
254 | MAX1619_REG_R_STATUS); | ||
255 | if ((reg_config & 0x03) != 0x00 | ||
256 | || reg_convrate > 0x07 || (reg_status & 0x61 ) !=0x00) { | ||
257 | dev_dbg(&adapter->dev, | ||
258 | "MAX1619 detection failed at 0x%02x.\n", | ||
259 | new_client->addr); | ||
260 | return -ENODEV; | ||
261 | } | ||
262 | } | 247 | } |
263 | 248 | ||
264 | if (kind <= 0) { /* identification */ | 249 | /* identification */ |
265 | u8 man_id, chip_id; | 250 | man_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_MAN_ID); |
266 | 251 | chip_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CHIP_ID); | |
267 | man_id = i2c_smbus_read_byte_data(new_client, | 252 | if (man_id != 0x4D || chip_id != 0x04) { |
268 | MAX1619_REG_R_MAN_ID); | 253 | dev_info(&adapter->dev, |
269 | chip_id = i2c_smbus_read_byte_data(new_client, | 254 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X).\n", |
270 | MAX1619_REG_R_CHIP_ID); | 255 | man_id, chip_id); |
271 | 256 | return -ENODEV; | |
272 | if ((man_id == 0x4D) && (chip_id == 0x04)) | ||
273 | kind = max1619; | ||
274 | |||
275 | if (kind <= 0) { /* identification failed */ | ||
276 | dev_info(&adapter->dev, | ||
277 | "Unsupported chip (man_id=0x%02X, " | ||
278 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
279 | return -ENODEV; | ||
280 | } | ||
281 | } | 257 | } |
282 | 258 | ||
283 | strlcpy(info->type, "max1619", I2C_NAME_SIZE); | 259 | strlcpy(info->type, "max1619", I2C_NAME_SIZE); |