Re: [hwmon PATCH v3 6/6] hwmon: (adt7470) Use cached PWM frequency value
| Newsgroups | org.kernel.vger.linux-hwmon |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incorrect PWM frequency is cached in `pwm1_freq_set()` for high frequencies. -- --- Patch [6]: [hwmon PATCH v3 6/6] hwmon: (adt7470) Use cached PWM frequency value --- commit 1d5eabde22a3c2244581f951eb2060da34244bbe Author: Luiz Angelo Daros de Luca <[email protected]> hwmon: (adt7470) Use cached PWM frequency value This commit updates the driver to use a cached PWM frequency in the read path instead of querying the hardware. It aims to prevent exposing negative error codes through sysfs if the register read fails. > diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c > index f1150f0fe2172..405eda900650f 100644 > --- a/drivers/hwmon/adt7470.c > +++ b/drivers/hwmon/adt7470.c [ ... ] > @@ -817,6 +818,10 @@ static int pwm1_freq_set(struct device *dev, long freq) > err = regmap_update_bits(data->regmap, ADT7470_REG_CFG_2, > ADT7470_FREQ_MASK, > index << ADT7470_FREQ_SHIFT); > + if (err < 0) > + goto out; > + > + data->pwm_freq = adt7470_freq_map[index]; [Severity: Medium] Is the correct index used for caching the frequency here? Looking at pwm1_freq_set(), when setting a high frequency like 1400Hz or 22500Hz, the initial index is resolved to 8 or 9. The code then modifies this by subtracting 8 (index -= 8) before updating the hardware registers. By using this modified index to update data->pwm_freq, does the driver end up caching 11Hz or 15Hz (indexes 0 and 1) instead of the requested high frequency? > out: > mutex_unlock(&data->lock); > -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6