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@xxxxxxxxx> 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@xxxxxxxxx> > > 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