diff options
author | Krzysztof Adamski <krzysztof.adamski@nokia.com> | 2021-09-24 11:39:06 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2021-10-12 07:22:40 -0700 |
commit | cae0233946c316884e4c40925c7d69b9221c02f9 (patch) | |
tree | 400bd3e54b7453e3ca68d17bf05c0252c20124a2 /drivers/hwmon/tmp421.c | |
parent | 0a4157196a5da25b28aa6840bcac553c925e5013 (diff) | |
download | linux-stable-cae0233946c316884e4c40925c7d69b9221c02f9.tar.gz linux-stable-cae0233946c316884e4c40925c7d69b9221c02f9.tar.bz2 linux-stable-cae0233946c316884e4c40925c7d69b9221c02f9.zip |
hwmon: (tmp421) introduce MAX_CHANNELS define
There are few places where the maximal number of channels is used define
the size of arrays but when raw number is used it is not clear that they
really related to this quantity.
This commit introduces MAX_CHANNELS define and uses it those places to
give some context to the number.
Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/abc1a213a25b890b799b35ad94bb543a2ade7fc8.1632473318.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 | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index b963a369c5ab..a4ac6e16d592 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c @@ -29,6 +29,7 @@ static const unsigned short normal_i2c[] = { 0x2a, 0x4c, 0x4d, 0x4e, 0x4f, enum chips { tmp421, tmp422, tmp423, tmp441, tmp442 }; +#define MAX_CHANNELS 4 /* The TMP421 registers */ #define TMP421_STATUS_REG 0x08 #define TMP421_CONFIG_REG_1 0x09 @@ -36,8 +37,8 @@ enum chips { tmp421, tmp422, tmp423, tmp441, tmp442 }; #define TMP421_MANUFACTURER_ID_REG 0xFE #define TMP421_DEVICE_ID_REG 0xFF -static const u8 TMP421_TEMP_MSB[4] = { 0x00, 0x01, 0x02, 0x03 }; -static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 }; +static const u8 TMP421_TEMP_MSB[MAX_CHANNELS] = { 0x00, 0x01, 0x02, 0x03 }; +static const u8 TMP421_TEMP_LSB[MAX_CHANNELS] = { 0x10, 0x11, 0x12, 0x13 }; /* Flags */ #define TMP421_CONFIG_SHUTDOWN 0x40 @@ -89,7 +90,7 @@ MODULE_DEVICE_TABLE(of, tmp421_of_match); struct tmp421_data { struct i2c_client *client; struct mutex update_lock; - u32 temp_config[5]; + u32 temp_config[MAX_CHANNELS + 1]; struct hwmon_channel_info temp_info; const struct hwmon_channel_info *info[2]; struct hwmon_chip_info chip; @@ -97,7 +98,7 @@ struct tmp421_data { unsigned long last_updated; unsigned long channels; u8 config; - s16 temp[4]; + s16 temp[MAX_CHANNELS]; }; static int temp_from_raw(u16 reg, bool extended) |