Re: [PATCH v2 3/3] platform/x86: dasharo-acpi: Add EC fan curve support
From: Michał Kopeć
Date: Thu Nov 26 2026 - 11:56:04 EST
On Mon, Nov 23, 2026 at 11:58:21AM +0100, Filip Gołaś wrote:
Hi Filip,
Thanks for the V2, a few comments below:
> @@ -78,6 +81,7 @@ struct dasharo_capability {
>
> struct dasharo_data {
> struct platform_device *pdev;
> + struct mutex curve_lock;
The hwmon core already serializes the ->read()/->write() callbacks on
its own lock, and exports hwmon_lock()/hwmon_unlock() (plus a
guard(hwmon_lock)) for attributes in extra groups. Could we use that
instead of a private mutex? It would drop devm_mutex_init(), and it
would also serialize the curve attributes against pwmN_enable/pwmN,
which go through the core. The show callbacks currently take no lock
at all.
> + val /= MILLIDEGREE_PER_DEGREE;
Nit: DIV_ROUND_CLOSEST() would be more usual for hwmon. Negative
values are already rejected above, so it's safe here.
> +#define DASHARO_POINT_ATTRS(ch, pt) \
> + static SENSOR_DEVICE_ATTR_2_RW(pwm##ch##_auto_point##pt##_temp, curve_point_temp, \
> + (ch) - 1, (pt) - 1); \
> + static SENSOR_DEVICE_ATTR_2_RW(pwm##ch##_auto_point##pt##_pwm, curve_point_pwm, \
> + ch - 1, pt - 1)
The parentheses are inconsistent between the two lines; please use
(ch) - 1, (pt) - 1 in both.
> +DASHARO_POINT_ATTRS(1, 1);
> +DASHARO_POINT_ATTRS(1, 2);
> +DASHARO_POINT_ATTRS(1, 3);
> +DASHARO_POINT_ATTRS(1, 4);
> +DASHARO_POINT_ATTRS(2, 1);
> +DASHARO_POINT_ATTRS(2, 2);
> +DASHARO_POINT_ATTRS(2, 3);
> +DASHARO_POINT_ATTRS(2, 4);
The attributes only exist for pwm1 and pwm2, but the driver supports
up to 24 PWM channels. If firmware reports FAN_POINTS for a fan on
pwm3 or above, it silently gets no curve attributes. Please mention
this limit in the commit message, or generate the attributes for all
channels if that's not too much trouble.
Thanks,
Michał