diff options
Diffstat (limited to 'drivers/hwmon/ds620.c')
-rw-r--r-- | drivers/hwmon/ds620.c | 42 |
1 files changed, 10 insertions, 32 deletions
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 | */ | ||
83 | static 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 | |||
93 | static 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 | |||
98 | static void ds620_init_client(struct i2c_client *client) | 78 | static 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 | } |