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: <20230924173418.4d83ac04@jic23-huawei>
Date:   Sun, 24 Sep 2023 17:34:18 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     alisadariana@...il.com
Cc:     Alisa-Dariana Roman <alisa.roman@...log.com>,
        stable@...r.kernel.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
Subject: Re: [PATCH v2] iio: adc: ad7192: Correct reference voltage

On Sun, 24 Sep 2023 18:21:48 +0300
alisadariana@...il.com wrote:

> From: Alisa-Dariana Roman <alisa.roman@...log.com>
> 
> The avdd and the reference voltage are two different sources but the
> reference voltage was assigned according to the avdd supply.
> 
> Add vref regulator structure and set the reference voltage according to
> the vref supply from the devicetree.
> 
> In case vref supply is missing, reference voltage is set according to
> the avdd supply for compatibility with old devicetrees.
> 
> Fixes: b581f748cce0 ("staging: iio: adc: ad7192: move out of staging")
> Signed-off-by: Alisa-Dariana Roman <alisa.roman@...log.com>
> Cc: stable@...r.kernel.org
Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan

> ---
> v1 -> v2
> 	- use dev_err_probe()
> 	Link: https://lore.kernel.org/lkml/20230923225827.75681-1-alisadariana@gmail.com/
> 
>  drivers/iio/adc/ad7192.c | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
> index 69d1103b9508..b64fd365f83f 100644
> --- a/drivers/iio/adc/ad7192.c
> +++ b/drivers/iio/adc/ad7192.c
> @@ -177,6 +177,7 @@ struct ad7192_chip_info {
>  struct ad7192_state {
>  	const struct ad7192_chip_info	*chip_info;
>  	struct regulator		*avdd;
> +	struct regulator		*vref;
>  	struct clk			*mclk;
>  	u16				int_vref_mv;
>  	u32				fclk;
> @@ -1008,10 +1009,30 @@ static int ad7192_probe(struct spi_device *spi)
>  	if (ret)
>  		return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n");
>  
> -	ret = regulator_get_voltage(st->avdd);
> -	if (ret < 0) {
> -		dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
> -		return ret;
> +	st->vref = devm_regulator_get_optional(&spi->dev, "vref");
> +	if (IS_ERR(st->vref)) {
> +		if (PTR_ERR(st->vref) != -ENODEV)
> +			return PTR_ERR(st->vref);
> +
> +		ret = regulator_get_voltage(st->avdd);
> +		if (ret < 0)
> +			return dev_err_probe(&spi->dev, ret,
> +					     "Device tree error, AVdd voltage undefined\n");
> +	} else {
> +		ret = regulator_enable(st->vref);
> +		if (ret) {
> +			dev_err(&spi->dev, "Failed to enable specified Vref supply\n");
> +			return ret;
> +		}
> +
> +		ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->vref);
> +		if (ret)
> +			return ret;
> +
> +		ret = regulator_get_voltage(st->vref);
> +		if (ret < 0)
> +			return dev_err_probe(&spi->dev, ret,
> +					     "Device tree error, Vref voltage undefined\n");
>  	}
>  	st->int_vref_mv = ret / 1000;
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ