Re: [PATCH v5 2/2] hwmon: (max6639) : Add hwmon attributes for fan and pwm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 14, 2024 at 11:25:31AM +0530, Naresh Solanki wrote:
> Add attribute for fan & pwm i.e.,
> fanY_pulse
> pwmY_freq
> 
> Signed-off-by: Naresh Solanki <naresh.solanki@xxxxxxxxxxxxx>
> ---
> Changes in V5:
> - Remove unnecessary IS_ERR check.
> - Add mutex
> ---
>  drivers/hwmon/max6639.c | 90 +++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 86 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
> index 45ed629c6af9..091a4a0abd27 100644
> --- a/drivers/hwmon/max6639.c
> +++ b/drivers/hwmon/max6639.c
> @@ -76,6 +76,7 @@ static const unsigned int freq_table[] = { 20, 33, 50, 100, 5000, 8333, 12500,
>   */
>  struct max6639_data {
>  	struct regmap *regmap;
> +	struct mutex update_lock;
>  
>  	/* Register values initialized only once */
>  	u8 ppr[MAX6639_NUM_CHANNELS];	/* Pulses per rotation 0..3 for 1..4 ppr */
> @@ -232,6 +233,9 @@ static int max6639_read_fan(struct device *dev, u32 attr, int channel,
>  			return res;
>  		*fan_val = !!(val & BIT(1 - channel));
>  		return 0;
> +	case hwmon_fan_pulses:
> +		*fan_val = data->ppr[channel];
> +		return 0;
>  	default:
>  		return -EOPNOTSUPP;
>  	}
> @@ -243,6 +247,33 @@ static int max6639_set_ppr(struct max6639_data *data, int channel, u8 ppr)
>  	return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), ppr-- << 6);
>  }
>  
> +static int max6639_write_fan(struct device *dev, u32 attr, int channel,
> +			     long val)
> +{
> +	struct max6639_data *data = dev_get_drvdata(dev);
> +	int err;
> +
> +	switch (attr) {
> +	case hwmon_fan_pulses:
> +		if (val <= 0 || val > 5)
> +			return -EINVAL;
> +

Testing max6639 ...
Out of range value accepted writing into fan1_pulses: val=5 max=4
Out of range value accepted writing into fan2_pulses: val=5 max=4

Valid range is 1..4.

No need to resend, I'll fix that up and apply.

Thanks,
Guenter




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux