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: <ZHssDS57yx46RvFA@surfacebook>
Date:   Sat, 3 Jun 2023 15:03:25 +0300
From:   andy.shevchenko@...il.com
To:     fl.scratchpad@...il.com
Cc:     jic23@...nel.org, Lars-Peter Clausen <lars@...afoo.de>,
        Michael Hennerich <Michael.Hennerich@...log.com>,
        Alexandru Tachici <alexandru.tachici@...log.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>, linux-iio@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v3 3/5] iio: adc: ad7192: Use VRef instead of AVdd as
 reference voltage source

Tue, May 30, 2023 at 09:53:09AM +0200, fl.scratchpad@...il.com kirjoitti:
> From: Fabrizio Lamarque <fl.scratchpad@...il.com>
> 
> Add missing vref-supply and fix avdd-supply used as if it were vref.
> 
> AD7192 requires three independent voltage sources, digital supply (on
> pin DVdd), analog supply (on AVdd) and reference voltage (VRef on
> alternate pin pair REFIN1 or REFIN2).
> 
> Emit a warning message when AVdd is used in place of VRef for backwards
> compatibility.

...

> +	st->vref = devm_regulator_get_optional(&spi->dev, "vref");
> +	if (!IS_ERR(st->vref)) {
> +		ret = regulator_enable(st->vref);
> +		if (ret)
> +			return dev_err_probe(&spi->dev, ret,
> +					     "Failed to enable specified VRef supply\n");
> +
> +		ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->vref);
> +		if (ret)
> +			return ret;
> +	} else if (PTR_ERR(st->vref) != -ENODEV) {
> +		return PTR_ERR(st->vref);
> +	}

Wouldn't this be better?

	if (IS_ERR(st->vref)) {
		if (PTR_ERR(st->vref) != -ENODEV)
			return PTR_ERR(st->vref);
	} else {

...

>  	if (ret)
>  		return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n");
>  
> -	ret = regulator_get_voltage(st->avdd);
> +

One blank line is enough.

> +	if (!IS_ERR(st->vref)) {
> +		ret = regulator_get_voltage(st->vref);

Why negative conditional? Usual pattern is to check for errors first, so

	if (IS_ERR(st->vref)) {
		dev_warn(...);
		...
	} else {
		ret = regulator_get_voltage(st->vref);
	}

> +	} else {
> +		dev_warn(&spi->dev, "Using AVdd in place of VRef. Likely an old DTS\n");
> +		ret = regulator_get_voltage(st->avdd);
> +	}

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ