Re: [PATCH v3 3/6] iio: adc: ad7173: refactor ain and vref selection

From: Ceclan, Dumitru
Date: Thu May 30 2024 - 10:45:48 EST


On 29/05/2024 15:49, Nuno Sá wrote:
> On Wed, 2024-05-29 at 14:27 +0200, Nuno Sá wrote:
>> On Mon, 2024-05-27 at 20:02 +0300, Dumitru Ceclan via B4 Relay wrote:
>>> From: Dumitru Ceclan <dumitru.ceclan@xxxxxxxxxx>

..

>>> +static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st,
>>> +       unsigned int ain[2])
>
> Pass the pointer and size of it... Also, it should be made 'const'
>

I'm learning here: what is the purpose of passing the size of it?
This is a specific case where the size will always be 2

Also, this will make it awkward in the following patch where I'm using
the assumption of size 2 to check if both inputs have a voltage divider
ain[(i+1) %2]

>>> +{
>>> + struct device *dev = &st->sd.spi->dev;
>>> +
>>> + for (int i = 0; i < 2; i++) {
>
> Use the size in here... At the very least, ARRAY_SIZE() if you keep it like this.
>