Re: [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages
From: Joshua Crofts
Date: Thu Nov 26 2026 - 08:32:01 EST
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