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 4/4] iio: imu: fxos8700: fix magnetometer scale getting error
Date: Sun, 4 Dec 2022 15:27:03 +0000 [thread overview]
Message-ID: <20221204152703.4e83f951@jic23-huawei> (raw)
In-Reply-To: <20221202103538.2218925-5-carlos.song@nxp.com>
On Fri, 2 Dec 2022 18:35:38 +0800
Carlos Song <carlos.song@nxp.com> wrote:
> Incorrect iio channel type cause a magnetometer scale getting
> error. Meanwhile magnetometer scale and available magnetometer
> scale should be locked as 0.1uT according to the datasheet.
>
> Set magn sensor type "IIO_MAGN" and modify magn_scale fixed "0.1uT".
>
> Fixes: 84e5ddd5c46e ("iio: imu: Add support for the FXOS8700 IMU")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
> ---
> drivers/iio/imu/fxos8700_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c
> index 27e3bd61d054..8d46462dca76 100644
> --- a/drivers/iio/imu/fxos8700_core.c
> +++ b/drivers/iio/imu/fxos8700_core.c
> @@ -319,7 +319,7 @@ static enum fxos8700_sensor fxos8700_to_sensor(enum iio_chan_type iio_type)
> switch (iio_type) {
> case IIO_ACCEL:
> return FXOS8700_ACCEL;
> - case IIO_ANGL_VEL:
> + case IIO_MAGN:
Ahah. This had me confused on looking at earlier patch ;)
Amusingly much of the code 'worked' because it was use as a boolean return
so -EINVAL had same affect as FXOS8700_MAGN.
This fix stands on it's own as a separate fix, so I'd rather see it in a
trivial patch of it's own before this one.
> return FXOS8700_MAGN;
> default:
> return -EINVAL;
> @@ -350,7 +350,7 @@ static int fxos8700_set_scale(struct fxos8700_data *data,
> struct device *dev = regmap_get_device(data->regmap);
>
> if (t == FXOS8700_MAGN) {
> - dev_err(dev, "Magnetometer scale is locked at 1200uT\n");
> + dev_err(dev, "Magnetometer scale is locked at 0.1uT\n");
> return -EINVAL;
> }
>
> @@ -393,7 +393,7 @@ static int fxos8700_get_scale(struct fxos8700_data *data,
> static const int scale_num = ARRAY_SIZE(fxos8700_accel_scale);
>
> if (t == FXOS8700_MAGN) {
> - *uscale = 1200; /* Magnetometer is locked at 1200uT */
> + *uscale = 100000; /* Magnetometer scale is locked at 0.1 uT */
See Documentation/ABI/testing/sysfs-bus-iio
magnetometer channel units are Gauss.
0.1ut = 0.001g so uscale should be 1000 I think with available changed to match.
> return 0;
> }
>
> @@ -563,7 +563,7 @@ static IIO_CONST_ATTR(in_accel_sampling_frequency_available,
> static IIO_CONST_ATTR(in_magn_sampling_frequency_available,
> "1.5625 6.25 12.5 50 100 200 400 800");
> static IIO_CONST_ATTR(in_accel_scale_available, "0.000244 0.000488 0.000976");
> -static IIO_CONST_ATTR(in_magn_scale_available, "0.000001200");
> +static IIO_CONST_ATTR(in_magn_scale_available, "0.100000")
>
> static struct attribute *fxos8700_attrs[] = {
> &iio_const_attr_in_accel_sampling_frequency_available.dev_attr.attr,
prev parent reply other threads:[~2022-12-04 15:14 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
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 [this message]
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=20221204152703.4e83f951@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