From: Jonathan Cameron <jic23@kernel.org>
To: Carlos Song <carlos.song@nxp.com>
Cc: lars@metafoo.de, rjones@gateworks.com,
Jonathan.Cameron@huawei.com, haibo.chen@nxp.com,
linux-imx@nxp.com, linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/4] iio: imu: fxos8700: fix ODR offset error
Date: Sun, 4 Dec 2022 15:15:21 +0000 [thread overview]
Message-ID: <20221204151521.208e6a7d@jic23-huawei> (raw)
In-Reply-To: <20221202103538.2218925-4-carlos.song@nxp.com>
On Fri, 2 Dec 2022 18:35:37 +0800
Carlos Song <carlos.song@nxp.com> wrote:
> Correct offset of ODR configure is needed when configure the register
> and read ODR data from the register.
>
> Give the correct offset to value when configuring ODR bit and
> reading ODR data from CTRL_REG1 register.
>
> Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
> Fixes: 058f2a09e645 ("iio: imu: fxos8700: fix CTRL_REG1 register configuration error")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Minor suggestion inline.
Btw, I'm not particularly keen on internal review tags.
I know the policy varies by company, but it it isn't too much of a problem, I'd
prefer to have seen Haibo Chen's review on list as that then gives me some
way to build trust in Haibo's reviews over the long run!
If not possible, then that's fine.
Jonathan
> ---
> drivers/iio/imu/fxos8700_core.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c
> index 60c08519d8af..27e3bd61d054 100644
> --- a/drivers/iio/imu/fxos8700_core.c
> +++ b/drivers/iio/imu/fxos8700_core.c
> @@ -147,6 +147,7 @@
> #define FXOS8700_CTRL_ODR_MSK 0x38
> #define FXOS8700_CTRL_ODR_MAX 0x00
> #define FXOS8700_CTRL_ODR_MIN GENMASK(4, 3)
> +#define FXOS8700_CTRL_ODR_OFFSET 3
>
> /* Bit definitions for FXOS8700_M_CTRL_REG1 */
> #define FXOS8700_HMS_MASK GENMASK(1, 0)
> @@ -498,8 +499,7 @@ static int fxos8700_get_odr(struct fxos8700_data *data, enum fxos8700_sensor t,
> if (ret)
> return ret;
>
> - val &= FXOS8700_CTRL_ODR_MSK;
> -
> + val = (val & FXOS8700_CTRL_ODR_MSK) >> FXOS8700_CTRL_ODR_OFFSET;
FIELD_GET() / FIELD_PREP() preferred as it avoids need to separately define
an offset.
> for (i = 0; i < odr_num; i++)
> if (val == fxos8700_odr[i].bits)
> break;
> @@ -636,7 +636,8 @@ static int fxos8700_chip_init(struct fxos8700_data *data, bool use_spi)
>
> /* Max ODR (800Hz individual or 400Hz hybrid), active mode */
> return regmap_write(data->regmap, FXOS8700_CTRL_REG1,
> - FXOS8700_CTRL_ODR_MAX | FXOS8700_ACTIVE);
> + FXOS8700_CTRL_ODR_MAX << FXOS8700_CTRL_ODR_OFFSET |
> + FXOS8700_ACTIVE);
> }
>
> static void fxos8700_chip_uninit(void *data)
next prev parent reply other threads:[~2022-12-04 15:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 10:35 [PATCH 0/4] iio: imu: fxos8700: fix few bug in reading raw data and configuring register Carlos Song
2022-12-02 10:35 ` [PATCH 1/4] iio: imu: fxos8700: fix get data function error Carlos Song
2022-12-04 15:03 ` Jonathan Cameron
2022-12-02 10:35 ` [PATCH 2/4] iio: imu: fxos8700: fix CTRL_REG1 register configuration error Carlos Song
2022-12-04 15:12 ` Jonathan Cameron
2022-12-02 10:35 ` [PATCH 3/4] iio: imu: fxos8700: fix ODR offset error Carlos Song
2022-12-04 15:15 ` Jonathan Cameron [this message]
2022-12-02 10:35 ` [PATCH 4/4] iio: imu: fxos8700: fix magnetometer scale getting error Carlos Song
2022-12-04 15:27 ` Jonathan Cameron
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=20221204151521.208e6a7d@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=carlos.song@nxp.com \
--cc=haibo.chen@nxp.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=rjones@gateworks.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