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] [thread-next>] [day] [month] [year] [list]
Message-ID: <717d15c36fbd1a5c23526ac87bc9d66cd39c54d3.camel@gmail.com>
Date: Mon, 21 Oct 2024 13:15:19 +0200
From: Nuno Sá <noname.nuno@...il.com>
To: Julien Stephan <jstephan@...libre.com>, Lars-Peter Clausen
 <lars@...afoo.de>,  Michael Hennerich <Michael.Hennerich@...log.com>, Nuno
 Sá <nuno.sa@...log.com>, David Lechner	
 <dlechner@...libre.com>, Jonathan Cameron <jic23@...nel.org>, Rob Herring	
 <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley	
 <conor+dt@...nel.org>, Liam Girdwood <lgirdwood@...il.com>, Mark Brown	
 <broonie@...nel.org>, Jonathan Corbet <corbet@....net>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Conor Dooley <conor.dooley@...rochip.com>, 
 Jonathan Cameron <Jonathan.Cameron@...wei.com>, linux-doc@...r.kernel.org
Subject: Re: [PATCH v2 3/5] iio: adc: ad7380: add missing supplies

On Mon, 2024-10-21 at 12:00 +0200, Julien Stephan wrote:
> vcc and vlogic are required but are not retrieved and enabled in the
> probe. Add them.
> 
> In order to prepare support for additional parts requiring different
> supplies, add vcc and vlogic to the platform specific structures
> 
> Signed-off-by: Julien Stephan <jstephan@...libre.com>
> ---

One small not below... With that,

Reviewed-by: Nuno Sa <nuno.sa@...log.com>

>  drivers/iio/adc/ad7380.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index
> e033c734191143a25a490b09c730dbf95f796737..e257f78d63edd7910fcb936ec5344922f8e7
> 0b99 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -75,6 +75,7 @@
>  #define T_CONVERT_NS 190		/* conversion time */
>  #define T_CONVERT_0_NS 10		/* 1st conversion start time
> (oversampling) */
>  #define T_CONVERT_X_NS 500		/* xth conversion start time
> (oversampling) */
> +#define T_POWERUP_MS 5			/* Power up */
>  
>  struct ad7380_timing_specs {
>  	const unsigned int t_csh_ns;	/* CS minimum high time */
> @@ -86,6 +87,8 @@ struct ad7380_chip_info {
>  	unsigned int num_channels;
>  	unsigned int num_simult_channels;
>  	bool has_mux;
> +	const char * const *supplies;
> +	unsigned int num_supplies;
>  	const char * const *vcm_supplies;
>  	unsigned int num_vcm_supplies;
>  	const unsigned long *available_scan_masks;
> @@ -243,6 +246,10 @@ DEFINE_AD7380_8_CHANNEL(ad7386_4_channels, 16, 0, u);
>  DEFINE_AD7380_8_CHANNEL(ad7387_4_channels, 14, 0, u);
>  DEFINE_AD7380_8_CHANNEL(ad7388_4_channels, 12, 0, u);
>  
> +static const char * const ad7380_supplies[] = {
> +	"vcc", "vlogic",
> +};
> +
>  static const char * const ad7380_2_channel_vcm_supplies[] = {
>  	"aina", "ainb",
>  };
> @@ -338,6 +345,8 @@ static const struct ad7380_chip_info ad7380_chip_info = {
>  	.channels = ad7380_channels,
>  	.num_channels = ARRAY_SIZE(ad7380_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.available_scan_masks = ad7380_2_channel_scan_masks,
>  	.timing_specs = &ad7380_timing,
>  };
> @@ -347,6 +356,8 @@ static const struct ad7380_chip_info ad7381_chip_info = {
>  	.channels = ad7381_channels,
>  	.num_channels = ARRAY_SIZE(ad7381_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.available_scan_masks = ad7380_2_channel_scan_masks,
>  	.timing_specs = &ad7380_timing,
>  };
> @@ -356,6 +367,8 @@ static const struct ad7380_chip_info ad7383_chip_info = {
>  	.channels = ad7383_channels,
>  	.num_channels = ARRAY_SIZE(ad7383_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.vcm_supplies = ad7380_2_channel_vcm_supplies,
>  	.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
>  	.available_scan_masks = ad7380_2_channel_scan_masks,
> @@ -367,6 +380,8 @@ static const struct ad7380_chip_info ad7384_chip_info = {
>  	.channels = ad7384_channels,
>  	.num_channels = ARRAY_SIZE(ad7384_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.vcm_supplies = ad7380_2_channel_vcm_supplies,
>  	.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
>  	.available_scan_masks = ad7380_2_channel_scan_masks,
> @@ -378,6 +393,8 @@ static const struct ad7380_chip_info ad7386_chip_info = {
>  	.channels = ad7386_channels,
>  	.num_channels = ARRAY_SIZE(ad7386_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x2_channel_scan_masks,
>  	.timing_specs = &ad7380_timing,
> @@ -388,6 +405,8 @@ static const struct ad7380_chip_info ad7387_chip_info = {
>  	.channels = ad7387_channels,
>  	.num_channels = ARRAY_SIZE(ad7387_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x2_channel_scan_masks,
>  	.timing_specs = &ad7380_timing,
> @@ -398,6 +417,8 @@ static const struct ad7380_chip_info ad7388_chip_info = {
>  	.channels = ad7388_channels,
>  	.num_channels = ARRAY_SIZE(ad7388_channels),
>  	.num_simult_channels = 2,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x2_channel_scan_masks,
>  	.timing_specs = &ad7380_timing,
> @@ -408,6 +429,8 @@ static const struct ad7380_chip_info ad7380_4_chip_info =
> {
>  	.channels = ad7380_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7380_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.available_scan_masks = ad7380_4_channel_scan_masks,
>  	.timing_specs = &ad7380_4_timing,
>  };
> @@ -417,6 +440,8 @@ static const struct ad7380_chip_info ad7381_4_chip_info =
> {
>  	.channels = ad7381_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7381_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.available_scan_masks = ad7380_4_channel_scan_masks,
>  	.timing_specs = &ad7380_4_timing,
>  };
> @@ -426,6 +451,8 @@ static const struct ad7380_chip_info ad7383_4_chip_info =
> {
>  	.channels = ad7383_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7383_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.vcm_supplies = ad7380_4_channel_vcm_supplies,
>  	.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
>  	.available_scan_masks = ad7380_4_channel_scan_masks,
> @@ -437,6 +464,8 @@ static const struct ad7380_chip_info ad7384_4_chip_info =
> {
>  	.channels = ad7384_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7384_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.vcm_supplies = ad7380_4_channel_vcm_supplies,
>  	.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
>  	.available_scan_masks = ad7380_4_channel_scan_masks,
> @@ -448,6 +477,8 @@ static const struct ad7380_chip_info ad7386_4_chip_info =
> {
>  	.channels = ad7386_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7386_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x4_channel_scan_masks,
>  	.timing_specs = &ad7380_4_timing,
> @@ -458,6 +489,8 @@ static const struct ad7380_chip_info ad7387_4_chip_info =
> {
>  	.channels = ad7387_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7387_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x4_channel_scan_masks,
>  	.timing_specs = &ad7380_4_timing,
> @@ -468,6 +501,8 @@ static const struct ad7380_chip_info ad7388_4_chip_info =
> {
>  	.channels = ad7388_4_channels,
>  	.num_channels = ARRAY_SIZE(ad7388_4_channels),
>  	.num_simult_channels = 4,
> +	.supplies = ad7380_supplies,
> +	.num_supplies = ARRAY_SIZE(ad7380_supplies),
>  	.has_mux = true,
>  	.available_scan_masks = ad7380_2x4_channel_scan_masks,
>  	.timing_specs = &ad7380_4_timing,
> @@ -1004,6 +1039,14 @@ static int ad7380_probe(struct spi_device *spi)
>  	if (!st->chip_info)
>  		return dev_err_probe(&spi->dev, -EINVAL, "missing match
> data\n");
>  
> +	ret = devm_regulator_bulk_get_enable(&spi->dev, st->chip_info-
> >num_supplies,
> +					     st->chip_info->supplies);
> +
> +	if (ret)
> +		return dev_err_probe(&spi->dev, ret,
> +				     "Failed to enable power supplies\n");
> +	msleep(T_POWERUP_MS);

T_POWERUP_MS is 5ms so msleep() is not the advised API to use. In order to have
not to think about it, use fsleep(). This came up recently and this is one of
the reasons why I think (in most common cases at least) using fsleep() is a good
practise even if we already know which function we need to call. Also makes
reviewers lives easier as we don't have to double check the time being slept.

- Nuno Sá


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ