diff options
Diffstat (limited to 'drivers/hwmon/smm665.c')
-rw-r--r-- | drivers/hwmon/smm665.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/hwmon/smm665.c b/drivers/hwmon/smm665.c index 425df5bccd4..411638181fd 100644 --- a/drivers/hwmon/smm665.c +++ b/drivers/hwmon/smm665.c | |||
@@ -214,33 +214,26 @@ static int smm665_read_adc(struct smm665_data *data, int adc) | |||
214 | * | 214 | * |
215 | * Neither i2c_smbus_read_byte() nor | 215 | * Neither i2c_smbus_read_byte() nor |
216 | * i2c_smbus_read_block_data() worked here, | 216 | * i2c_smbus_read_block_data() worked here, |
217 | * so use i2c_smbus_read_word_data() instead. | 217 | * so use i2c_smbus_read_word_swapped() instead. |
218 | * We could also try to use i2c_master_recv(), | 218 | * We could also try to use i2c_master_recv(), |
219 | * but that is not always supported. | 219 | * but that is not always supported. |
220 | */ | 220 | */ |
221 | rv = i2c_smbus_read_word_data(client, 0); | 221 | rv = i2c_smbus_read_word_swapped(client, 0); |
222 | if (rv < 0) { | 222 | if (rv < 0) { |
223 | dev_dbg(&client->dev, "Failed to read ADC value: error %d", rv); | 223 | dev_dbg(&client->dev, "Failed to read ADC value: error %d", rv); |
224 | return -1; | 224 | return -1; |
225 | } | 225 | } |
226 | /* | 226 | /* |
227 | * Validate/verify readback adc channel (in bit 11..14). | 227 | * Validate/verify readback adc channel (in bit 11..14). |
228 | * High byte is in lower 8 bit of rv, so only shift by 3. | ||
229 | */ | 228 | */ |
230 | radc = (rv >> 3) & 0x0f; | 229 | radc = (rv >> 11) & 0x0f; |
231 | if (radc != adc) { | 230 | if (radc != adc) { |
232 | dev_dbg(&client->dev, "Unexpected RADC: Expected %d got %d", | 231 | dev_dbg(&client->dev, "Unexpected RADC: Expected %d got %d", |
233 | adc, radc); | 232 | adc, radc); |
234 | return -EIO; | 233 | return -EIO; |
235 | } | 234 | } |
236 | /* | ||
237 | * Chip replies with H/L, while SMBus expects L/H. | ||
238 | * Thus, byte order is reversed, and we have to swap | ||
239 | * the result. | ||
240 | */ | ||
241 | rv = swab16(rv) & SMM665_ADC_MASK; | ||
242 | 235 | ||
243 | return rv; | 236 | return rv & SMM665_ADC_MASK; |
244 | } | 237 | } |
245 | 238 | ||
246 | static struct smm665_data *smm665_update_device(struct device *dev) | 239 | static struct smm665_data *smm665_update_device(struct device *dev) |