diff mbox series

[03/16] hwmon: ina3221: Fix type incompatibility with non-macro find_closest

Message ID 20250515081332.151250-4-asoponar@taladin.ro
State New
Headers show
Series lib: Refactor find_closest() and find_closest_descending() from macros to lib functions | expand

Commit Message

Alexandru Soponar May 15, 2025, 8:13 a.m. UTC
The ina3221_conv_time array was previously declared as u16 but used with
find_closest(). With find_closest() now implemented as a function taking
signed int parameters instead of a macro, passing unsigned arrays causes
type incompatibility errors. This patch changes the array type from
u16 to int to ensure compatibility with the function signature and
prevent compilation errors.

Signed-off-by: Alexandru Soponar <asoponar@taladin.ro>
---
 drivers/hwmon/ina3221.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 1bf479a0f793..482ab8e53d5c 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -178,7 +178,7 @@  static inline int ina3221_summation_shunt_resistor(struct ina3221_data *ina)
 }
 
 /* Lookup table for Bus and Shunt conversion times in usec */
-static const u16 ina3221_conv_time[] = {
+static const int ina3221_conv_time[] = {
 	140, 204, 332, 588, 1100, 2116, 4156, 8244,
 };
 
@@ -192,7 +192,7 @@  static inline u32 ina3221_interval_ms_to_conv_time(u16 config, int interval)
 {
 	u32 channels = hweight16(config & INA3221_CONFIG_CHs_EN_MASK);
 	u32 samples_idx = INA3221_CONFIG_AVG(config);
-	u32 samples = ina3221_avg_samples[samples_idx];
+	int samples = ina3221_avg_samples[samples_idx];
 
 	/* Bisect the result to Bus and Shunt conversion times */
 	return DIV_ROUND_CLOSEST(interval * 1000 / 2, channels * samples);
@@ -204,8 +204,8 @@  static inline u32 ina3221_reg_to_interval_us(u16 config)
 	u32 channels = hweight16(config & INA3221_CONFIG_CHs_EN_MASK);
 	u32 vbus_ct_idx = INA3221_CONFIG_VBUS_CT(config);
 	u32 vsh_ct_idx = INA3221_CONFIG_VSH_CT(config);
-	u32 vbus_ct = ina3221_conv_time[vbus_ct_idx];
-	u32 vsh_ct = ina3221_conv_time[vsh_ct_idx];
+	int vbus_ct = ina3221_conv_time[vbus_ct_idx];
+	int vsh_ct = ina3221_conv_time[vsh_ct_idx];
 
 	/* Calculate total conversion time */
 	return channels * (vbus_ct + vsh_ct);