[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <wvflf3rmqaonm6gt45gqtxndprkqbhgvce5z7c4z7c7jgdg4tm@kofkvcbvnaav>
Date: Tue, 6 May 2025 16:46:35 +0200
From: Angelo Dureghello <adureghello@...libre.com>
To: Andy Shevchenko <andy@...nel.org>
Cc: Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>,
Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH v2 3/5] iio: adc: ad7606: add offset and phase
calibration support
On 02.05.2025 16:39, Andy Shevchenko wrote:
> On Fri, May 02, 2025 at 03:27:00PM +0200, Angelo Dureghello wrote:
> > From: Angelo Dureghello <adureghello@...libre.com>
> >
> > Add support for offset and phase calibration, only for
> > devices that support software mode, that are:
> >
> > ad7606b
> > ad7606c-16
> > ad7606c-18
>
> ...
>
> > +static int ad7606_get_calib_offset(struct ad7606_state *st, int ch, int *val)
> > +{
> > + int ret;
> > +
> > + ret = st->bops->reg_read(st, AD7606_CALIB_OFFSET(ch));
> > + if (ret < 0)
> > + return ret;
> > +
> > + *val = st->chip_info->calib_offset_avail[0] +
> > + ret * st->chip_info->calib_offset_avail[1];
>
> Something wrong with the indentation.
Can eventually adjust to:
*val = st->chip_info->calib_offset_avail[0] + ret *
st->chip_info->calib_offset_avail[1];
this is genrelly ok.
>
> > + return 0;
> > +}
>
> ...
>
> > +static int ad7606_set_calib_offset(struct ad7606_state *st, int ch, int val)
> > +{
> > + int start_val, step_val, stop_val;
>
> All need to be signed?
>
would keep them all as int, to avoid different type comparison later.
> > + start_val = st->chip_info->calib_offset_avail[0];
> > + step_val = st->chip_info->calib_offset_avail[1];
> > + stop_val = st->chip_info->calib_offset_avail[2];
> > +
> > + if (val < start_val || val > stop_val)
> > + return -EINVAL;
> > +
> > + val -= start_val;
> > + val /= step_val;
> > +
> > + return st->bops->reg_write(st, AD7606_CALIB_OFFSET(ch), val);
> > +}
>
> ...
>
> > +static int ad7606_set_calib_phase(struct ad7606_state *st, int ch, int val,
> > + int val2)
> > +{
> > + int wreg, start_ns, step_ns, stop_ns;
>
> Ditto.
>
here too, val and val2 comes in as int, and subsequent operations
are int, so would stay as int.
> > + if (val != 0)
> > + return -EINVAL;
> > +
> > + start_ns = st->chip_info->calib_phase_avail[0][1];
> > + step_ns = st->chip_info->calib_phase_avail[1][1];
> > + stop_ns = st->chip_info->calib_phase_avail[2][1];
> > +
> > + /*
> > + * ad7606b: phase dielay from 0 to 318.75 μs in steps of 1.25 μs.
> > + * ad7606c-16/18: phase delay from 0 µs to 255 µs in steps of 1 µs.
> > + */
> > + if (val2 < start_ns || val2 > stop_ns)
> > + return -EINVAL;
>
> Wrong indentation. Please fix in all places where it happens.
>
rechecked better now, tabs in this place was wrong. Fixed, thanks.
> > + wreg = val2 / step_ns;
> > +
> > + return st->bops->reg_write(st, AD7606_CALIB_PHASE(ch), wreg);
> > +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
regards,
angelo
Powered by blists - more mailing lists