From: Jonathan Cameron <jic23@kernel.org>
To: Julien Stephan <jstephan@baylibre.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Jonathan Corbet" <corbet@lwn.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH RFC v2 2/4] iio: adc: ad7380: enable regmap cache
Date: Sat, 28 Dec 2024 14:02:01 +0000 [thread overview]
Message-ID: <20241228140201.424936ba@jic23-huawei> (raw)
In-Reply-To: <20241224-ad7380-add-alert-support-v2-2-7c89b2bf7cb3@baylibre.com>
On Tue, 24 Dec 2024 10:34:31 +0100
Julien Stephan <jstephan@baylibre.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@baylibre.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!
> /*
next prev parent reply other threads:[~2024-12-28 14:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 9:34 [PATCH RFC v2 0/4] iio: adc: ad7380: add alert support Julien Stephan
2024-12-24 9:34 ` [PATCH RFC v2 1/4] iio: adc: ad7380: do not use iio_device_claim_direct_scoped anymore Julien Stephan
2024-12-27 8:43 ` Uwe Kleine-König
2024-12-28 13:51 ` Jonathan Cameron
2024-12-28 13:49 ` Jonathan Cameron
2024-12-24 9:34 ` [PATCH RFC v2 2/4] iio: adc: ad7380: enable regmap cache Julien Stephan
2024-12-27 8:48 ` Uwe Kleine-König
2024-12-28 14:07 ` Jonathan Cameron
2024-12-28 14:02 ` Jonathan Cameron [this message]
2024-12-24 9:34 ` [PATCH RFC v2 3/4] iio: adc: ad7380: add alert support Julien Stephan
2024-12-27 9:39 ` Uwe Kleine-König
2024-12-28 14:24 ` Jonathan Cameron
2025-01-06 15:29 ` David Lechner
2025-01-07 8:51 ` Julien Stephan
2025-01-11 12:51 ` Jonathan Cameron
2025-01-12 11:40 ` Jonathan Cameron
2024-12-24 9:34 ` [PATCH RFC v2 4/4] docs: iio: " Julien Stephan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241228140201.424936ba@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=corbet@lwn.net \
--cc=dlechner@baylibre.com \
--cc=jstephan@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox