diff options
Diffstat (limited to 'drivers/hwmon/ds1621.c')
| -rw-r--r-- | drivers/hwmon/ds1621.c | 24 |
1 files changed, 3 insertions, 21 deletions
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. */ | ||
| 86 | static 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 | |||
| 96 | static 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 | |||
| 101 | static void ds1621_init_client(struct i2c_client *client) | 83 | static 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 | } |
