From: Jonathan Cameron <jic23@kernel.org>
To: Andrea Merello <andrea.merello@gmail.com>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio <linux-iio@vger.kernel.org>,
Andrea Merello <andrea.merello@iit.it>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [v3 07/13] iio: imu: add Bosch Sensortec BNO055 core driver
Date: Sun, 27 Mar 2022 17:11:04 +0100 [thread overview]
Message-ID: <20220327171104.051fcbd2@jic23-huawei> (raw)
In-Reply-To: <CAN8YU5OCEBTF37hb6ozaguJ0=svPyv+fmGGsLhoBCPZA5Odgdw@mail.gmail.com>
On Tue, 22 Mar 2022 11:27:14 +0100
Andrea Merello <andrea.merello@gmail.com> wrote:
> Il giorno sab 19 feb 2022 alle ore 18:34 Jonathan Cameron
> <jic23@kernel.org> ha scritto:
> >
> > On Thu, 17 Feb 2022 22:58:14 +0100 (CET)
> > Peter Meerwald-Stadler <pmeerw@pmeerw.net> wrote:
> >
> > > On Thu, 17 Feb 2022, Andrea Merello wrote:
> > >
> > > nice work, minor comments below
> >
> > I'll review on top of Peter to save on duplication.
> >
> > Mostly really minor stuff.
+CC Greg for binary attribute questions.
>
> :)
>
> As usual, comments inline; OK for all the rest.
>
> > Given this has crossed with the introduction of namespaces to quite
> > a few IIO drivers (I have another series to do on that once I get
> > caught up with reviews) I'd prefer it if you would move this into
> > a symbol namespace (EXPORT_SYMBOL_NS_GPL() and appropriate namespace
> > statements in the two bus modules.
> >
> > Save it being done as a follow up series. If you prefer not to then
> > that's fine too as it'll be a trivial follow up patch.
>
> I'll include it in V4 directly.
>
> [...]
>
> > > > + case IIO_CHAN_INFO_SCALE:
> > > > + /* Table 3-31: 1 quaternion = 2^14 LSB */
> > > > + if (size < 2)
> > > > + return -EINVAL;
> > > > + vals[0] = 1;
> > > > + vals[1] = 1 << 14;
> > > > + return IIO_VAL_FRACTIONAL_LOG2;
> >
> > This doesn't look right. Not vals[1] = 14 given FRACTIONAL_LOG2?
>
> Hum.. maybe just IIO_VAL_FRACTIONAL ?
That works as well, though I'd argue FRACTIONAL_LOG2 is the
better option as it makes it clear the divisor is a power of 2
and the precision might potentially be better as a result (I've not
checked!)
>
> > > > + default:
> > > > + return -EINVAL;
> > > > + }
> > > > +}
> > > > +
>
> [...]
>
> > > > +static IIO_DEVICE_ATTR_RO(sys_calibration_auto_status, 0);
> > > > +static IIO_DEVICE_ATTR_RO(in_accel_calibration_auto_status, 0);
> > > > +static IIO_DEVICE_ATTR_RO(in_gyro_calibration_auto_status, 0);
> > > > +static IIO_DEVICE_ATTR_RO(in_magn_calibration_auto_status, 0);
> > > > +static IIO_DEVICE_ATTR_RO(calibration_data, 0);
> >
> > This is documented as providing binary data but it's not using
> > a binary attribute and that rather surprised me.
> >
> > Off the top of my head I can't recall why it matters though, so please
> > take a look at whether a bin_attribute makes more sense for this.
>
> As far as I can see, it seems that a non-binary attributes only
> support to be read at once while the binary attributes read()
> operation supports random access i.e. it has the file position
> parameter.
>
> The calibration data is "dynamic", it's read from the HW every time,
> and I'm not sure it makes any sense to read it in several chunks (what
> if we read a chunk and the calibration data is updated by the HW
> before reading the second chunk?). So, despide the fitting "binary"
> name I'm tempted to stick with regular attribute. However I'm not sure
> this is the only difference related to binary attributes.
+Cc Greg. Valid choice to use a normal attribute for this?
>
> > > > +
> > > > +static IIO_DEVICE_ATTR_RO(serial_number, 0);
> > > > +
> > > > +static struct attribute *bno055_attrs[] = {
> > > > + &iio_dev_attr_in_accel_range_raw_available.dev_attr.attr,
> >
> > discussed in ABI documentation review.
> > I think these should be range_input to avoid implication they are
> > in _raw units (i.e. need _scale to be applied)
>
> They are raw indeed; they need scale to be applied, then they become m/s^2.
>
> I'll fix the doc to clarify this.
Ah. Ok.
>
> [...]
>
> > > > +
> > > > + priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> > > > + if (IS_ERR(priv->reset_gpio))
> > > > + return dev_err_probe(dev, PTR_ERR(priv->reset_gpio), "Failed to get reset GPIO");
> > > > +
> > > > + priv->clk = devm_clk_get_optional(dev, "clk");
> > > > + if (IS_ERR(priv->clk))
> > > > + return dev_err_probe(dev, PTR_ERR(priv->clk), "Failed to get CLK");
> > > > +
> > > > + ret = clk_prepare_enable(priv->clk);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + ret = devm_add_action_or_reset(dev, bno055_clk_disable, priv->clk);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + if (priv->reset_gpio) {
> > > > + usleep_range(5000, 10000);
> > > > + gpiod_set_value_cansleep(priv->reset_gpio, 1);
> > > > + usleep_range(650000, 750000);
> >
> > Not a toggle on the reset? I'd expect it to be set and then unset after
> > a pulse.
>
> Isn't the above devm_gpiod_get_optional() call that also initialize
> the initial GPIO value (then just wait and flip here) ?
good point. Missed that.
Jonathan
>
> [...]
next prev parent reply other threads:[~2022-03-27 16:03 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 16:26 [v3 00/13] Add support for Bosch BNO055 IMU Andrea Merello
2022-02-17 16:26 ` [v3 01/13] iio: add modifiers for linear acceleration Andrea Merello
2022-02-17 16:26 ` [v3 02/13] iio: document linear acceleration modifiers Andrea Merello
2022-02-19 16:08 ` Jonathan Cameron
2022-02-17 16:27 ` [v3 03/13] iio: event_monitor: add " Andrea Merello
2022-02-17 16:27 ` [v3 04/13] iio: add modifers for pitch, yaw, roll Andrea Merello
2022-02-17 16:27 ` [v3 05/13] iio: document pitch, yaw, roll modifiers Andrea Merello
2022-02-19 16:31 ` Jonathan Cameron
2022-02-17 16:27 ` [v3 06/13] iio: event_monitor: add pitch, yaw and " Andrea Merello
2022-02-17 16:27 ` [v3 07/13] iio: imu: add Bosch Sensortec BNO055 core driver Andrea Merello
2022-02-17 21:58 ` Peter Meerwald-Stadler
2022-02-19 17:41 ` Jonathan Cameron
2022-03-22 10:27 ` Andrea Merello
2022-03-27 16:11 ` Jonathan Cameron [this message]
2022-03-28 13:02 ` Greg Kroah-Hartman
2022-04-04 6:30 ` Andrea Merello
2022-04-04 7:54 ` Greg Kroah-Hartman
2022-03-22 10:14 ` Andrea Merello
2022-02-17 16:27 ` [v3 08/13] iio: document bno055 private sysfs attributes Andrea Merello
2022-02-19 16:50 ` Jonathan Cameron
2022-02-17 16:27 ` [v3 09/13] iio: document "serial_number" sysfs attribute Andrea Merello
2022-02-19 16:52 ` Jonathan Cameron
2022-02-17 16:27 ` [v3 10/13] dt-bindings: iio: imu: add documentation for Bosch BNO055 bindings Andrea Merello
2022-02-24 19:54 ` Rob Herring
2022-02-17 16:27 ` [v3 11/13] iio: imu: add BNO055 serdev driver Andrea Merello
2022-02-17 19:47 ` kernel test robot
2022-02-18 5:20 ` kernel test robot
2022-02-21 20:27 ` Andy Shevchenko
2022-03-22 10:37 ` Andrea Merello
2022-02-17 16:27 ` [v3 12/13] iio: imu: add BNO055 I2C driver Andrea Merello
2022-02-19 17:03 ` Jonathan Cameron
2022-02-21 20:32 ` Andy Shevchenko
2022-02-17 16:27 ` [v3 13/13] docs: iio: add documentation for BNO055 driver Andrea Merello
2022-02-19 17:06 ` Jonathan Cameron
2022-03-22 10:30 ` Andrea Merello
2022-03-22 20:32 ` 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=20220327171104.051fcbd2@jic23-huawei \
--to=jic23@kernel.org \
--cc=andrea.merello@gmail.com \
--cc=andrea.merello@iit.it \
--cc=gregkh@linuxfoundation.org \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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