[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220731171624.3d4bb241@jic23-huawei>
Date: Sun, 31 Jul 2022 17:16:24 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Angel Iglesias <ang.iglesiasg@...il.com>
Cc: linux-iio@...r.kernel.org, Lars-Peter Clausen <lars@...afoo.de>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Nikita Yushchenko <nikita.yoush@...entembedded.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Paul Cercueil <paul@...pouillou.net>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 4/5] iio: pressure: bmp280: Add support for BMP380
sensor family
On Sat, 23 Jul 2022 19:39:44 +0200
Angel Iglesias <ang.iglesiasg@...il.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@...il.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.
> + 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;
> +}
> +
Powered by blists - more mailing lists