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]
Message-ID: <545dcd1d-886f-b3d5-962f-b7f2bb7f7bfa@alliedtelesis.co.nz>
Date:   Tue, 18 Apr 2023 22:13:55 +0000
From:   Chris Packham <Chris.Packham@...iedtelesis.co.nz>
To:     "jdelvare@...e.com" <jdelvare@...e.com>,
        "linux@...ck-us.net" <linux@...ck-us.net>,
        "manio@...boo.net" <manio@...boo.net>
CC:     "linux-hwmon@...r.kernel.org" <linux-hwmon@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] hwmon: (adt7475) Handle DT unaware platforms


On 19/04/23 10:01, Chris Packham wrote:
> Configuring the pwm polarity via the adi,pwm-active-state property is an
> optional feature. On DT aware platforms of_property_read_u32_array()
> returns -EINVAL when the property is absent this is checked for and the
> driver probe continues without issue.
>
> On DT unaware platfroms of_property_read_u32_array() returns -ENOSYS
> which caused the driver probe to dev_warn(). Update the code to deal
> with -ENOSYS so that the dev_warn() only occurs when there is a genuine
> issue.
>
> Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output")
> Reported-by: Mariusz Białończyk <manio@...boo.net>
> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> ---
>   drivers/hwmon/adt7475.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> index 6e4c92b500b8..af906eee480e 100644
> --- a/drivers/hwmon/adt7475.c
> +++ b/drivers/hwmon/adt7475.c
> @@ -1607,6 +1607,13 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client)
>   	ret = of_property_read_u32_array(client->dev.of_node,
>   					 "adi,pwm-active-state", states,
>   					 ARRAY_SIZE(states));
> +	/*
> +	 * -EINVAL indicates that the property is absent, -ENOSYS indicates
> +	 * that the platform lacks DT awareness. Neither of these are errors
> +	 * for the optional pwm polarity support.
> +	 */
> +	if (ret == -EINVAL || ret == -ENOSYS)
> +		return 0;
I was looking around for why there weren't more checks of -ENOSYS and I 
suspect the answer is I should be using device_property_read_u32_array() 
instead. With the indirection I'm not 100% sure that I'll actually get 
the -EINVAL on a DT unaware platform, can anyone confirm this?
>   	if (ret)
>   		return ret;
>   
> @@ -1741,7 +1748,7 @@ static int adt7475_probe(struct i2c_client *client)
>   		adt7475_read_pwm(client, i);
>   
>   	ret = adt7475_set_pwm_polarity(client);
> -	if (ret && ret != -EINVAL)
> +	if (ret)
>   		dev_warn(&client->dev, "Error configuring pwm polarity\n");
>   
>   	/* Start monitoring */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ