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/lm75.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/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 55bd87c15c9a..e392548cccb8 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -239,6 +239,7 @@ static int lm75_detect(struct i2c_client *new_client, int kind, | |||
239 | { | 239 | { |
240 | struct i2c_adapter *adapter = new_client->adapter; | 240 | struct i2c_adapter *adapter = new_client->adapter; |
241 | int i; | 241 | int i; |
242 | int cur, conf, hyst, os; | ||
242 | 243 | ||
243 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 244 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
244 | I2C_FUNC_SMBUS_WORD_DATA)) | 245 | I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -251,40 +252,35 @@ static int lm75_detect(struct i2c_client *new_client, int kind, | |||
251 | The cycling+unused addresses combination is not tested, | 252 | The cycling+unused addresses combination is not tested, |
252 | since it would significantly slow the detection down and would | 253 | since it would significantly slow the detection down and would |
253 | hardly add any value. */ | 254 | hardly add any value. */ |
254 | if (kind < 0) { | ||
255 | int cur, conf, hyst, os; | ||
256 | |||
257 | /* Unused addresses */ | ||
258 | cur = i2c_smbus_read_word_data(new_client, 0); | ||
259 | conf = i2c_smbus_read_byte_data(new_client, 1); | ||
260 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
261 | if (i2c_smbus_read_word_data(new_client, 4) != hyst | ||
262 | || i2c_smbus_read_word_data(new_client, 5) != hyst | ||
263 | || i2c_smbus_read_word_data(new_client, 6) != hyst | ||
264 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
265 | return -ENODEV; | ||
266 | os = i2c_smbus_read_word_data(new_client, 3); | ||
267 | if (i2c_smbus_read_word_data(new_client, 4) != os | ||
268 | || i2c_smbus_read_word_data(new_client, 5) != os | ||
269 | || i2c_smbus_read_word_data(new_client, 6) != os | ||
270 | || i2c_smbus_read_word_data(new_client, 7) != os) | ||
271 | return -ENODEV; | ||
272 | 255 | ||
273 | /* Unused bits */ | 256 | /* Unused addresses */ |
274 | if (conf & 0xe0) | 257 | cur = i2c_smbus_read_word_data(new_client, 0); |
275 | return -ENODEV; | 258 | conf = i2c_smbus_read_byte_data(new_client, 1); |
259 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
260 | if (i2c_smbus_read_word_data(new_client, 4) != hyst | ||
261 | || i2c_smbus_read_word_data(new_client, 5) != hyst | ||
262 | || i2c_smbus_read_word_data(new_client, 6) != hyst | ||
263 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
264 | return -ENODEV; | ||
265 | os = i2c_smbus_read_word_data(new_client, 3); | ||
266 | if (i2c_smbus_read_word_data(new_client, 4) != os | ||
267 | || i2c_smbus_read_word_data(new_client, 5) != os | ||
268 | || i2c_smbus_read_word_data(new_client, 6) != os | ||
269 | || i2c_smbus_read_word_data(new_client, 7) != os) | ||
270 | return -ENODEV; | ||
276 | 271 | ||
277 | /* Addresses cycling */ | 272 | /* Unused bits */ |
278 | for (i = 8; i < 0xff; i += 8) | 273 | if (conf & 0xe0) |
279 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | 274 | return -ENODEV; |
280 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | 275 | |
281 | || i2c_smbus_read_word_data(new_client, i + 3) != os) | 276 | /* Addresses cycling */ |
282 | return -ENODEV; | 277 | for (i = 8; i < 0xff; i += 8) { |
278 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | ||
279 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | ||
280 | || i2c_smbus_read_word_data(new_client, i + 3) != os) | ||
281 | return -ENODEV; | ||
283 | } | 282 | } |
284 | 283 | ||
285 | /* NOTE: we treat "force=..." and "force_lm75=..." the same. | ||
286 | * Only new-style driver binding distinguishes chip types. | ||
287 | */ | ||
288 | strlcpy(info->type, "lm75", I2C_NAME_SIZE); | 284 | strlcpy(info->type, "lm75", I2C_NAME_SIZE); |
289 | 285 | ||
290 | return 0; | 286 | return 0; |