Re: [hwmon PATCH v3 6/6] hwmon: (adt7470) Use cached PWM frequency value

Guenter Roeck <[email protected]>
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/26/26 20:34, Luiz Angelo Daros de Luca wrote:
> adt7470_pwm_read() currently ignores failures returned by
> pwm1_freq_get(). If the register read fails, the negative error code is
> returned through *val while the function itself reports success,
> potentially exposing a negative PWM frequency through sysfs.
> 
> Fix this by using the cached PWM frequency maintained by the driver,
> eliminating the register access from the read path.
> 
> Apart from the corrected error propagation and using the cached value,
> no functional change is intended.
> 

An alternative might be to use regmap for caching and drop all driver-internal
caching. I have done that for other drivers; typically it simplifies the code,
sometimes significantly, since the update_device() function is no longer needed.
Something to consider for later, maybe.

Thanks,
Guenter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.