Re: [PATCH v4 8/8] iio: adc: stm32-dfsdm: add scaling support to dfsdm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 4 Jul 2024 17:53:36 +0200
Olivier Moysan <olivier.moysan@xxxxxxxxxxx> wrote:

> Add scaling support to STM32 DFSDM.
> 
> When used in an analog context, a DFSDM filter typically converts the data
> from a sigma delta modulator. The IIO device associated to the DFSDM
> filter provides these data as raw data.
> The IIO device can provide scaling information (voltage and offset) to
> allow conversion of raw data into physical values.
> 
> With the new binding based on IIO backend framework, the sigma delta
> modulators are defined as backends providing scaling information.
> 
> The scaling is not supported with legacy binding.
> 
> Signed-off-by: Olivier Moysan <olivier.moysan@xxxxxxxxxxx>
> Acked-by: Nuno Sa <nuno.sa@xxxxxxxxxx>

One really minor thing inline.

Jonathan

> @@ -1278,7 +1308,14 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
>  				int *val2, long mask)
>  {
>  	struct stm32_dfsdm_adc *adc = iio_priv(indio_dev);
> -	int ret;
> +
> +	struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id];
> +	struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast];
> +	u32 max = flo->max << (flo->lshift - chan->scan_type.shift);
> +	int ret, idx = chan->scan_index;
Trivial but I've been grumping at others about this today so you get it too ;)
Don't mix declarations that include assignments with ones that don't.
It isn't good for general readability.
	int idx = chan->scan_index;
	int ret;

I'm not interested in patches to 'fix' this in other code, but nice to not
introduce more cases in new code.

> +
> +	if (flo->lshift < chan->scan_type.shift)
> +		max = flo->max >> (chan->scan_type.shift - flo->lshift);
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux