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]
Date: Mon, 3 Jun 2024 08:36:51 -0500
From: David Lechner <dlechner@...libre.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Marcelo Schmitt <marcelo.schmitt1@...il.com>, Nuno Sá
 <nuno.sa@...log.com>, Michael Hennerich <Michael.Hennerich@...log.com>,
 Mark Brown <broonie@...nel.org>, Liam Girdwood <lgirdwood@...il.com>,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/5] iio: adc: ad7192: use
 devm_regulator_get_enable_read_voltage

On 6/1/24 7:48 AM, Jonathan Cameron wrote:
> On Fri, 31 May 2024 16:19:32 -0500
> David Lechner <dlechner@...libre.com> wrote:
> 
>> This makes use of the new devm_regulator_get_enable_read_voltage()
>> function to reduce boilerplate code.
>>
>> Error messages have changed slightly since there are now fewer places
>> where we print an error. The rest of the logic of selecting which
>> supply to use as the reference voltage remains the same.
>>
>> Also 1000 is replaced by MILLI in a few places for consistency.
>>
>> Signed-off-by: David Lechner <dlechner@...libre.com>
> Ouch diff didn't like this one much and it is a bit hard to read.
> 
> One case where I think this has an unintended side effect.
> See below.
> 

...

>> @@ -1219,74 +1211,54 @@ static int ad7192_probe(struct spi_device *spi)
>>  	 * Newer firmware should provide a zero volt fixed supply if wired to
>>  	 * ground.
>>  	 */
>> -	aincom = devm_regulator_get_optional(&spi->dev, "aincom");
>> -	if (IS_ERR(aincom)) {
>> -		if (PTR_ERR(aincom) != -ENODEV)
>> -			return dev_err_probe(&spi->dev, PTR_ERR(aincom),
>> -					     "Failed to get AINCOM supply\n");
>> -
>> +	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "aincom");
>> +	if (ret == -ENODEV)
>>  		st->aincom_mv = 0;
>> -	} else {
>> -		ret = regulator_enable(aincom);
>> -		if (ret)
>> -			return dev_err_probe(&spi->dev, ret,
>> -					     "Failed to enable specified AINCOM supply\n");
>> +	else if (ret < 0)
>> +		return dev_err_probe(&spi->dev, ret, "Failed to get AINCOM voltage\n");
>> +	else
>> +		st->aincom_mv = ret / MILLI;
>>  
>> -		ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, aincom);
>> +	/* AVDD can optionally be used as reference voltage */
>> +	ret = devm_regulator_get_enable_read_voltage(&spi->dev, "avdd");
>> +	if (ret == -EINVAL) {
>> +		/*
>> +		 * We get -EINVAL if avdd is a supply with unknown voltage. We
>> +		 * still need to enable it since it is also a power supply.
>> +		 */
>> +		ret = devm_regulator_get_enable(&spi->dev, "avdd");
> 
> What happens if the entry simply isn't there in the DT.
> Previously I think the regulator framework would supply a stub whereas
> the devm_regulator_get_enable_read_voltage() returns -ENODEV so isn't
> caught by the handling and I think it should be.

Ah, yes so:

if (ret == -EINVAL || ret == -ENODEV) {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ