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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <15f4c51c-3f7d-4e93-9c3a-71ac1d626463@roeck-us.net>
Date: Sun, 21 Jul 2024 20:53:32 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Chris Packham <chris.packham@...iedtelesis.co.nz>, jdelvare@...e.com,
 robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org, ukleinek@...nel.org
Cc: linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org
Subject: Re: [PATCH v6 3/3] hwmon: (adt7475) Add support for configuring
 initial PWM state

On 7/21/24 17:58, Chris Packham wrote:
> By default the PWM duty cycle in hardware is 100%. On some systems this
> can cause unwanted fan noise. Add the ability to specify the fan
> connections and initial state of the PWMs via device properties.
> 
> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> ---
> 
> Notes:
>      Changes in v6:
>      - Use do_div() instead of plain /
>      - Use a helper function to avoid repetition between the of and non-of
>        code paths.
>      Changes in v5:
>      - Deal with PWM frequency and duty cycle being specified in nanoseconds
>      Changes in v4:
>      - Support DT and ACPI fwnodes
>      - Put PWM into manual mode
>      Changes in v3:
>      - Use the pwm provider/consumer bindings
>      Changes in v2:
>      - Use correct device property string for frequency
>      - Allow -EINVAL and only warn on error
>      - Use a frequency of 0 to indicate that the hardware should be left as-is
> 
>   drivers/hwmon/adt7475.c | 130 ++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 130 insertions(+)
> 
> diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> index 4224ffb30483..fc5605d34f36 100644
> --- a/drivers/hwmon/adt7475.c
> +++ b/drivers/hwmon/adt7475.c
> @@ -21,6 +21,8 @@
>   #include <linux/of.h>
>   #include <linux/util_macros.h>
>   
> +#include <dt-bindings/pwm/pwm.h>
> +
>   /* Indexes for the sysfs hooks */
>   
>   #define INPUT		0
> @@ -1662,6 +1664,130 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client)
>   	return 0;
>   }
>   
> +struct adt7475_pwm_config {
> +	int index;
> +	int freq;
> +	int flags;
> +	int duty;
> +};
> +
> +static int _adt7475_pwm_properties_parse_args(u32 args[4], struct adt7475_pwm_config *cfg)
> +{
> +	unsigned long freq_hz;
> +	unsigned long duty;
> +
> +	if (args[1] == 0)
> +		return -EINVAL;
> +
> +	freq_hz = 1000000000UL;
> +	do_div(freq_hz, args[1]);
> +	duty = 255 * args[3];
> +	do_div(duty, args[1]);
> +

Gues I am a bit at loss here, just as 0-day. Why use do_div ? It is only needed
for 64-bit divide operations.

Thanks,
Guenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ