Re: [PATCH v2 2/3] hwmon: (cros_ec) add PWM control over fans

From: Thomas Weißschuh
Date: Sat May 10 2025 - 03:50:55 EST


On 2025-05-05 10:59:06+0800, Sung-Chi Li wrote:
> On Sat, May 03, 2025 at 09:36:39AM +0200, Thomas Weißschuh wrote:
> > On 2025-05-02 13:34:46+0800, Sung-Chi Li via B4 Relay wrote:
> > > From: Sung-Chi Li <lschyi@xxxxxxxxxxxx>

<snip>

> > > static int cros_ec_hwmon_read_temp(struct cros_ec_device *cros_ec, u8 index, u8 *temp)
> > > {
> > > unsigned int offset;
> > > @@ -76,6 +114,8 @@ static int cros_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> > > struct cros_ec_hwmon_priv *priv = dev_get_drvdata(dev);
> > > int ret = -EOPNOTSUPP;
> > > u16 speed;
> > > + u8 control_method;
> > > + u8 pwm_value;
> >
> > Ordering.
> >
>
> I thought you are talking about only the u8 variables, or do you mean the
> ordering should be applied with different types (and the declarations of
> different types are mixed)?

The ordering was for the whole declaration block.
If you want to keep variables of the same type together, declare them in
a single line (and sort that).

<snip>

> > > +static int cros_ec_hwmon_resume(struct platform_device *pdev)
> > > +{
> > > + const struct cros_ec_hwmon_priv *priv = platform_get_drvdata(pdev);
> > > + size_t i;
> > > +
> > > + if (!priv->fan_control_supported)
> > > + return 0;
> > > +
> > > + /* EC sets fan control to auto after suspended, restore to settings before suspended. */
> > > + for (i = 0; i < EC_FAN_SPEED_ENTRIES; i++) {
> > > + if (!(priv->manual_fans & BIT(i)))
> > > + continue;
> > > +
> > > + /*
> > > + * Setting fan PWM value to EC will change the mode to manual for that fan in EC as
> > > + * well, so we do not need to issue a separate fan mode to manual call.
> > > + */
> > > + cros_ec_hwmon_set_fan_pwm_val(priv->cros_ec, i, priv->manual_fan_pwm_values[i]);
> >
> > Error handling?
> >
>
> I removed the error checking in the v2 version because after second thought, I
> think even if we failed at the i th fan, we should do our best to restore these
> fan settings, thus continuing on the (i+1) th fan and so on rather than stop the
> process immediately. Is adding a warning log for the failure sufficient?

A warning sounds good here.