This is a preparatory change. Upcoming patches will introduce more per-channel parameters so it's worth organizing them into a struct. Signed-off-by: Krzysztof Adamski <krzysztof.adamski@xxxxxxxxx> --- drivers/hwmon/tmp421.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index 356c96c3588b..707310d616a4 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c @@ -87,6 +87,10 @@ static const struct of_device_id __maybe_unused tmp421_of_match[] = { }; MODULE_DEVICE_TABLE(of, tmp421_of_match); +struct tmp421_channel { + s16 temp; +}; + struct tmp421_data { struct i2c_client *client; struct mutex update_lock; @@ -98,7 +102,7 @@ struct tmp421_data { unsigned long last_updated; unsigned long channels; u8 config; - s16 temp[MAX_CHANNELS]; + struct tmp421_channel channel[MAX_CHANNELS]; }; static int temp_from_raw(u16 reg, bool extended) @@ -133,12 +137,12 @@ static int tmp421_update_device(struct tmp421_data *data) ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]); if (ret < 0) goto exit; - data->temp[i] = ret << 8; + data->channel[i].temp = ret << 8; ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]); if (ret < 0) goto exit; - data->temp[i] |= ret; + data->channel[i].temp |= ret; } data->last_updated = jiffies; data->valid = true; @@ -167,7 +171,7 @@ static int tmp421_read(struct device *dev, enum hwmon_sensor_types type, switch (attr) { case hwmon_temp_input: - *val = temp_from_raw(tmp421->temp[channel], + *val = temp_from_raw(tmp421->channel[channel].temp, tmp421->config & TMP421_CONFIG_RANGE); return 0; case hwmon_temp_fault: @@ -175,7 +179,7 @@ static int tmp421_read(struct device *dev, enum hwmon_sensor_types type, * Any of OPEN or /PVLD bits indicate a hardware mulfunction * and the conversion result may be incorrect */ - *val = !!(tmp421->temp[channel] & 0x03); + *val = !!(tmp421->channel[channel].temp & 0x03); return 0; default: return -EOPNOTSUPP; -- 2.31.1