aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ds1621.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/ds1621.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/ds1621.c')
-rw-r--r--drivers/hwmon/ds1621.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 53f88f511816..2a4c6a05b14f 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -237,20 +237,16 @@ static int ds1621_detect(struct i2c_client *client, int kind,
237 return -ENODEV; 237 return -ENODEV;
238 238
239 /* Now, we do the remaining detection. It is lousy. */ 239 /* Now, we do the remaining detection. It is lousy. */
240 if (kind < 0) { 240 /* The NVB bit should be low if no EEPROM write has been requested
241 /* The NVB bit should be low if no EEPROM write has been 241 during the latest 10ms, which is highly improbable in our case. */
242 requested during the latest 10ms, which is highly 242 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
243 improbable in our case. */ 243 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
244 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); 244 return -ENODEV;
245 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) 245 /* The 7 lowest bits of a temperature should always be 0. */
246 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) {
247 temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]);
248 if (temp < 0 || (temp & 0x7f00))
246 return -ENODEV; 249 return -ENODEV;
247 /* The 7 lowest bits of a temperature should always be 0. */
248 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) {
249 temp = i2c_smbus_read_word_data(client,
250 DS1621_REG_TEMP[i]);
251 if (temp < 0 || (temp & 0x7f00))
252 return -ENODEV;
253 }
254 } 250 }
255 251
256 strlcpy(info->type, "ds1621", I2C_NAME_SIZE); 252 strlcpy(info->type, "ds1621", I2C_NAME_SIZE);