diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c index 8102b6851d3d..aec4adf98658 100644 --- a/drivers/hwmon/chipcap2.c +++ b/drivers/hwmon/chipcap2.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -260,8 +261,7 @@ static int cc2_write_reg(struct cc2_data *data, u8 reg, u16 val) if (ret < 0) goto disable; - cpu_to_be16s(&val); - ret = i2c_smbus_write_word_data(data->client, reg, val); + ret = i2c_smbus_write_word_swapped(data->client, reg, val); if (ret < 0) goto disable; @@ -311,7 +311,7 @@ static int cc2_read_reg(struct cc2_data *data, u8 reg, u16 *val) if (ret != CC2_EEPROM_DATA_LEN) return ret < 0 ? ret : -EIO; - *val = be16_to_cpup((__be16 *)&buf[1]); + *val = get_unaligned_be16(&buf[1]); return cc2_read_command_status(data->client); } @@ -351,10 +351,10 @@ static int cc2_data_fetch(struct i2c_client *client, switch (type) { case hwmon_humidity: - *val = cc2_rh_convert(be16_to_cpup((__be16 *)&data[0])); + *val = cc2_rh_convert(get_unaligned_be16(&data[0])); break; case hwmon_temp: - *val = cc2_temp_convert(be16_to_cpup((__be16 *)&data[2])); + *val = cc2_temp_convert(get_unaligned_be16(&data[2])); break; default: return -EINVAL;