From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Mehdi Djait <mehdi.djait.k@gmail.com>, jic23@kernel.org
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 0/2] iio: accel: kionix-kx022a: Minor fixes
Date: Mon, 30 Jan 2023 10:15:51 +0200 [thread overview]
Message-ID: <d6e797c3-ef06-c89f-e181-45535d23f614@gmail.com> (raw)
In-Reply-To: <cover.1674996464.git.mehdi.djait.k@gmail.com>
Hi Mehdi,
On 1/29/23 15:37, Mehdi Djait wrote:
> Two minor fixes. Swap the setting of rd_table and wr_table and remove
> the g_range member.
>
> Matti, I thought about defining an unsigned int array for the 4 possible
> g ranges, setting a g_range initial value in the probe function and
> updating it in the write_raw callback (case IIO_CHAN_INFO_SCALE)
How would it differ from current write_raw behaviour (below)?
[mvaittin@dc75zzyyyyyyyyyyyyycy-3 linux]$ grep -A70 write_raw
drivers/iio/accel/kionix-kx022a.c
static int kx022a_write_raw(struct iio_dev *idev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{
struct kx022a_data *data = iio_priv(idev);
int ret, n;
/*
* We should not allow changing scale or frequency when FIFO is running
* as it will mess the timestamp/scale for samples existing in the
* buffer. If this turns out to be an issue we can later change logic
* to internally flush the fifo before reconfiguring so the samples in
* fifo keep matching the freq/scale settings. (Such setup could cause
* issues if users trust the watermark to be reached within known
* time-limit).
*/
ret = iio_device_claim_direct_mode(idev);
if (ret)
return ret;
switch (mask) {
//snip
case IIO_CHAN_INFO_SCALE:
n = ARRAY_SIZE(kx022a_scale_table);
while (n-- > 0)
if (val == kx022a_scale_table[n][0] &&
val2 == kx022a_scale_table[n][1])
break;
if (n < 0) {
ret = -EINVAL;
goto unlock_out;
}
ret = kx022a_turn_off_lock(data);
if (ret)
break;
ret = regmap_update_bits(data->regmap, KX022A_REG_CNTL,
KX022A_MASK_GSEL,
n << KX022A_GSEL_SHIFT);
kx022a_turn_on_unlock(data);
break;
//snip
but
> does it make sense to keep track of the g_range value ?
Do you mean caching the g_range instead of retrieving it from the
hardware? I don't know an use-case where reading the range would be
time-critical - and even if it was, the regmap should cache the value
anyways. (unless KX022A_REG_CNTL is in volatile range). So no, I don't
think caching the g_range is worth it.
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-01-30 8:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 13:37 [PATCH 0/2] iio: accel: kionix-kx022a: Minor fixes Mehdi Djait
2023-01-29 13:37 ` [PATCH 1/2] iio: accel: kionix-kx022a: Fix the setting of regmap_config rd_table and wr_table Mehdi Djait
2023-01-30 7:37 ` Matti Vaittinen
2023-01-31 19:32 ` Mehdi Djait
2023-01-29 13:37 ` [PATCH 2/2] iio: accel: kionix-kx022a: Remove the unused member g_range Mehdi Djait
2023-01-30 8:17 ` Matti Vaittinen
2023-02-05 14:56 ` Jonathan Cameron
2023-01-30 8:15 ` Matti Vaittinen [this message]
2023-01-31 19:48 ` [PATCH 0/2] iio: accel: kionix-kx022a: Minor fixes Mehdi Djait
2023-02-01 5:36 ` Matti Vaittinen
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=d6e797c3-ef06-c89f-e181-45535d23f614@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=mehdi.djait.k@gmail.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;
as well as URLs for NNTP newsgroup(s).