[PATCH 2/4] hwmon: (adt7470) Add ADT7470_PWM_MAX macro

From: Luiz Angelo Daros de Luca

Date: Thu Jul 16 2026 - 17:22:15 EST


Instead of a magic 255, use a macro to refer to it.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@xxxxxxxxx>
---
drivers/hwmon/adt7470.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 664349756dc2..4ac292cd7f47 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -100,6 +100,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
#define ADT7470_REG_FAN_MAX(x) (ADT7470_REG_FAN_MAX_BASE_ADDR + ((x) * 2))

#define ADT7470_PWM_COUNT 4
+#define ADT7470_PWM_MAX 255
#define ADT7470_REG_PWM(x) (ADT7470_REG_PWM_BASE_ADDR + (x))
#define ADT7470_REG_PWM_MAX(x) (ADT7470_REG_PWM_MAX_BASE_ADDR + (x))
#define ADT7470_REG_PWM_MIN(x) (ADT7470_REG_PWM_MIN_BASE_ADDR + (x))
@@ -811,7 +812,7 @@ static int adt7470_pwm_write(struct device *dev, u32 attr, int channel, long val

switch (attr) {
case hwmon_pwm_input:
- val = clamp_val(val, 0, 255);
+ val = clamp_val(val, 0, ADT7470_PWM_MAX);
mutex_lock(&data->lock);
data->pwm[channel] = val;
err = regmap_write(data->regmap, ADT7470_REG_PWM(channel),
@@ -869,7 +870,7 @@ static ssize_t pwm_max_store(struct device *dev,
if (kstrtol(buf, 10, &temp))
return -EINVAL;

- temp = clamp_val(temp, 0, 255);
+ temp = clamp_val(temp, 0, ADT7470_PWM_MAX);

mutex_lock(&data->lock);
data->pwm_max[attr->index] = temp;
@@ -904,7 +905,7 @@ static ssize_t pwm_min_store(struct device *dev,
if (kstrtol(buf, 10, &temp))
return -EINVAL;

- temp = clamp_val(temp, 0, 255);
+ temp = clamp_val(temp, 0, ADT7470_PWM_MAX);

mutex_lock(&data->lock);
data->pwm_min[attr->index] = temp;

--
2.55.0