Re: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
From: Thomas Weißschuh
Date: Wed Jan 21 2026 - 16:41:45 EST
On 2026-01-21 09:08:26+0000, Tzung-Bi Shih wrote:
> On Sun, Jan 18, 2026 at 10:45:56AM +0100, Thomas Weißschuh wrote:
> > @@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
> > u32 attr, int channel)
> > {
> > const struct cros_ec_hwmon_priv *priv = data;
> > + u16 speed;
> >
> > if (type == hwmon_fan) {
> > + if (attr == hwmon_fan_target &&
> > + cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) == -EOPNOTSUPP)
>
> [v2 4/4] patch uses is_cros_ec_cmd_available() for the purpose. Can't it
> also use here?
That is somewhat intentional. The code in patch 4 is executed many
times, so caching the result is faster. The code here is only executed
once. Calling the accessor instead of using is_cros_ec_cmd_available()
makes sure that we test for the correct command and version, without
needing another, long CROS_EC_HWMON_*_VERSION define.
Thomas