diff options
Diffstat (limited to 'drivers/hwmon/ads7828.c')
-rw-r--r-- | drivers/hwmon/ads7828.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c index c42c5a69a664..cfcc3b6fb6bf 100644 --- a/drivers/hwmon/ads7828.c +++ b/drivers/hwmon/ads7828.c | |||
@@ -74,13 +74,6 @@ static int ads7828_detect(struct i2c_client *client, | |||
74 | static int ads7828_probe(struct i2c_client *client, | 74 | static int ads7828_probe(struct i2c_client *client, |
75 | const struct i2c_device_id *id); | 75 | const struct i2c_device_id *id); |
76 | 76 | ||
77 | /* The ADS7828 returns the 12-bit sample in two bytes, | ||
78 | these are read as a word then byte-swapped */ | ||
79 | static u16 ads7828_read_value(struct i2c_client *client, u8 reg) | ||
80 | { | ||
81 | return swab16(i2c_smbus_read_word_data(client, reg)); | ||
82 | } | ||
83 | |||
84 | static inline u8 channel_cmd_byte(int ch) | 77 | static inline u8 channel_cmd_byte(int ch) |
85 | { | 78 | { |
86 | /* cmd byte C2,C1,C0 - see datasheet */ | 79 | /* cmd byte C2,C1,C0 - see datasheet */ |
@@ -104,7 +97,8 @@ static struct ads7828_data *ads7828_update_device(struct device *dev) | |||
104 | 97 | ||
105 | for (ch = 0; ch < ADS7828_NCH; ch++) { | 98 | for (ch = 0; ch < ADS7828_NCH; ch++) { |
106 | u8 cmd = channel_cmd_byte(ch); | 99 | u8 cmd = channel_cmd_byte(ch); |
107 | data->adc_input[ch] = ads7828_read_value(client, cmd); | 100 | data->adc_input[ch] = |
101 | i2c_smbus_read_word_swapped(client, cmd); | ||
108 | } | 102 | } |
109 | data->last_updated = jiffies; | 103 | data->last_updated = jiffies; |
110 | data->valid = 1; | 104 | data->valid = 1; |
@@ -203,7 +197,7 @@ static int ads7828_detect(struct i2c_client *client, | |||
203 | for (ch = 0; ch < ADS7828_NCH; ch++) { | 197 | for (ch = 0; ch < ADS7828_NCH; ch++) { |
204 | u16 in_data; | 198 | u16 in_data; |
205 | u8 cmd = channel_cmd_byte(ch); | 199 | u8 cmd = channel_cmd_byte(ch); |
206 | in_data = ads7828_read_value(client, cmd); | 200 | in_data = i2c_smbus_read_word_swapped(client, cmd); |
207 | if (in_data & 0xF000) { | 201 | if (in_data & 0xF000) { |
208 | pr_debug("%s : Doesn't look like an ads7828 device\n", | 202 | pr_debug("%s : Doesn't look like an ads7828 device\n", |
209 | __func__); | 203 | __func__); |