aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ads7828.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/ads7828.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/ads7828.c')
-rw-r--r--drivers/hwmon/ads7828.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index 5c39b4af1b23..451977bca7d6 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -191,6 +191,7 @@ static int ads7828_detect(struct i2c_client *client, int kind,
191 struct i2c_board_info *info) 191 struct i2c_board_info *info)
192{ 192{
193 struct i2c_adapter *adapter = client->adapter; 193 struct i2c_adapter *adapter = client->adapter;
194 int ch;
194 195
195 /* Check we have a valid client */ 196 /* Check we have a valid client */
196 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) 197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA))
@@ -202,20 +203,17 @@ static int ads7828_detect(struct i2c_client *client, int kind,
202 - Read from the 8 channel addresses 203 - Read from the 8 channel addresses
203 - Check the top 4 bits of each result are not set (12 data bits) 204 - Check the top 4 bits of each result are not set (12 data bits)
204 */ 205 */
205 if (kind < 0) { 206 for (ch = 0; ch < ADS7828_NCH; ch++) {
206 int ch; 207 u16 in_data;
207 for (ch = 0; ch < ADS7828_NCH; ch++) { 208 u8 cmd = channel_cmd_byte(ch);
208 u16 in_data; 209 in_data = ads7828_read_value(client, cmd);
209 u8 cmd = channel_cmd_byte(ch); 210 if (in_data & 0xF000) {
210 in_data = ads7828_read_value(client, cmd); 211 pr_debug("%s : Doesn't look like an ads7828 device\n",
211 if (in_data & 0xF000) { 212 __func__);
212 printk(KERN_DEBUG 213 return -ENODEV;
213 "%s : Doesn't look like an ads7828 device\n",
214 __func__);
215 return -ENODEV;
216 }
217 } 214 }
218 } 215 }
216
219 strlcpy(info->type, "ads7828", I2C_NAME_SIZE); 217 strlcpy(info->type, "ads7828", I2C_NAME_SIZE);
220 218
221 return 0; 219 return 0;