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] [day] [month] [year] [list]
Message-ID: <20240601194328.6c28f743@jic23-huawei>
Date: Sat, 1 Jun 2024 19:43:28 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Nuno Sá <noname.nuno@...il.com>
Cc: David Lechner <dlechner@...libre.com>, "Ceclan, Dumitru" 
 <mitrutzceclan@...il.com>, dumitru.ceclan@...log.com, Lars-Peter Clausen
 <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>, Rob
 Herring <robh@...nel.org>, Krzysztof Kozlowski
 <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
 linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 5/6] iio: adc: ad7173: Add support for AD411x devices

On Thu, 30 May 2024 08:19:57 +0200
Nuno Sá <noname.nuno@...il.com> wrote:

> On Wed, 2024-05-29 at 15:59 -0500, David Lechner wrote:
> > On 5/29/24 9:03 AM, Ceclan, Dumitru wrote:  
> > > On 29/05/2024 15:46, Nuno Sá wrote:  
> > > > On Mon, 2024-05-27 at 20:02 +0300, Dumitru Ceclan via B4 Relay wrote:  
> > > > > From: Dumitru Ceclan <dumitru.ceclan@...log.com>  
> > > 
> > > ...
> > >   
> > > > >  static const struct ad7173_device_info ad7173_device_info[] = {
> > > > > +	[ID_AD4111] = {
> > > > > +		.name = "ad4111",
> > > > > +		.id = AD7173_AD4111_AD4112_AD4114_ID,
> > > > > +		.num_voltage_inputs_with_divider = 8,
> > > > > +		.num_channels = 16,
> > > > > +		.num_configs = 8,
> > > > > +		.num_voltage_inputs = 8,
> > > > > +		.num_gpios = 2,
> > > > > +		.higher_gpio_bits = true,
> > > > > +		.has_temp = true,
> > > > > +		.has_vcom_input = true,
> > > > > +		.has_input_buf = true,
> > > > > +		.has_current_inputs = true,
> > > > > +		.has_int_ref = true,
> > > > > +		.clock = 2 * HZ_PER_MHZ,
> > > > > +		.sinc5_data_rates = ad7173_sinc5_data_rates,
> > > > > +		.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
> > > > > +	},  
> > > > 
> > > > At some point it would be nice to drop the ad7173_device_info array...
> > > >   
> > > What are good alternatives to this?  
> > 
> > Drivers like ad7091r8 have individual static struct ad7091r_init_info
> > instead of putting them all in an array. I like doing it that
> > way because it makes less code to read compared to having the
> > array.
> > 
> > It would let us get rid of enum ad7173_ids, have one level less
> > indent on each static const struct ad7173_device_info and 
> > 
> > { .compatible = "adi,ad7172-2", .data = &ad7173_device_info },
> > 
> > would now fit on one line since we no longer need the array
> > index.
> >   
> 
> Exactly... But up to you to do it now or defer it to a later patch.
> 
Agreed - the array pattern for this is not a good idea as it
also encourages people to assign meaning to the enum values leaving
stuff expressed as code that should be a flag or value inside these
device_info structures.

Some of those where mistakes of a younger me ;(

Jonathan

> - Nuno Sá


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ