[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBKxFuKFYDWdDlh7@JSANTO12-L01.ad.analog.com>
Date: Wed, 30 Apr 2025 20:24:06 -0300
From: Jonathan Santos <jonath4nns@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Jonathan Santos <Jonathan.Santos@...log.com>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-gpio@...r.kernel.org, andy@...nel.org, nuno.sa@...log.com,
Michael.Hennerich@...log.com, marcelo.schmitt@...log.com,
jic23@...nel.org, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, marcelo.schmitt1@...il.com,
linus.walleij@...aro.org, brgl@...ev.pl, lgirdwood@...il.com,
broonie@...nel.org, dlechner@...libre.com
Subject: Re: [PATCH v6 05/11] iio: adc: ad7768-1: add regulator to control
VCM output
On 04/28, Andy Shevchenko wrote:
> On Mon, Apr 28, 2025 at 3:13 AM Jonathan Santos
> <Jonathan.Santos@...log.com> wrote:
> >
> > The VCM output voltage can be used as a common-mode voltage within the
> > amplifier preconditioning circuits external to the AD7768-1.
> >
> > This change allows the user to configure VCM output using the regulator
> > framework.
>
> ...
>
> > #include <linux/gpio/consumer.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
>
> Why?
>
I was using of_match_ptr() before, but forgot to remove it, sorry.
> > #include <linux/regmap.h>
> > #include <linux/regulator/consumer.h>
> > +#include <linux/regulator/driver.h>
>
> ...
>
> > +static int ad7768_vcm_enable(struct regulator_dev *rdev)
> > +{
> > + struct iio_dev *indio_dev = rdev_get_drvdata(rdev);
> > + struct ad7768_state *st = iio_priv(indio_dev);
> > + int ret, regval;
>
> > + if (!indio_dev)
> > + return -EINVAL;
>
> Isn't it a dead code? Or i.o.w. under which circumstances can this be true?
> Ditto for other functions with the same check.
>
Yes, you're right. Since I defined the driver data below, there was no
need for the check.
> > + if (!iio_device_claim_direct(indio_dev))
> > + return -EBUSY;
> > +
> > + /* To enable, set the last selected output */
> > + regval = AD7768_REG_ANALOG2_VCM(st->vcm_output_sel + 1);
> > + ret = regmap_update_bits(st->regmap, AD7768_REG_ANALOG2,
> > + AD7768_REG_ANALOG2_VCM_MSK, regval);
> > + iio_device_release_direct(indio_dev);
> > +
> > + return ret;
> > +}
>
> ...
>
> > + return clamp(val, 1, (int)rdev->desc->n_voltages) - 1;
>
> No explicit castings in min/max/clamp, please. This may lead to subtle
> mistakes. Also, don't forget to include minmax.h.
>
Okay, thanks.
> --
> With Best Regards,
> Andy Shevchenko
Powered by blists - more mailing lists