All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Crofts <crofts@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages
Date: Thu, 26 Nov 2026 14:31:51 +0100	[thread overview]
Message-ID: <3ec029d6-d53d-4cd9-8582-a15cfd3eb4d1@kernel.org> (raw)
In-Reply-To: <0723d51fa973f0204e1c436c08a784b7b1cca795.1795699121.git.mazziesaccount@gmail.com>

On 26-Nov-26 14:23, Matti Vaittinen wrote:

...

> diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c
> index 127ccc2c4a22..1d58bc1544a1 100644
> --- a/drivers/iio/dac/rohm-bd79703.c
> +++ b/drivers/iio/dac/rohm-bd79703.c
> @@ -41,7 +41,9 @@ static const struct regmap_config bd79703_regmap_config = {
>  /* Dynamic driver private data */
>  struct bd79703_data {
>  	struct regmap *regmap;
> -	int vfs;
> +	int vcc_mv;

_mV is the preferred style to denote SI unit variables.

> +	int vfs_mv;
> +	unsigned int num_vfs_chan;
>  };
>  
>  /* Static, IC type specific data for different variants */
> @@ -49,7 +51,11 @@ struct bd7970x_chip_data {
>  	const char *name;
>  	const struct iio_chan_spec *channels;
>  	int num_channels;
> -	bool has_vfs;
> +	/*
> +	 * Some ICs use VFS-pin for full-scale voltage for first N channels.
> +	 * We need to know these channels to get correct scale

Small nit, but missing period at the end.

> +	 */
> +	unsigned int num_vfs_chan;
>  };
>  

...

>  static int bd79703_probe(struct spi_device *spi)
> @@ -184,23 +206,26 @@ static int bd79703_probe(struct spi_device *spi)
>  				     "Failed to initialize Regmap\n");
>  
>  	/*
> -	 * BD79703 has a separate VFS pin, whereas the BD79700 and BD79701 use
> -	 * VCC for their full-scale output voltage.
> +	 * BD79702 and BD79703 have a separate VFS pin. On these ICs, the VFS
> +	 * pin provides the full-scale output voltage for half of the channels,
> +	 * and use VCC for the rest.
> +	 * The BD79700 and BD79701 use VCC for their full-scale output voltage
> +	 * for all of the channels.
>  	 */
> -	if (cd->has_vfs) {
> -		ret = devm_regulator_get_enable(dev, "vcc");
> -		if (ret)
> -			return dev_err_probe(dev, ret, "Failed to enable VCC\n");
> +	ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "Failed to enable VCC\n");
> +
> +	data->vcc_mv = ret / 1000;

Better to do ret / (MICRO / MILLI).

>  
> +	if (cd->num_vfs_chan > 0) {
>  		ret = devm_regulator_get_enable_read_voltage(dev, "vfs");
>  		if (ret < 0)
>  			return dev_err_probe(dev, ret, "Failed to get Vfs\n");
> -	} else {
> -		ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
> -		if (ret < 0)
> -			return dev_err_probe(dev, ret, "Failed to get VCC\n");
> +
> +		data->vfs_mv = ret / 1000;

Same here.

-- 
Kind regards,
Joshua Crofts


  reply	other threads:[~2026-11-26 13:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 13:23 [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages Matti Vaittinen
2026-11-26 13:31 ` Joshua Crofts [this message]
2026-11-27  6:34   ` Matti Vaittinen
2026-11-27 11:03     ` Andy Shevchenko
2026-11-27 11:46       ` Matti Vaittinen
2026-11-27 12:08         ` Andy Shevchenko
2026-11-27 15:57           ` Andy Shevchenko
2026-11-30  7:06             ` Matti Vaittinen
2026-11-30  7:01           ` Matti Vaittinen
2026-11-30 14:34             ` Andy Shevchenko
2026-11-28  3:53 ` Jonathan Cameron
2026-11-30  8:28   ` Matti Vaittinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ec029d6-d53d-4cd9-8582-a15cfd3eb4d1@kernel.org \
    --to=crofts@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.