[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241228140201.424936ba@jic23-huawei>
Date: Sat, 28 Dec 2024 14:02:01 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Julien Stephan <jstephan@...libre.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich
<Michael.Hennerich@...log.com>, Nuno Sá <nuno.sa@...log.com>,
David Lechner <dlechner@...libre.com>, Jonathan Corbet <corbet@....net>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH RFC v2 2/4] iio: adc: ad7380: enable regmap cache
On Tue, 24 Dec 2024 10:34:31 +0100
Julien Stephan <jstephan@...libre.com> wrote:
> Enable regmap cache, to avoid useless access on spi bus.
> Don't store anymore the oversampling ratio in private data structure.
>
> Signed-off-by: Julien Stephan <jstephan@...libre.com>
A few really minor things inline,
Jonathan
> static int ad7380_debugfs_reg_access(struct iio_dev *indio_dev, u32 reg,
> @@ -692,6 +709,37 @@ static int ad7380_debugfs_reg_access(struct iio_dev *indio_dev, u32 reg,
> return ret;
> }
>
> +/**
> + * ad7380_regval_to_osr - convert OSR register value to ratio
> + * @regval: register value to check
> + *
> + * Returns: the ratio corresponding to the OSR register. If regval is not in
> + * bound, return 1 (oversampling disabled)
> + *
> + */
> +static int ad7380_regval_to_osr(int regval)
Make regval an unsigned int and yout can drop one test.
The FIELD_GET is never going to give you a signed value anyway.
> +{
> + if (regval < 0 || regval >= ARRAY_SIZE(ad7380_oversampling_ratios))
> + return 1;
> +
> + return ad7380_oversampling_ratios[regval];
> +}
> +
> +static int ad7380_get_osr(struct ad7380_state *st, int *val)
> +{
> + int tmp;
> + int ret = 0;
No point in initializing.
> +
> + ret = regmap_read(st->regmap, AD7380_REG_ADDR_CONFIG1, &tmp);
> + if (ret)
> + return ret;
> +
> + *val = ad7380_regval_to_osr(FIELD_GET(AD7380_CONFIG1_OSR, tmp));
> +
> + return 0;
> +}
> +
> +
Trivial but one blank line almost always enough!
> /*
Powered by blists - more mailing lists