From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: Antoni Pokusinski <apokusinski01@gmail.com>,
lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, andrej.skvortzov@gmail.com,
neil.armstrong@linaro.org, icenowy@aosc.io, megi@xff.cz,
danila@jiaxyga.com, javier.carrasco.cruz@gmail.com,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: magnetometer: si7210: add driver for Si7210
Date: Sat, 18 Jan 2025 16:16:22 +0000 [thread overview]
Message-ID: <20250118161622.6b96f998@jic23-huawei> (raw)
In-Reply-To: <Z4jCz1VXVPtEDNqB@smile.fi.intel.com>
On Thu, 16 Jan 2025 10:26:55 +0200
Andy Shevchenko <andy@kernel.org> wrote:
> On Wed, Jan 15, 2025 at 09:16:22PM +0100, Antoni Pokusinski wrote:
> > Silicon Labs Si7210 is an I2C Hall effect magnetic position and
> > temperature sensor. The driver supports the following functionalities:
> > * reading the temperature measurements
> > * reading the magnetic field measurements in a single-shot mode
> > * choosing the magnetic field measurement scale (20 or 200 mT)
>
> ...
>
> > +obj-$(CONFIG_SI7210) += si7210.o
>
> Looks like TAB/space mixture in the middle.
>
> ...
>
> > +#include <asm/byteorder.h>
>
> asm/* usually goes after linux/*
>
> > +#include <linux/array_size.h>
> > +#include <linux/bitfield.h>
> > +#include <linux/bits.h>
> > +#include <linux/cleanup.h>
> > +#include <linux/err.h>
> > +#include <linux/i2c.h>
> > +#include <linux/iio/iio.h>
> > +#include <linux/math64.h>
> > +#include <linux/mod_devicetable.h>
> > +#include <linux/mutex.h>
> > +#include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/types.h>
> > +#include <linux/units.h>
>
> ...
>
> Despite a good formatting I would still add a comment with a formula in
> math-human-readable form.
The rest of the comments are the sort of thing I might tweak.
This one not so much as I'll probably get the maths wrong.
Given where we are with the cycle (too late 6.14, too early for 6.15
beyond me queuing it up in testing for autobuilders to get an early lok)
we have plenty of time so I'd prefer to pick up a v5 with this comment
added and the other minor stuff tidied up.
FWIW I took a look at the overall driver and have nothing to add
in the way of review comments!
Jonathan
>
> > + temp = FIELD_GET(GENMASK(14, 3), dspsig);
> > + temp = div_s64(-383 * temp * temp, 100) + 160940 * temp - 279800000;
> > + temp *= (1 + (data->temp_gain / 2048));
> > + temp += (int)(MICRO / 16) * data->temp_offset;
>
> > + ret = regulator_get_voltage(data->vdd);
> > + if (ret < 0)
> > + return ret;
> > +
> > + temp -= 222 * div_s64(ret, MILLI);
>
> Including this piece.
>
> > + *val = div_s64(temp, MILLI);
>
> ...
>
> > +static int si7210_set_scale(struct si7210_data *data, unsigned int scale)
> > +{
> > + s8 *a_otp_values;
> > + int ret;
> > +
> > + if (scale == 20)
> > + a_otp_values = data->scale_20_a;
> > + else if (scale == 200)
> > + a_otp_values = data->scale_200_a;
> > + else
> > + return -EINVAL;
> > +
> > + guard(mutex)(&data->fetch_lock);
> > +
> > + /* Write the registers 0xCA - 0xCC */
> > + ret = regmap_bulk_write(data->regmap, SI7210_REG_A0, a_otp_values, 3);
> > + if (ret)
> > + return ret;
>
> > + /* Write the registers 0xCE - 0xD0 */
> > + ret = regmap_bulk_write(data->regmap, SI7210_REG_A3, &a_otp_values[3], 3);
> > + if (ret)
> > + return ret;
>
> Just to be sure I understand the above. There are two of 24-bit values or there are
> two sets of 3 byte arrays? How does datasheet refers to them? What does common sense
> tell us here?
>
> > + data->curr_scale = scale;
> > +
> > + return 0;
> > +}
>
> ...
>
> Overall LGTM, there is no need for resend as I believe the three things above
> may be tweaked by Jonathan. The last one can go even if there are 2 24-bit
> values, but ideally in that case we should use those as a such and apply
> put_unaligned_be24/le24() whichever suits better.
>
prev parent reply other threads:[~2025-01-18 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 20:16 [PATCH v4 0/2] iio: magnetometer: add support for Si7210 Antoni Pokusinski
2025-01-15 20:16 ` [PATCH v4 1/2] dt-bindings: iio: magnetometer: add binding " Antoni Pokusinski
2025-01-15 20:24 ` Antoni Pokusinski
2025-01-16 7:52 ` Krzysztof Kozlowski
2025-01-15 20:16 ` [PATCH v4 2/2] iio: magnetometer: si7210: add driver " Antoni Pokusinski
2025-01-16 8:26 ` Andy Shevchenko
2025-01-16 20:05 ` Antoni Pokusinski
2025-01-17 13:46 ` Andy Shevchenko
2025-01-18 16:16 ` 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=20250118161622.6b96f998@jic23-huawei \
--to=jic23@kernel.org \
--cc=andrej.skvortzov@gmail.com \
--cc=andy@kernel.org \
--cc=apokusinski01@gmail.com \
--cc=conor+dt@kernel.org \
--cc=danila@jiaxyga.com \
--cc=devicetree@vger.kernel.org \
--cc=icenowy@aosc.io \
--cc=javier.carrasco.cruz@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=megi@xff.cz \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
/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