[PATCH v2 5/7] hwmon: add driver for the hwmon parts of qnap-mcu devices

Guenter Roeck linux at roeck-us.net
Tue Jul 30 08:27:42 PDT 2024


On Sun, Jul 28, 2024 at 11:17:49PM +0200, Heiko Stuebner wrote:
> The MCU can be found on network-attached-storage devices made by QNAP
> and provides access to fan control including reading back its RPM as
> well as reading the temperature of the NAS case.
> 
> Signed-off-by: Heiko Stuebner <heiko at sntech.de>

Minor comment inline, in case you resend, otherwise

Acked-by: Guenter Roeck <linux at roeck-us.net>

> +static int qnap_mcu_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
> +				u32 attr, int channel, long val)
> +{
> +	struct qnap_mcu_hwmon *hwm = dev_get_drvdata(dev);
> +
> +	switch (attr) {
> +	case hwmon_pwm_input:
> +		if (val < 0 || val > 255)
> +			return -EINVAL;
> +
> +		if (val < hwm->pwm_min)
> +			val = hwm->pwm_min;
> +
> +		if (val > hwm->pwm_max)
> +			val = hwm->pwm_max;
> +
		val = clamp_val(val, hwm->pwm_min, hwm->pwm_max);

Guenter



More information about the linux-arm-kernel mailing list