From: Angel Iglesias <ang.iglesiasg@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Paul Cercueil <paul@crapouillou.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/5] iio: pressure: bmp280: Add support for BMP380 sensor family
Date: Mon, 01 Aug 2022 09:57:56 +0200 [thread overview]
Message-ID: <38786c4f1217102840eccd50cd9df530caed2add.camel@gmail.com> (raw)
In-Reply-To: <20220731171624.3d4bb241@jic23-huawei>
On dom, 2022-07-31 at 17:16 +0100, Jonathan Cameron wrote:
> On Sat, 23 Jul 2022 19:39:44 +0200
> Angel Iglesias <ang.iglesiasg@gmail.com> wrote:
>
> > Adds compatibility with the new generation of this sensor, the BMP380
> >
> > Includes basic sensor initialization to do pressure and temp
> > measurements and allows tuning oversampling settings for each channel.
> >
> > The compensation algorithms are adapted from the device datasheet and
> > the repository https://github.com/BoschSensortec/BMP3-Sensor-API
> >
> > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com>
>
> Hi Angel,
>
> A comment below. Follows on from comment on previous patch rather than being a
> suggestion to change anything in here (beyond what has already been raised by
> others!)
>
> Jonathan
>
> > +static int bmp380_read_calib(struct bmp280_data *data, unsigned int chip)
> > +{
> > + struct bmp380_calib *calib = &data->calib.bmp380;
> > + int ret;
> > + u8 *buf;
> > +
> > + buf = kmalloc(BMP380_CALIB_REG_COUNT, GFP_KERNEL);
>
> Ah. The complexity in here explains somewhat why you did it with u8 in the
> previous
> patch. Probably still better to have a __be16 buffer for that one though
> even though we can't do that here.
Yes, I thought that, although I had to make more cumbersome the conversions and
do the +2 increment on the enum with the index, it would be better to have a
somewhat more uniform structure in each calib reading function.
> > + if (!buf)
> > + return -ENOMEM;
> > +
> > + /* Read temperature calibration values. */
> > + ret = regmap_bulk_read(data->regmap, BMP380_REG_CALIB_TEMP_START,
> > buf,
> > + BMP380_CALIB_REG_COUNT);
> > + if (ret < 0) {
> > + dev_err(data->dev,
> > + "failed to read temperature calibration
> > parameters\n");
> > + kfree(buf);
> > + return ret;
> > + }
> > +
> > + /* Toss the temperature calibration data into the entropy pool */
> > + add_device_randomness(buf, BMP380_CALIB_REG_COUNT);
> > +
> > + /* Parse calibration data */
> > + calib->T1 = get_unaligned_le16(&buf[BMP380_T1]);
> > + calib->T2 = get_unaligned_le16(&buf[BMP380_T2]);
> > + calib->T3 = buf[BMP380_T3];
> > + calib->P1 = get_unaligned_le16(&buf[BMP380_P1]);
> > + calib->P2 = get_unaligned_le16(&buf[BMP380_P2]);
> > + calib->P3 = buf[BMP380_P3];
> > + calib->P4 = buf[BMP380_P4];
> > + calib->P5 = get_unaligned_le16(&buf[BMP380_P5]);
> > + calib->P6 = get_unaligned_le16(&buf[BMP380_P6]);
> > + calib->P7 = buf[BMP380_P7];
> > + calib->P8 = buf[BMP380_P8];
> > + calib->P9 = get_unaligned_le16(&buf[BMP380_P9]);
> > + calib->P10 = buf[BMP380_P10];
> > + calib->P11 = buf[BMP380_P11];
> > +
> > + kfree(buf);
> > + return 0;
> > +}
> > +
Thanks for your comments,
Kind regards,
Angel
next prev parent reply other threads:[~2022-08-01 7:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-23 17:36 [PATCH v4 0/5] Add support for pressure sensor Bosch BMP380 Angel Iglesias
2022-07-23 17:38 ` [PATCH v4 1/5] dt-bindings: iio: pressure: bmp085: Add BMP380 compatible string Angel Iglesias
2022-07-23 17:38 ` [PATCH v4 2/5] iio: pressure: bmp280: simplify driver initialization logic Angel Iglesias
2022-07-25 21:05 ` Andy Shevchenko
2022-07-23 17:39 ` [PATCH v4 3/5] iio: pressure: bmp280: Fix alignment for DMA safety Angel Iglesias
2022-07-25 21:08 ` Andy Shevchenko
2022-07-31 16:07 ` Jonathan Cameron
2022-07-31 16:13 ` Jonathan Cameron
2022-08-01 8:08 ` Angel Iglesias
2022-07-23 17:39 ` [PATCH v4 4/5] iio: pressure: bmp280: Add support for BMP380 sensor family Angel Iglesias
2022-07-23 22:50 ` kernel test robot
2022-07-24 0:02 ` kernel test robot
2022-07-24 0:22 ` kernel test robot
2022-07-25 21:15 ` Andy Shevchenko
2022-08-01 7:49 ` Angel Iglesias
2022-07-31 16:16 ` Jonathan Cameron
2022-08-01 7:57 ` Angel Iglesias [this message]
2022-07-23 17:40 ` [PATCH v4 5/5] iio: pressure: bmp280: Add more tunable config parameters for BMP380 Angel Iglesias
2022-07-25 21:19 ` Andy Shevchenko
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=38786c4f1217102840eccd50cd9df530caed2add.camel@gmail.com \
--to=ang.iglesiasg@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikita.yoush@cogentembedded.com \
--cc=paul@crapouillou.net \
--cc=rafael.j.wysocki@intel.com \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).