From 90f4102ce59226954edbe960b2434d8b3da5f086 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 4 Nov 2011 12:00:47 +0100 Subject: hwmon: Use i2c_smbus_{read,write}_word_swapped Make use of the new i2c_smbus_{read,write}_word_swapped functions. This makes the driver code more compact and readable. It also ensures proper error handling. Signed-off-by: Jean Delvare Acked-by: Jonathan Cameron Acked-by: Guenter Roeck Cc: Dirk Eibach Cc: "Mark M. Hoffman" Cc: Guillaume Ligneul --- drivers/hwmon/ads7828.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers/hwmon/ads7828.c') 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, static int ads7828_probe(struct i2c_client *client, const struct i2c_device_id *id); -/* The ADS7828 returns the 12-bit sample in two bytes, - these are read as a word then byte-swapped */ -static u16 ads7828_read_value(struct i2c_client *client, u8 reg) -{ - return swab16(i2c_smbus_read_word_data(client, reg)); -} - static inline u8 channel_cmd_byte(int ch) { /* cmd byte C2,C1,C0 - see datasheet */ @@ -104,7 +97,8 @@ static struct ads7828_data *ads7828_update_device(struct device *dev) for (ch = 0; ch < ADS7828_NCH; ch++) { u8 cmd = channel_cmd_byte(ch); - data->adc_input[ch] = ads7828_read_value(client, cmd); + data->adc_input[ch] = + i2c_smbus_read_word_swapped(client, cmd); } data->last_updated = jiffies; data->valid = 1; @@ -203,7 +197,7 @@ static int ads7828_detect(struct i2c_client *client, for (ch = 0; ch < ADS7828_NCH; ch++) { u16 in_data; u8 cmd = channel_cmd_byte(ch); - in_data = ads7828_read_value(client, cmd); + in_data = i2c_smbus_read_word_swapped(client, cmd); if (in_data & 0xF000) { pr_debug("%s : Doesn't look like an ads7828 device\n", __func__); -- cgit