lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 14 Jun 2024 06:34:46 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Naresh Solanki <naresh.solanki@...ements.com>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/2] hwmon: (max6639) : Add hwmon attributes for fan
 and pwm

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@...ements.com>
> ---
> 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ