diff options
author | Krzysztof Adamski <krzysztof.adamski@nokia.com> | 2021-10-12 11:26:55 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2021-10-12 07:25:34 -0700 |
commit | 5e3dbeac3795d60d9dc182abe6d0130a2a00142c (patch) | |
tree | 714e58f65be00c22e8379aee04cb7b6104715543 /drivers/hwmon/tmp421.c | |
parent | beee7890c36320fe08d9cce82afa1db848360bfb (diff) | |
download | linux-stable-5e3dbeac3795d60d9dc182abe6d0130a2a00142c.tar.gz linux-stable-5e3dbeac3795d60d9dc182abe6d0130a2a00142c.tar.bz2 linux-stable-5e3dbeac3795d60d9dc182abe6d0130a2a00142c.zip |
hwmon: (tmp421) introduce a channel struct
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@nokia.com>
Link: https://lore.kernel.org/r/baf34d95983a6b58a3e39e4c098e5979e541572e.1634029538.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/tmp421.c')
-rw-r--r-- | drivers/hwmon/tmp421.c | 14 |
1 files 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; |