From: sashiko-bot@kernel.org
To: "Luiz Angelo Daros de Luca" <luizluca@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [hwmon PATCH v3 6/6] hwmon: (adt7470) Use cached PWM frequency value
Date: Mon, 27 Jul 2026 03:45:01 +0000 [thread overview]
Message-ID: <20260727034502.94A5D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-adt7470_thermalzone-v3-6-21424d550c3d@gmail.com>
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 <luizluca@gmail.com>
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/20260727-adt7470_thermalzone-v3-0-21424d550c3d@gmail.com?part=6
next prev parent reply other threads:[~2026-07-27 3:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 3:34 [hwmon PATCH v3 0/6] hwmon: (adt7470): Multiple fixes Luiz Angelo Daros de Luca
2026-07-27 3:34 ` [hwmon PATCH v3 1/6] hwmon: (adt7470) Fix fans stuck in manual mode on I2C errors Luiz Angelo Daros de Luca
2026-07-27 3:49 ` sashiko-bot
2026-07-27 3:34 ` [hwmon PATCH v3 2/6] hwmon: (adt7470) Fix cache updated before hardware write on I2C error Luiz Angelo Daros de Luca
2026-07-27 3:50 ` sashiko-bot
2026-07-27 5:03 ` Luiz Angelo Daros de Luca
2026-07-27 3:34 ` [hwmon PATCH v3 3/6] hwmon: (adt7470) Fix busy-loop and I2C flooding in update thread Luiz Angelo Daros de Luca
2026-07-27 3:49 ` sashiko-bot
2026-07-27 3:34 ` [hwmon PATCH v3 4/6] hwmon: (adt7470) Fix swapped PWM3 and PWM4 auto mode masks Luiz Angelo Daros de Luca
2026-07-27 3:46 ` sashiko-bot
2026-07-27 14:27 ` Guenter Roeck
2026-07-27 3:34 ` [hwmon PATCH v3 5/6] hwmon: (adt7470) Fix temperature alarm logic in hwmon_temp_read() Luiz Angelo Daros de Luca
2026-07-27 3:44 ` sashiko-bot
2026-07-27 4:29 ` Luiz Angelo Daros de Luca
2026-07-27 3:34 ` [hwmon PATCH v3 6/6] hwmon: (adt7470) Use cached PWM frequency value Luiz Angelo Daros de Luca
2026-07-27 3:45 ` sashiko-bot [this message]
2026-07-27 5:10 ` Luiz Angelo Daros de Luca
2026-07-27 14:33 ` Guenter Roeck
2026-07-27 3:44 ` [hwmon PATCH v3 0/6] hwmon: (adt7470): Multiple fixes Luiz Angelo Daros de Luca
2026-07-27 14:33 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727034502.94A5D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=luizluca@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox