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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vciw_ivdKFsqo=FML64zUL_cDCzjuhmdVC3V_Whnatqwg@mail.gmail.com>
Date: Mon, 28 Apr 2025 09:42:18 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Jonathan Santos <Jonathan.Santos@...log.com>
Cc: 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, jonath4nns@...il.com, 
	dlechner@...libre.com
Subject: Re: [PATCH v6 05/11] iio: adc: ad7768-1: add regulator to control VCM output

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?

>  #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.

> +       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.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ