From: Jonathan Cameron <jic23@kernel.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
phone-devel@vger.kernel.org
Subject: Re: [PATCH 2/2 v2] iio: magnetometer: Add driver for Yamaha YAS5xx
Date: Sat, 28 Nov 2020 11:27:35 +0000 [thread overview]
Message-ID: <20201128112735.57398b74@archlinux> (raw)
In-Reply-To: <X8HNcg4fQKbo8yd5@builder.lan>
On Fri, 27 Nov 2020 22:09:22 -0600
Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
> On Fri 27 Nov 18:40 CST 2020, Linus Walleij wrote:
>
> > This adds an IIO magnetometer driver for the Yamaha
> > YAS53x magnetometer/compass chips YAS530 and YAS532.
> > A quick survey of the source code released by different
> > vendors reveal that we have these variants in the family
> > with some deployments listed:
> >
> > * YAS529 MS-3C (2005 Samsung Aries)
> > * YAS530 MS-3E (2011 Samsung Galaxy S Advance)
> > * YAS532 MS-3R (2011 Samsung Galaxy S4)
> > * YAS533 MS-3F (Vivo 1633, 1707, V3, Y21L)
> > * (YAS534 is a magnetic switch)
> > * YAS535 MS-6C
> > * YAS536 MS-3W
> > * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5)
> > * YAS539 MS-3S (2018 Samsung Galaxy A7 SM-A750FN)
> >
> > The YAS529 is so significantly different from the
> > YAS53x variants that it will require its own driver.
> > The YAS537 and YAS539 have slightly different register
> > sets but have strong similarities so a common driver
> > will probably be reasonable.
> >
> > The source code for Samsung Galaxy A7's YAS539 is not
> > that significantly different from the YAS530 in the
> > Galaxy S Advance, so I believe we will only need this
> > one driver with quirks to handle all of them.
> >
> > The YAS539 is actively announced on Yamaha's devices
> > site:
> > https://device.yamaha.com/en/lsi/products/e_compass/
> >
> > This is a driver written from scratch using buffered
> > IIO and runtime PM handling regulators and reset.
> >
>
> Looks quite nice, just spotted some small things as I was skimming
> through the patch.
>
> > Cc: phone-devel@vger.kernel.org
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> > ChangeLog v1->v3:
> > - This is posted along with the DT bindings which are
> > in v3 so just number everything as v3.
>
> $subject still says v2...
>
> [..]
> > diff --git a/drivers/iio/magnetometer/yamaha-yas53x.c b/drivers/iio/magnetometer/yamaha-yas53x.c
> [..]
> > +/* On YAS532 the x, y1 and y2 values are 13 bits */
> > +static u16 yas532_extract_axis(u8 *data)
> > +{
> > + u16 val;
> > +
> > + /*
> > + * These are the bits used in a 16bit word:
> > + * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
> > + * x x x x x x x x x x x x x
> > + */
> > + val = get_unaligned_be16(&data[0]);
> > + val >>= 2;
> > + val &= GENMASK(12, 0);
>
> Wouldn't it be easier to follow if you GENMASK out the bits you document
> above, then shift them right?
Even better to use FIELD_GET
which does what Bjorn suggested under the hood.
Thanks,
Jonathan
>
> > + return val;
> > +}
> [..]
> > +/**
> > + * yas5xx_measure() - Make a measure from the hardware*
> > + * @yas5xx: The device state
> > + * @t: the raw temperature measurement
> > + * @x: the raw x axis measurement
> > + * @y1: the y1 axis measurement
> > + * @y2: the y2 axis measurement
>
> * Return:
>
> To complete the kerneldoc.
>
> > + */
> > +static int yas5xx_measure(struct yas5xx *yas5xx, u16 *t, u16 *x, u16 *y1, u16 *y2)
> > +{
> [..]
> > +/**
>
> This will result in someone feeling inclined to send a patch to fix the
> incomplete kerneldoc.
>
> So please either fill it out, or drop the second '*'.
>
> > + * yas5xx_get_measure() - Measure a sample of all axis and process
> > + *
> > + * Returned valued are in nanotesla according to some code.
> > + */
> > +static int yas5xx_get_measure(struct yas5xx *yas5xx, s32 *to, s32 *xo, s32 *yo, s32 *zo)
> > +{
> [..]
> > +static int __maybe_unused yas5xx_runtime_resume(struct device *dev)
> > +{
> > + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> > + struct yas5xx *yas5xx = iio_priv(indio_dev);
> > + int ret;
> > +
> > + ret = regulator_bulk_enable(ARRAY_SIZE(yas5xx->regs), yas5xx->regs);
> > + if (ret) {
> > + dev_err(dev, "cannot enable regulators\n");
>
> regulator_bulk_enable() will log which of the regs it failed ot enable,
> so you can omit this.
>
> Regards,
> Bjorn
next prev parent reply other threads:[~2020-11-28 22:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-28 0:40 [PATCH 1/2 v2] iio: accel: yamaha-yas53x: Add DT bindings Linus Walleij
2020-11-28 0:40 ` [PATCH 2/2 v2] iio: magnetometer: Add driver for Yamaha YAS5xx Linus Walleij
2020-11-28 4:09 ` Bjorn Andersson
2020-11-28 11:27 ` Jonathan Cameron [this message]
2020-11-28 11:33 ` Linus Walleij
2020-11-28 12:21 ` Jonathan Cameron
2020-11-28 21:04 ` Linus Walleij
2020-11-29 11:26 ` Jonathan Cameron
2020-11-29 20:42 ` Linus Walleij
2020-11-28 11:37 ` [PATCH 1/2 v2] iio: accel: yamaha-yas53x: Add DT bindings 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=20201128112735.57398b74@archlinux \
--to=jic23@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=phone-devel@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;
as well as URLs for NNTP newsgroup(s).