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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250219103307.GA22470@francesco-nb>
Date: Wed, 19 Feb 2025 11:33:07 +0100
From: Francesco Dolcini <francesco@...cini.it>
To: Quentin Schulz <quentin.schulz@...rry.de>
Cc: Francesco Dolcini <francesco@...cini.it>,
	Jean Delvare <jdelvare@...e.com>,
	Guenter Roeck <linux@...ck-us.net>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Farouk Bouabid <farouk.bouabid@...rry.de>,
	Francesco Dolcini <francesco.dolcini@...adex.com>,
	linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/2] hwmon: (amc6821) Add PWM polarity configuration
 with OF

Hello Quentin,

On Wed, Feb 19, 2025 at 11:08:43AM +0100, Quentin Schulz wrote:
> On 2/18/25 5:56 PM, Francesco Dolcini wrote:
> > From: Francesco Dolcini <francesco.dolcini@...adex.com>
> > 
> > Add support to configure the PWM-Out pin polarity based on a device
> > tree property.
> > 
> > Signed-off-by: Francesco Dolcini <francesco.dolcini@...adex.com>
> > ---
> >   drivers/hwmon/amc6821.c | 7 +++++--
> >   1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
> > index 1e3c6acd8974..1ea2d97eebca 100644
> > --- a/drivers/hwmon/amc6821.c
> > +++ b/drivers/hwmon/amc6821.c
> > @@ -845,7 +845,7 @@ static int amc6821_detect(struct i2c_client *client, struct i2c_board_info *info
> >   	return 0;
> >   }
> > -static int amc6821_init_client(struct amc6821_data *data)
> > +static int amc6821_init_client(struct i2c_client *client, struct amc6821_data *data)
> >   {
> >   	struct regmap *regmap = data->regmap;
> >   	int err;
> > @@ -864,6 +864,9 @@ static int amc6821_init_client(struct amc6821_data *data)
> >   		if (err)
> >   			return err;
> > +		if (of_property_read_bool(client->dev.of_node, "ti,pwm-inverted"))
> 
> I know that the AMC6821 is doing a lot of smart things, but this really
> tickled me. PWM controllers actually do support that already via
> PWM_POLARITY_INVERTED flag for example. See
> Documentation/devicetree/bindings/hwmon/adt7475.yaml which seems to be
> another HWMON driver which acts as a PWM controller. I'm not sure this is
> relevant, applicable or desired but I wanted to highlight this.

>From the DT binding point of view, it seems to implement the same I am
proposing here with adi,pwm-active-state property.

Do you have anything more specific in mind?

> 
> > +			pwminv = 1;
> > +
> 
> This is silently overriding the module parameter.
> 
> I don't think this is a good idea, at the very least not silently.

I was thinking at the same, and in the end I do have proposed this
solution in any case.

Let's look at the 2 use cases in which the DT property and the module
parameter are different.

## 1

module parameter pwminv=0
ti,pwm-inverted DT property present

=> we enable the PWM inversion

I think this is fair, if someone has a DT based system we need to assume
that the DT is correct. This is a HW configuration, not a module
parameter.

## 2

module parameter pwminv=1
ti,pwm-inverted DT property absent

=> we enable the PWM inversion

In this case the module parameter is overriding the DT. It means that
someone explicitly set pwminv=1 module parameter. I think is fair to
fulfill the module parameter request in this case, overriding the DT

> I would suggest to add some logic in the probe function to set this value
> and check its consistency.

With that said I can implement something around the lines you proposed,
if you still think is worth doing it. I would personally just keep the
priority on the module parameter over the DT and add an info print on what
is actually configured by the driver (not checking if they are
different).
	
Or I can just add a dev_info() telling the user about the actual PWM
polarity used, making this more transparent, without changing the logic
proposed here.

Francesco


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ