aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/ad7414.c7
-rw-r--r--drivers/hwmon/ad7418.c27
-rw-r--r--drivers/hwmon/ads1015.c21
-rw-r--r--drivers/hwmon/ads7828.c12
-rw-r--r--drivers/hwmon/asb100.c10
-rw-r--r--drivers/hwmon/ds1621.c24
-rw-r--r--drivers/hwmon/ds620.c42
-rw-r--r--drivers/hwmon/gl518sm.c4
-rw-r--r--drivers/hwmon/gl520sm.c4
-rw-r--r--drivers/hwmon/jc42.c52
-rw-r--r--drivers/hwmon/lm73.c8
-rw-r--r--drivers/hwmon/lm75.c9
-rw-r--r--drivers/hwmon/lm77.c4
-rw-r--r--drivers/hwmon/lm92.c26
-rw-r--r--drivers/hwmon/max16065.c4
-rw-r--r--drivers/hwmon/sht21.c26
-rw-r--r--drivers/hwmon/smm665.c15
-rw-r--r--drivers/hwmon/tmp102.c44
-rw-r--r--drivers/hwmon/w83781d.c10
19 files changed, 115 insertions, 234 deletions
diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c
index d46c0c758ddf..df29a7fff9e7 100644
--- a/drivers/hwmon/ad7414.c
+++ b/drivers/hwmon/ad7414.c
@@ -58,10 +58,9 @@ static inline int ad7414_temp_from_reg(s16 reg)
58 58
59static inline int ad7414_read(struct i2c_client *client, u8 reg) 59static inline int ad7414_read(struct i2c_client *client, u8 reg)
60{ 60{
61 if (reg == AD7414_REG_TEMP) { 61 if (reg == AD7414_REG_TEMP)
62 int value = i2c_smbus_read_word_data(client, reg); 62 return i2c_smbus_read_word_swapped(client, reg);
63 return (value < 0) ? value : swab16(value); 63 else
64 } else
65 return i2c_smbus_read_byte_data(client, reg); 64 return i2c_smbus_read_byte_data(client, reg);
66} 65}
67 66
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
index ffc781fec185..8cb718ce8237 100644
--- a/drivers/hwmon/ad7418.c
+++ b/drivers/hwmon/ad7418.c
@@ -76,20 +76,6 @@ static struct i2c_driver ad7418_driver = {
76 .id_table = ad7418_id, 76 .id_table = ad7418_id,
77}; 77};
78 78
79/* All registers are word-sized, except for the configuration registers.
80 * AD7418 uses a high-byte first convention. Do NOT use those functions to
81 * access the configuration registers CONF and CONF2, as they are byte-sized.
82 */
83static inline int ad7418_read(struct i2c_client *client, u8 reg)
84{
85 return swab16(i2c_smbus_read_word_data(client, reg));
86}
87
88static inline int ad7418_write(struct i2c_client *client, u8 reg, u16 value)
89{
90 return i2c_smbus_write_word_data(client, reg, swab16(value));
91}
92
93static void ad7418_init_client(struct i2c_client *client) 79static void ad7418_init_client(struct i2c_client *client)
94{ 80{
95 struct ad7418_data *data = i2c_get_clientdata(client); 81 struct ad7418_data *data = i2c_get_clientdata(client);
@@ -128,7 +114,9 @@ static struct ad7418_data *ad7418_update_device(struct device *dev)
128 udelay(30); 114 udelay(30);
129 115
130 for (i = 0; i < 3; i++) { 116 for (i = 0; i < 3; i++) {
131 data->temp[i] = ad7418_read(client, AD7418_REG_TEMP[i]); 117 data->temp[i] =
118 i2c_smbus_read_word_swapped(client,
119 AD7418_REG_TEMP[i]);
132 } 120 }
133 121
134 for (i = 0, ch = 4; i < data->adc_max; i++, ch--) { 122 for (i = 0, ch = 4; i < data->adc_max; i++, ch--) {
@@ -138,11 +126,12 @@ static struct ad7418_data *ad7418_update_device(struct device *dev)
138 126
139 udelay(15); 127 udelay(15);
140 data->in[data->adc_max - 1 - i] = 128 data->in[data->adc_max - 1 - i] =
141 ad7418_read(client, AD7418_REG_ADC); 129 i2c_smbus_read_word_swapped(client,
130 AD7418_REG_ADC);
142 } 131 }
143 132
144 /* restore old configuration value */ 133 /* restore old configuration value */
145 ad7418_write(client, AD7418_REG_CONF, cfg); 134 i2c_smbus_write_word_swapped(client, AD7418_REG_CONF, cfg);
146 135
147 data->last_updated = jiffies; 136 data->last_updated = jiffies;
148 data->valid = 1; 137 data->valid = 1;
@@ -182,7 +171,9 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
182 171
183 mutex_lock(&data->lock); 172 mutex_lock(&data->lock);
184 data->temp[attr->index] = LM75_TEMP_TO_REG(temp); 173 data->temp[attr->index] = LM75_TEMP_TO_REG(temp);
185 ad7418_write(client, AD7418_REG_TEMP[attr->index], data->temp[attr->index]); 174 i2c_smbus_write_word_swapped(client,
175 AD7418_REG_TEMP[attr->index],
176 data->temp[attr->index]);
186 mutex_unlock(&data->lock); 177 mutex_unlock(&data->lock);
187 return count; 178 return count;
188} 179}
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index e9beeda4cbe5..eedca3cf9968 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -59,19 +59,6 @@ struct ads1015_data {
59 struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; 59 struct ads1015_channel_data channel_data[ADS1015_CHANNELS];
60}; 60};
61 61
62static s32 ads1015_read_reg(struct i2c_client *client, unsigned int reg)
63{
64 s32 data = i2c_smbus_read_word_data(client, reg);
65
66 return (data < 0) ? data : swab16(data);
67}
68
69static s32 ads1015_write_reg(struct i2c_client *client, unsigned int reg,
70 u16 val)
71{
72 return i2c_smbus_write_word_data(client, reg, swab16(val));
73}
74
75static int ads1015_read_value(struct i2c_client *client, unsigned int channel, 62static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
76 int *value) 63 int *value)
77{ 64{
@@ -87,7 +74,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
87 mutex_lock(&data->update_lock); 74 mutex_lock(&data->update_lock);
88 75
89 /* get channel parameters */ 76 /* get channel parameters */
90 res = ads1015_read_reg(client, ADS1015_CONFIG); 77 res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG);
91 if (res < 0) 78 if (res < 0)
92 goto err_unlock; 79 goto err_unlock;
93 config = res; 80 config = res;
@@ -101,13 +88,13 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
101 config |= (pga & 0x0007) << 9; 88 config |= (pga & 0x0007) << 9;
102 config |= (data_rate & 0x0007) << 5; 89 config |= (data_rate & 0x0007) << 5;
103 90
104 res = ads1015_write_reg(client, ADS1015_CONFIG, config); 91 res = i2c_smbus_write_word_swapped(client, ADS1015_CONFIG, config);
105 if (res < 0) 92 if (res < 0)
106 goto err_unlock; 93 goto err_unlock;
107 94
108 /* wait until conversion finished */ 95 /* wait until conversion finished */
109 msleep(conversion_time_ms); 96 msleep(conversion_time_ms);
110 res = ads1015_read_reg(client, ADS1015_CONFIG); 97 res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG);
111 if (res < 0) 98 if (res < 0)
112 goto err_unlock; 99 goto err_unlock;
113 config = res; 100 config = res;
@@ -117,7 +104,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
117 goto err_unlock; 104 goto err_unlock;
118 } 105 }
119 106
120 res = ads1015_read_reg(client, ADS1015_CONVERSION); 107 res = i2c_smbus_read_word_swapped(client, ADS1015_CONVERSION);
121 if (res < 0) 108 if (res < 0)
122 goto err_unlock; 109 goto err_unlock;
123 conversion = res; 110 conversion = res;
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,
74static int ads7828_probe(struct i2c_client *client, 74static 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 */
79static u16 ads7828_read_value(struct i2c_client *client, u8 reg)
80{
81 return swab16(i2c_smbus_read_word_data(client, reg));
82}
83
84static inline u8 channel_cmd_byte(int ch) 77static 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__);
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index c02a052d3085..d7bd1f3f2a31 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -829,17 +829,17 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
829 /* convert from ISA to LM75 I2C addresses */ 829 /* convert from ISA to LM75 I2C addresses */
830 switch (reg & 0xff) { 830 switch (reg & 0xff) {
831 case 0x50: /* TEMP */ 831 case 0x50: /* TEMP */
832 res = swab16(i2c_smbus_read_word_data(cl, 0)); 832 res = i2c_smbus_read_word_swapped(cl, 0);
833 break; 833 break;
834 case 0x52: /* CONFIG */ 834 case 0x52: /* CONFIG */
835 res = i2c_smbus_read_byte_data(cl, 1); 835 res = i2c_smbus_read_byte_data(cl, 1);
836 break; 836 break;
837 case 0x53: /* HYST */ 837 case 0x53: /* HYST */
838 res = swab16(i2c_smbus_read_word_data(cl, 2)); 838 res = i2c_smbus_read_word_swapped(cl, 2);
839 break; 839 break;
840 case 0x55: /* MAX */ 840 case 0x55: /* MAX */
841 default: 841 default:
842 res = swab16(i2c_smbus_read_word_data(cl, 3)); 842 res = i2c_smbus_read_word_swapped(cl, 3);
843 break; 843 break;
844 } 844 }
845 } 845 }
@@ -877,10 +877,10 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
877 i2c_smbus_write_byte_data(cl, 1, value & 0xff); 877 i2c_smbus_write_byte_data(cl, 1, value & 0xff);
878 break; 878 break;
879 case 0x53: /* HYST */ 879 case 0x53: /* HYST */
880 i2c_smbus_write_word_data(cl, 2, swab16(value)); 880 i2c_smbus_write_word_swapped(cl, 2, value);
881 break; 881 break;
882 case 0x55: /* MAX */ 882 case 0x55: /* MAX */
883 i2c_smbus_write_word_data(cl, 3, swab16(value)); 883 i2c_smbus_write_word_swapped(cl, 3, value);
884 break; 884 break;
885 } 885 }
886 } 886 }
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index e11363467a8d..ef1ac996752e 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -80,24 +80,6 @@ struct ds1621_data {
80 u8 conf; /* Register encoding, combined */ 80 u8 conf; /* Register encoding, combined */
81}; 81};
82 82
83/* Temperature registers are word-sized.
84 DS1621 uses a high-byte first convention, which is exactly opposite to
85 the SMBus standard. */
86static int ds1621_read_temp(struct i2c_client *client, u8 reg)
87{
88 int ret;
89
90 ret = i2c_smbus_read_word_data(client, reg);
91 if (ret < 0)
92 return ret;
93 return swab16(ret);
94}
95
96static int ds1621_write_temp(struct i2c_client *client, u8 reg, u16 value)
97{
98 return i2c_smbus_write_word_data(client, reg, swab16(value));
99}
100
101static void ds1621_init_client(struct i2c_client *client) 83static void ds1621_init_client(struct i2c_client *client)
102{ 84{
103 u8 conf, new_conf; 85 u8 conf, new_conf;
@@ -136,7 +118,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
136 data->conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); 118 data->conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
137 119
138 for (i = 0; i < ARRAY_SIZE(data->temp); i++) 120 for (i = 0; i < ARRAY_SIZE(data->temp); i++)
139 data->temp[i] = ds1621_read_temp(client, 121 data->temp[i] = i2c_smbus_read_word_swapped(client,
140 DS1621_REG_TEMP[i]); 122 DS1621_REG_TEMP[i]);
141 123
142 /* reset alarms if necessary */ 124 /* reset alarms if necessary */
@@ -177,8 +159,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
177 159
178 mutex_lock(&data->update_lock); 160 mutex_lock(&data->update_lock);
179 data->temp[attr->index] = val; 161 data->temp[attr->index] = val;
180 ds1621_write_temp(client, DS1621_REG_TEMP[attr->index], 162 i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index],
181 data->temp[attr->index]); 163 data->temp[attr->index]);
182 mutex_unlock(&data->update_lock); 164 mutex_unlock(&data->update_lock);
183 return count; 165 return count;
184} 166}
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index 4f7c3fc40a89..225ae4f36583 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -75,33 +75,13 @@ struct ds620_data {
75 s16 temp[3]; /* Register values, word */ 75 s16 temp[3]; /* Register values, word */
76}; 76};
77 77
78/*
79 * Temperature registers are word-sized.
80 * DS620 uses a high-byte first convention, which is exactly opposite to
81 * the SMBus standard.
82 */
83static int ds620_read_temp(struct i2c_client *client, u8 reg)
84{
85 int ret;
86
87 ret = i2c_smbus_read_word_data(client, reg);
88 if (ret < 0)
89 return ret;
90 return swab16(ret);
91}
92
93static int ds620_write_temp(struct i2c_client *client, u8 reg, u16 value)
94{
95 return i2c_smbus_write_word_data(client, reg, swab16(value));
96}
97
98static void ds620_init_client(struct i2c_client *client) 78static void ds620_init_client(struct i2c_client *client)
99{ 79{
100 struct ds620_platform_data *ds620_info = client->dev.platform_data; 80 struct ds620_platform_data *ds620_info = client->dev.platform_data;
101 u16 conf, new_conf; 81 u16 conf, new_conf;
102 82
103 new_conf = conf = 83 new_conf = conf =
104 swab16(i2c_smbus_read_word_data(client, DS620_REG_CONF)); 84 i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
105 85
106 /* switch to continuous conversion mode */ 86 /* switch to continuous conversion mode */
107 new_conf &= ~DS620_REG_CONFIG_1SHOT; 87 new_conf &= ~DS620_REG_CONFIG_1SHOT;
@@ -118,8 +98,7 @@ static void ds620_init_client(struct i2c_client *client)
118 new_conf |= DS620_REG_CONFIG_R1 | DS620_REG_CONFIG_R0; 98 new_conf |= DS620_REG_CONFIG_R1 | DS620_REG_CONFIG_R0;
119 99
120 if (conf != new_conf) 100 if (conf != new_conf)
121 i2c_smbus_write_word_data(client, DS620_REG_CONF, 101 i2c_smbus_write_word_swapped(client, DS620_REG_CONF, new_conf);
122 swab16(new_conf));
123 102
124 /* start conversion */ 103 /* start conversion */
125 i2c_smbus_write_byte(client, DS620_COM_START); 104 i2c_smbus_write_byte(client, DS620_COM_START);
@@ -141,8 +120,8 @@ static struct ds620_data *ds620_update_client(struct device *dev)
141 dev_dbg(&client->dev, "Starting ds620 update\n"); 120 dev_dbg(&client->dev, "Starting ds620 update\n");
142 121
143 for (i = 0; i < ARRAY_SIZE(data->temp); i++) { 122 for (i = 0; i < ARRAY_SIZE(data->temp); i++) {
144 res = ds620_read_temp(client, 123 res = i2c_smbus_read_word_swapped(client,
145 DS620_REG_TEMP[i]); 124 DS620_REG_TEMP[i]);
146 if (res < 0) { 125 if (res < 0) {
147 ret = ERR_PTR(res); 126 ret = ERR_PTR(res);
148 goto abort; 127 goto abort;
@@ -191,8 +170,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
191 170
192 mutex_lock(&data->update_lock); 171 mutex_lock(&data->update_lock);
193 data->temp[attr->index] = val; 172 data->temp[attr->index] = val;
194 ds620_write_temp(client, DS620_REG_TEMP[attr->index], 173 i2c_smbus_write_word_swapped(client, DS620_REG_TEMP[attr->index],
195 data->temp[attr->index]); 174 data->temp[attr->index]);
196 mutex_unlock(&data->update_lock); 175 mutex_unlock(&data->update_lock);
197 return count; 176 return count;
198} 177}
@@ -210,16 +189,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
210 return PTR_ERR(data); 189 return PTR_ERR(data);
211 190
212 /* reset alarms if necessary */ 191 /* reset alarms if necessary */
213 res = i2c_smbus_read_word_data(client, DS620_REG_CONF); 192 res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
214 if (res < 0) 193 if (res < 0)
215 return res; 194 return res;
216 195
217 conf = swab16(res); 196 new_conf = conf = res;
218 new_conf = conf;
219 new_conf &= ~attr->index; 197 new_conf &= ~attr->index;
220 if (conf != new_conf) { 198 if (conf != new_conf) {
221 res = i2c_smbus_write_word_data(client, DS620_REG_CONF, 199 res = i2c_smbus_write_word_swapped(client, DS620_REG_CONF,
222 swab16(new_conf)); 200 new_conf);
223 if (res < 0) 201 if (res < 0)
224 return res; 202 return res;
225 } 203 }
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index e7ae5743e181..a13e2da97e30 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -591,7 +591,7 @@ static int gl518_remove(struct i2c_client *client)
591static int gl518_read_value(struct i2c_client *client, u8 reg) 591static int gl518_read_value(struct i2c_client *client, u8 reg)
592{ 592{
593 if ((reg >= 0x07) && (reg <= 0x0c)) 593 if ((reg >= 0x07) && (reg <= 0x0c))
594 return swab16(i2c_smbus_read_word_data(client, reg)); 594 return i2c_smbus_read_word_swapped(client, reg);
595 else 595 else
596 return i2c_smbus_read_byte_data(client, reg); 596 return i2c_smbus_read_byte_data(client, reg);
597} 597}
@@ -599,7 +599,7 @@ static int gl518_read_value(struct i2c_client *client, u8 reg)
599static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value) 599static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value)
600{ 600{
601 if ((reg >= 0x07) && (reg <= 0x0c)) 601 if ((reg >= 0x07) && (reg <= 0x0c))
602 return i2c_smbus_write_word_data(client, reg, swab16(value)); 602 return i2c_smbus_write_word_swapped(client, reg, value);
603 else 603 else
604 return i2c_smbus_write_byte_data(client, reg, value); 604 return i2c_smbus_write_byte_data(client, reg, value);
605} 605}
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index 131ea8625f08..cd6085bbfba7 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -821,7 +821,7 @@ static int gl520_remove(struct i2c_client *client)
821static int gl520_read_value(struct i2c_client *client, u8 reg) 821static int gl520_read_value(struct i2c_client *client, u8 reg)
822{ 822{
823 if ((reg >= 0x07) && (reg <= 0x0c)) 823 if ((reg >= 0x07) && (reg <= 0x0c))
824 return swab16(i2c_smbus_read_word_data(client, reg)); 824 return i2c_smbus_read_word_swapped(client, reg);
825 else 825 else
826 return i2c_smbus_read_byte_data(client, reg); 826 return i2c_smbus_read_byte_data(client, reg);
827} 827}
@@ -829,7 +829,7 @@ static int gl520_read_value(struct i2c_client *client, u8 reg)
829static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value) 829static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value)
830{ 830{
831 if ((reg >= 0x07) && (reg <= 0x0c)) 831 if ((reg >= 0x07) && (reg <= 0x0c))
832 return i2c_smbus_write_word_data(client, reg, swab16(value)); 832 return i2c_smbus_write_word_swapped(client, reg, value);
833 else 833 else
834 return i2c_smbus_write_byte_data(client, reg, value); 834 return i2c_smbus_write_byte_data(client, reg, value);
835} 835}
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index 02cebb74e206..2d3d72805ff4 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -154,8 +154,6 @@ static int jc42_probe(struct i2c_client *client,
154 const struct i2c_device_id *id); 154 const struct i2c_device_id *id);
155static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info); 155static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info);
156static int jc42_remove(struct i2c_client *client); 156static int jc42_remove(struct i2c_client *client);
157static int jc42_read_value(struct i2c_client *client, u8 reg);
158static int jc42_write_value(struct i2c_client *client, u8 reg, u16 value);
159 157
160static struct jc42_data *jc42_update_device(struct device *dev); 158static struct jc42_data *jc42_update_device(struct device *dev);
161 159
@@ -187,7 +185,7 @@ static int jc42_suspend(struct device *dev)
187 struct jc42_data *data = i2c_get_clientdata(client); 185 struct jc42_data *data = i2c_get_clientdata(client);
188 186
189 data->config |= JC42_CFG_SHUTDOWN; 187 data->config |= JC42_CFG_SHUTDOWN;
190 jc42_write_value(client, JC42_REG_CONFIG, data->config); 188 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, data->config);
191 return 0; 189 return 0;
192} 190}
193 191
@@ -197,7 +195,7 @@ static int jc42_resume(struct device *dev)
197 struct jc42_data *data = i2c_get_clientdata(client); 195 struct jc42_data *data = i2c_get_clientdata(client);
198 196
199 data->config &= ~JC42_CFG_SHUTDOWN; 197 data->config &= ~JC42_CFG_SHUTDOWN;
200 jc42_write_value(client, JC42_REG_CONFIG, data->config); 198 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, data->config);
201 return 0; 199 return 0;
202} 200}
203 201
@@ -315,7 +313,7 @@ static ssize_t set_##value(struct device *dev, \
315 return -EINVAL; \ 313 return -EINVAL; \
316 mutex_lock(&data->update_lock); \ 314 mutex_lock(&data->update_lock); \
317 data->value = jc42_temp_to_reg(val, data->extended); \ 315 data->value = jc42_temp_to_reg(val, data->extended); \
318 err = jc42_write_value(client, reg, data->value); \ 316 err = i2c_smbus_write_word_swapped(client, reg, data->value); \
319 if (err < 0) \ 317 if (err < 0) \
320 ret = err; \ 318 ret = err; \
321 mutex_unlock(&data->update_lock); \ 319 mutex_unlock(&data->update_lock); \
@@ -357,7 +355,8 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
357 data->config = (data->config 355 data->config = (data->config
358 & ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT)) 356 & ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT))
359 | (hyst << JC42_CFG_HYST_SHIFT); 357 | (hyst << JC42_CFG_HYST_SHIFT);
360 err = jc42_write_value(client, JC42_REG_CONFIG, data->config); 358 err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG,
359 data->config);
361 if (err < 0) 360 if (err < 0)
362 ret = err; 361 ret = err;
363 mutex_unlock(&data->update_lock); 362 mutex_unlock(&data->update_lock);
@@ -452,10 +451,10 @@ static int jc42_detect(struct i2c_client *new_client,
452 I2C_FUNC_SMBUS_WORD_DATA)) 451 I2C_FUNC_SMBUS_WORD_DATA))
453 return -ENODEV; 452 return -ENODEV;
454 453
455 cap = jc42_read_value(new_client, JC42_REG_CAP); 454 cap = i2c_smbus_read_word_swapped(new_client, JC42_REG_CAP);
456 config = jc42_read_value(new_client, JC42_REG_CONFIG); 455 config = i2c_smbus_read_word_swapped(new_client, JC42_REG_CONFIG);
457 manid = jc42_read_value(new_client, JC42_REG_MANID); 456 manid = i2c_smbus_read_word_swapped(new_client, JC42_REG_MANID);
458 devid = jc42_read_value(new_client, JC42_REG_DEVICEID); 457 devid = i2c_smbus_read_word_swapped(new_client, JC42_REG_DEVICEID);
459 458
460 if (cap < 0 || config < 0 || manid < 0 || devid < 0) 459 if (cap < 0 || config < 0 || manid < 0 || devid < 0)
461 return -ENODEV; 460 return -ENODEV;
@@ -489,14 +488,14 @@ static int jc42_probe(struct i2c_client *new_client,
489 i2c_set_clientdata(new_client, data); 488 i2c_set_clientdata(new_client, data);
490 mutex_init(&data->update_lock); 489 mutex_init(&data->update_lock);
491 490
492 cap = jc42_read_value(new_client, JC42_REG_CAP); 491 cap = i2c_smbus_read_word_swapped(new_client, JC42_REG_CAP);
493 if (cap < 0) { 492 if (cap < 0) {
494 err = -EINVAL; 493 err = -EINVAL;
495 goto exit_free; 494 goto exit_free;
496 } 495 }
497 data->extended = !!(cap & JC42_CAP_RANGE); 496 data->extended = !!(cap & JC42_CAP_RANGE);
498 497
499 config = jc42_read_value(new_client, JC42_REG_CONFIG); 498 config = i2c_smbus_read_word_swapped(new_client, JC42_REG_CONFIG);
500 if (config < 0) { 499 if (config < 0) {
501 err = -EINVAL; 500 err = -EINVAL;
502 goto exit_free; 501 goto exit_free;
@@ -504,7 +503,8 @@ static int jc42_probe(struct i2c_client *new_client,
504 data->orig_config = config; 503 data->orig_config = config;
505 if (config & JC42_CFG_SHUTDOWN) { 504 if (config & JC42_CFG_SHUTDOWN) {
506 config &= ~JC42_CFG_SHUTDOWN; 505 config &= ~JC42_CFG_SHUTDOWN;
507 jc42_write_value(new_client, JC42_REG_CONFIG, config); 506 i2c_smbus_write_word_swapped(new_client, JC42_REG_CONFIG,
507 config);
508 } 508 }
509 data->config = config; 509 data->config = config;
510 510
@@ -535,25 +535,12 @@ static int jc42_remove(struct i2c_client *client)
535 hwmon_device_unregister(data->hwmon_dev); 535 hwmon_device_unregister(data->hwmon_dev);
536 sysfs_remove_group(&client->dev.kobj, &jc42_group); 536 sysfs_remove_group(&client->dev.kobj, &jc42_group);
537 if (data->config != data->orig_config) 537 if (data->config != data->orig_config)
538 jc42_write_value(client, JC42_REG_CONFIG, data->orig_config); 538 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG,
539 data->orig_config);
539 kfree(data); 540 kfree(data);
540 return 0; 541 return 0;
541} 542}
542 543
543/* All registers are word-sized. */
544static int jc42_read_value(struct i2c_client *client, u8 reg)
545{
546 int ret = i2c_smbus_read_word_data(client, reg);
547 if (ret < 0)
548 return ret;
549 return swab16(ret);
550}
551
552static int jc42_write_value(struct i2c_client *client, u8 reg, u16 value)
553{
554 return i2c_smbus_write_word_data(client, reg, swab16(value));
555}
556
557static struct jc42_data *jc42_update_device(struct device *dev) 544static struct jc42_data *jc42_update_device(struct device *dev)
558{ 545{
559 struct i2c_client *client = to_i2c_client(dev); 546 struct i2c_client *client = to_i2c_client(dev);
@@ -564,28 +551,29 @@ static struct jc42_data *jc42_update_device(struct device *dev)
564 mutex_lock(&data->update_lock); 551 mutex_lock(&data->update_lock);
565 552
566 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 553 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
567 val = jc42_read_value(client, JC42_REG_TEMP); 554 val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP);
568 if (val < 0) { 555 if (val < 0) {
569 ret = ERR_PTR(val); 556 ret = ERR_PTR(val);
570 goto abort; 557 goto abort;
571 } 558 }
572 data->temp_input = val; 559 data->temp_input = val;
573 560
574 val = jc42_read_value(client, JC42_REG_TEMP_CRITICAL); 561 val = i2c_smbus_read_word_swapped(client,
562 JC42_REG_TEMP_CRITICAL);
575 if (val < 0) { 563 if (val < 0) {
576 ret = ERR_PTR(val); 564 ret = ERR_PTR(val);
577 goto abort; 565 goto abort;
578 } 566 }
579 data->temp_crit = val; 567 data->temp_crit = val;
580 568
581 val = jc42_read_value(client, JC42_REG_TEMP_LOWER); 569 val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER);
582 if (val < 0) { 570 if (val < 0) {
583 ret = ERR_PTR(val); 571 ret = ERR_PTR(val);
584 goto abort; 572 goto abort;
585 } 573 }
586 data->temp_min = val; 574 data->temp_min = val;
587 575
588 val = jc42_read_value(client, JC42_REG_TEMP_UPPER); 576 val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER);
589 if (val < 0) { 577 if (val < 0) {
590 ret = ERR_PTR(val); 578 ret = ERR_PTR(val);
591 goto abort; 579 goto abort;
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
index 24be17608fbb..9e64d96620d3 100644
--- a/drivers/hwmon/lm73.c
+++ b/drivers/hwmon/lm73.c
@@ -34,7 +34,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
34#define LM73_REG_CTRL 0x04 34#define LM73_REG_CTRL 0x04
35#define LM73_REG_ID 0x07 35#define LM73_REG_ID 0x07
36 36
37#define LM73_ID 0x9001 /* or 0x190 after a swab16() */ 37#define LM73_ID 0x9001 /* 0x0190, byte-swapped */
38#define DRVNAME "lm73" 38#define DRVNAME "lm73"
39#define LM73_TEMP_MIN (-40) 39#define LM73_TEMP_MIN (-40)
40#define LM73_TEMP_MAX 150 40#define LM73_TEMP_MAX 150
@@ -57,7 +57,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
57 /* Write value */ 57 /* Write value */
58 value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4), 58 value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4),
59 (LM73_TEMP_MAX*4)) << 5; 59 (LM73_TEMP_MAX*4)) << 5;
60 i2c_smbus_write_word_data(client, attr->index, swab16(value)); 60 i2c_smbus_write_word_swapped(client, attr->index, value);
61 return count; 61 return count;
62} 62}
63 63
@@ -68,8 +68,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
68 struct i2c_client *client = to_i2c_client(dev); 68 struct i2c_client *client = to_i2c_client(dev);
69 /* use integer division instead of equivalent right shift to 69 /* use integer division instead of equivalent right shift to
70 guarantee arithmetic shift and preserve the sign */ 70 guarantee arithmetic shift and preserve the sign */
71 int temp = ((s16) (swab16(i2c_smbus_read_word_data(client, 71 int temp = ((s16) (i2c_smbus_read_word_swapped(client,
72 attr->index)))*250) / 32; 72 attr->index))*250) / 32;
73 return sprintf(buf, "%d\n", temp); 73 return sprintf(buf, "%d\n", temp);
74} 74}
75 75
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 90126a2a1e44..1888dd0fc05f 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -384,13 +384,10 @@ static struct i2c_driver lm75_driver = {
384 */ 384 */
385static int lm75_read_value(struct i2c_client *client, u8 reg) 385static int lm75_read_value(struct i2c_client *client, u8 reg)
386{ 386{
387 int value;
388
389 if (reg == LM75_REG_CONF) 387 if (reg == LM75_REG_CONF)
390 return i2c_smbus_read_byte_data(client, reg); 388 return i2c_smbus_read_byte_data(client, reg);
391 389 else
392 value = i2c_smbus_read_word_data(client, reg); 390 return i2c_smbus_read_word_swapped(client, reg);
393 return (value < 0) ? value : swab16(value);
394} 391}
395 392
396static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) 393static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
@@ -398,7 +395,7 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
398 if (reg == LM75_REG_CONF) 395 if (reg == LM75_REG_CONF)
399 return i2c_smbus_write_byte_data(client, reg, value); 396 return i2c_smbus_write_byte_data(client, reg, value);
400 else 397 else
401 return i2c_smbus_write_word_data(client, reg, swab16(value)); 398 return i2c_smbus_write_word_swapped(client, reg, value);
402} 399}
403 400
404static struct lm75_data *lm75_update_device(struct device *dev) 401static struct lm75_data *lm75_update_device(struct device *dev)
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index b28a297be50c..8dfc6782d596 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -365,7 +365,7 @@ static u16 lm77_read_value(struct i2c_client *client, u8 reg)
365 if (reg == LM77_REG_CONF) 365 if (reg == LM77_REG_CONF)
366 return i2c_smbus_read_byte_data(client, reg); 366 return i2c_smbus_read_byte_data(client, reg);
367 else 367 else
368 return swab16(i2c_smbus_read_word_data(client, reg)); 368 return i2c_smbus_read_word_swapped(client, reg);
369} 369}
370 370
371static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value) 371static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value)
@@ -373,7 +373,7 @@ static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value)
373 if (reg == LM77_REG_CONF) 373 if (reg == LM77_REG_CONF)
374 return i2c_smbus_write_byte_data(client, reg, value); 374 return i2c_smbus_write_byte_data(client, reg, value);
375 else 375 else
376 return i2c_smbus_write_word_data(client, reg, swab16(value)); 376 return i2c_smbus_write_word_swapped(client, reg, value);
377} 377}
378 378
379static void lm77_init_client(struct i2c_client *client) 379static void lm77_init_client(struct i2c_client *client)
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 7c31e6205f85..8fcbd4d422c5 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -117,16 +117,16 @@ static struct lm92_data *lm92_update_device(struct device *dev)
117 if (time_after(jiffies, data->last_updated + HZ) 117 if (time_after(jiffies, data->last_updated + HZ)
118 || !data->valid) { 118 || !data->valid) {
119 dev_dbg(&client->dev, "Updating lm92 data\n"); 119 dev_dbg(&client->dev, "Updating lm92 data\n");
120 data->temp1_input = swab16(i2c_smbus_read_word_data(client, 120 data->temp1_input = i2c_smbus_read_word_swapped(client,
121 LM92_REG_TEMP)); 121 LM92_REG_TEMP);
122 data->temp1_hyst = swab16(i2c_smbus_read_word_data(client, 122 data->temp1_hyst = i2c_smbus_read_word_swapped(client,
123 LM92_REG_TEMP_HYST)); 123 LM92_REG_TEMP_HYST);
124 data->temp1_crit = swab16(i2c_smbus_read_word_data(client, 124 data->temp1_crit = i2c_smbus_read_word_swapped(client,
125 LM92_REG_TEMP_CRIT)); 125 LM92_REG_TEMP_CRIT);
126 data->temp1_min = swab16(i2c_smbus_read_word_data(client, 126 data->temp1_min = i2c_smbus_read_word_swapped(client,
127 LM92_REG_TEMP_LOW)); 127 LM92_REG_TEMP_LOW);
128 data->temp1_max = swab16(i2c_smbus_read_word_data(client, 128 data->temp1_max = i2c_smbus_read_word_swapped(client,
129 LM92_REG_TEMP_HIGH)); 129 LM92_REG_TEMP_HIGH);
130 130
131 data->last_updated = jiffies; 131 data->last_updated = jiffies;
132 data->valid = 1; 132 data->valid = 1;
@@ -158,7 +158,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
158 \ 158 \
159 mutex_lock(&data->update_lock); \ 159 mutex_lock(&data->update_lock); \
160 data->value = TEMP_TO_REG(val); \ 160 data->value = TEMP_TO_REG(val); \
161 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ 161 i2c_smbus_write_word_swapped(client, reg, data->value); \
162 mutex_unlock(&data->update_lock); \ 162 mutex_unlock(&data->update_lock); \
163 return count; \ 163 return count; \
164} 164}
@@ -194,8 +194,8 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
194 194
195 mutex_lock(&data->update_lock); 195 mutex_lock(&data->update_lock);
196 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; 196 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
197 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, 197 i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST,
198 swab16(TEMP_TO_REG(data->temp1_hyst))); 198 TEMP_TO_REG(data->temp1_hyst));
199 mutex_unlock(&data->update_lock); 199 mutex_unlock(&data->update_lock);
200 return count; 200 return count;
201} 201}
diff --git a/drivers/hwmon/max16065.c b/drivers/hwmon/max16065.c
index dd2d7b9620c2..385886a4f224 100644
--- a/drivers/hwmon/max16065.c
+++ b/drivers/hwmon/max16065.c
@@ -137,10 +137,10 @@ static int max16065_read_adc(struct i2c_client *client, int reg)
137{ 137{
138 int rv; 138 int rv;
139 139
140 rv = i2c_smbus_read_word_data(client, reg); 140 rv = i2c_smbus_read_word_swapped(client, reg);
141 if (unlikely(rv < 0)) 141 if (unlikely(rv < 0))
142 return rv; 142 return rv;
143 return ((rv & 0xff) << 2) | ((rv >> 14) & 0x03); 143 return rv >> 6;
144} 144}
145 145
146static struct max16065_data *max16065_update_device(struct device *dev) 146static struct max16065_data *max16065_update_device(struct device *dev)
diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c
index 1c8c9812f244..15398780cc00 100644
--- a/drivers/hwmon/sht21.c
+++ b/drivers/hwmon/sht21.c
@@ -83,25 +83,6 @@ static inline int sht21_rh_ticks_to_per_cent_mille(int ticks)
83} 83}
84 84
85/** 85/**
86 * sht21_read_word_data() - read word from register
87 * @client: I2C client device
88 * @reg: I2C command byte
89 *
90 * Returns value, negative errno on error.
91 */
92static inline int sht21_read_word_data(struct i2c_client *client, u8 reg)
93{
94 int ret = i2c_smbus_read_word_data(client, reg);
95 if (ret < 0)
96 return ret;
97 /*
98 * SMBus specifies low byte first, but the SHT21 returns MSB
99 * first, so we have to swab16 the values
100 */
101 return swab16(ret);
102}
103
104/**
105 * sht21_update_measurements() - get updated measurements from device 86 * sht21_update_measurements() - get updated measurements from device
106 * @client: I2C client device 87 * @client: I2C client device
107 * 88 *
@@ -119,12 +100,13 @@ static int sht21_update_measurements(struct i2c_client *client)
119 * maximum two measurements per second at 12bit accuracy shall be made. 100 * maximum two measurements per second at 12bit accuracy shall be made.
120 */ 101 */
121 if (time_after(jiffies, sht21->last_update + HZ / 2) || !sht21->valid) { 102 if (time_after(jiffies, sht21->last_update + HZ / 2) || !sht21->valid) {
122 ret = sht21_read_word_data(client, SHT21_TRIG_T_MEASUREMENT_HM); 103 ret = i2c_smbus_read_word_swapped(client,
104 SHT21_TRIG_T_MEASUREMENT_HM);
123 if (ret < 0) 105 if (ret < 0)
124 goto out; 106 goto out;
125 sht21->temperature = sht21_temp_ticks_to_millicelsius(ret); 107 sht21->temperature = sht21_temp_ticks_to_millicelsius(ret);
126 ret = sht21_read_word_data(client, 108 ret = i2c_smbus_read_word_swapped(client,
127 SHT21_TRIG_RH_MEASUREMENT_HM); 109 SHT21_TRIG_RH_MEASUREMENT_HM);
128 if (ret < 0) 110 if (ret < 0)
129 goto out; 111 goto out;
130 sht21->humidity = sht21_rh_ticks_to_per_cent_mille(ret); 112 sht21->humidity = sht21_rh_ticks_to_per_cent_mille(ret);
diff --git a/drivers/hwmon/smm665.c b/drivers/hwmon/smm665.c
index 425df5bccd45..411638181fd8 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
246static struct smm665_data *smm665_update_device(struct device *dev) 239static struct smm665_data *smm665_update_device(struct device *dev)
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 5bd194968801..643aa8c94535 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -55,19 +55,6 @@ struct tmp102 {
55 int temp[3]; 55 int temp[3];
56}; 56};
57 57
58/* SMBus specifies low byte first, but the TMP102 returns high byte first,
59 * so we have to swab16 the values */
60static inline int tmp102_read_reg(struct i2c_client *client, u8 reg)
61{
62 int result = i2c_smbus_read_word_data(client, reg);
63 return result < 0 ? result : swab16(result);
64}
65
66static inline int tmp102_write_reg(struct i2c_client *client, u8 reg, u16 val)
67{
68 return i2c_smbus_write_word_data(client, reg, swab16(val));
69}
70
71/* convert left adjusted 13-bit TMP102 register value to milliCelsius */ 58/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
72static inline int tmp102_reg_to_mC(s16 val) 59static inline int tmp102_reg_to_mC(s16 val)
73{ 60{
@@ -94,7 +81,8 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client)
94 if (time_after(jiffies, tmp102->last_update + HZ / 3)) { 81 if (time_after(jiffies, tmp102->last_update + HZ / 3)) {
95 int i; 82 int i;
96 for (i = 0; i < ARRAY_SIZE(tmp102->temp); ++i) { 83 for (i = 0; i < ARRAY_SIZE(tmp102->temp); ++i) {
97 int status = tmp102_read_reg(client, tmp102_reg[i]); 84 int status = i2c_smbus_read_word_swapped(client,
85 tmp102_reg[i]);
98 if (status > -1) 86 if (status > -1)
99 tmp102->temp[i] = tmp102_reg_to_mC(status); 87 tmp102->temp[i] = tmp102_reg_to_mC(status);
100 } 88 }
@@ -130,8 +118,8 @@ static ssize_t tmp102_set_temp(struct device *dev,
130 118
131 mutex_lock(&tmp102->lock); 119 mutex_lock(&tmp102->lock);
132 tmp102->temp[sda->index] = val; 120 tmp102->temp[sda->index] = val;
133 status = tmp102_write_reg(client, tmp102_reg[sda->index], 121 status = i2c_smbus_write_word_swapped(client, tmp102_reg[sda->index],
134 tmp102_mC_to_reg(val)); 122 tmp102_mC_to_reg(val));
135 mutex_unlock(&tmp102->lock); 123 mutex_unlock(&tmp102->lock);
136 return status ? : count; 124 return status ? : count;
137} 125}
@@ -178,18 +166,19 @@ static int __devinit tmp102_probe(struct i2c_client *client,
178 } 166 }
179 i2c_set_clientdata(client, tmp102); 167 i2c_set_clientdata(client, tmp102);
180 168
181 status = tmp102_read_reg(client, TMP102_CONF_REG); 169 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
182 if (status < 0) { 170 if (status < 0) {
183 dev_err(&client->dev, "error reading config register\n"); 171 dev_err(&client->dev, "error reading config register\n");
184 goto fail_free; 172 goto fail_free;
185 } 173 }
186 tmp102->config_orig = status; 174 tmp102->config_orig = status;
187 status = tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONFIG); 175 status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
176 TMP102_CONFIG);
188 if (status < 0) { 177 if (status < 0) {
189 dev_err(&client->dev, "error writing config register\n"); 178 dev_err(&client->dev, "error writing config register\n");
190 goto fail_restore_config; 179 goto fail_restore_config;
191 } 180 }
192 status = tmp102_read_reg(client, TMP102_CONF_REG); 181 status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
193 if (status < 0) { 182 if (status < 0) {
194 dev_err(&client->dev, "error reading config register\n"); 183 dev_err(&client->dev, "error reading config register\n");
195 goto fail_restore_config; 184 goto fail_restore_config;
@@ -222,7 +211,8 @@ static int __devinit tmp102_probe(struct i2c_client *client,
222fail_remove_sysfs: 211fail_remove_sysfs:
223 sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); 212 sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group);
224fail_restore_config: 213fail_restore_config:
225 tmp102_write_reg(client, TMP102_CONF_REG, tmp102->config_orig); 214 i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
215 tmp102->config_orig);
226fail_free: 216fail_free:
227 kfree(tmp102); 217 kfree(tmp102);
228 218
@@ -240,10 +230,10 @@ static int __devexit tmp102_remove(struct i2c_client *client)
240 if (tmp102->config_orig & TMP102_CONF_SD) { 230 if (tmp102->config_orig & TMP102_CONF_SD) {
241 int config; 231 int config;
242 232
243 config = tmp102_read_reg(client, TMP102_CONF_REG); 233 config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
244 if (config >= 0) 234 if (config >= 0)
245 tmp102_write_reg(client, TMP102_CONF_REG, 235 i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
246 config | TMP102_CONF_SD); 236 config | TMP102_CONF_SD);
247 } 237 }
248 238
249 kfree(tmp102); 239 kfree(tmp102);
@@ -257,12 +247,12 @@ static int tmp102_suspend(struct device *dev)
257 struct i2c_client *client = to_i2c_client(dev); 247 struct i2c_client *client = to_i2c_client(dev);
258 int config; 248 int config;
259 249
260 config = tmp102_read_reg(client, TMP102_CONF_REG); 250 config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
261 if (config < 0) 251 if (config < 0)
262 return config; 252 return config;
263 253
264 config |= TMP102_CONF_SD; 254 config |= TMP102_CONF_SD;
265 return tmp102_write_reg(client, TMP102_CONF_REG, config); 255 return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
266} 256}
267 257
268static int tmp102_resume(struct device *dev) 258static int tmp102_resume(struct device *dev)
@@ -270,12 +260,12 @@ static int tmp102_resume(struct device *dev)
270 struct i2c_client *client = to_i2c_client(dev); 260 struct i2c_client *client = to_i2c_client(dev);
271 int config; 261 int config;
272 262
273 config = tmp102_read_reg(client, TMP102_CONF_REG); 263 config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
274 if (config < 0) 264 if (config < 0)
275 return config; 265 return config;
276 266
277 config &= ~TMP102_CONF_SD; 267 config &= ~TMP102_CONF_SD;
278 return tmp102_write_reg(client, TMP102_CONF_REG, config); 268 return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
279} 269}
280 270
281static const struct dev_pm_ops tmp102_dev_pm_ops = { 271static const struct dev_pm_ops tmp102_dev_pm_ops = {
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index eed43a008be1..65b685e2c7b7 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1245,17 +1245,17 @@ w83781d_read_value_i2c(struct w83781d_data *data, u16 reg)
1245 /* convert from ISA to LM75 I2C addresses */ 1245 /* convert from ISA to LM75 I2C addresses */
1246 switch (reg & 0xff) { 1246 switch (reg & 0xff) {
1247 case 0x50: /* TEMP */ 1247 case 0x50: /* TEMP */
1248 res = swab16(i2c_smbus_read_word_data(cl, 0)); 1248 res = i2c_smbus_read_word_swapped(cl, 0);
1249 break; 1249 break;
1250 case 0x52: /* CONFIG */ 1250 case 0x52: /* CONFIG */
1251 res = i2c_smbus_read_byte_data(cl, 1); 1251 res = i2c_smbus_read_byte_data(cl, 1);
1252 break; 1252 break;
1253 case 0x53: /* HYST */ 1253 case 0x53: /* HYST */
1254 res = swab16(i2c_smbus_read_word_data(cl, 2)); 1254 res = i2c_smbus_read_word_swapped(cl, 2);
1255 break; 1255 break;
1256 case 0x55: /* OVER */ 1256 case 0x55: /* OVER */
1257 default: 1257 default:
1258 res = swab16(i2c_smbus_read_word_data(cl, 3)); 1258 res = i2c_smbus_read_word_swapped(cl, 3);
1259 break; 1259 break;
1260 } 1260 }
1261 } 1261 }
@@ -1289,10 +1289,10 @@ w83781d_write_value_i2c(struct w83781d_data *data, u16 reg, u16 value)
1289 i2c_smbus_write_byte_data(cl, 1, value & 0xff); 1289 i2c_smbus_write_byte_data(cl, 1, value & 0xff);
1290 break; 1290 break;
1291 case 0x53: /* HYST */ 1291 case 0x53: /* HYST */
1292 i2c_smbus_write_word_data(cl, 2, swab16(value)); 1292 i2c_smbus_write_word_swapped(cl, 2, value);
1293 break; 1293 break;
1294 case 0x55: /* OVER */ 1294 case 0x55: /* OVER */
1295 i2c_smbus_write_word_data(cl, 3, swab16(value)); 1295 i2c_smbus_write_word_swapped(cl, 3, value);
1296 break; 1296 break;
1297 } 1297 }
1298 } 1298 }