[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240824111028.GA9644@vamoiridPC>
Date: Sat, 24 Aug 2024 13:10:28 +0200
From: Vasileios Amoiridis <vassilisamir@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Vasileios Amoiridis <vassilisamir@...il.com>, jic23@...nel.org,
lars@...afoo.de, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, ang.iglesiasg@...il.com,
linus.walleij@...aro.org, biju.das.jz@...renesas.com,
javier.carrasco.cruz@...il.com, semen.protsenko@...aro.org,
579lpy@...il.com, ak@...klinger.de, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/7] iio: pressure: bmp280: Use bulk read for humidity
calibration data
On Fri, Aug 23, 2024 at 09:47:22PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 23, 2024 at 08:17:08PM +0200, Vasileios Amoiridis wrote:
> > Convert individual reads to a bulk read for the humidity calibration data.
>
> ...
>
> > + calib->H2 = get_unaligned_le16(&data->bme280_humid_cal_buf[H2]);
> > + calib->H3 = data->bme280_humid_cal_buf[H3];
>
> > + h4_upper = FIELD_GET(BME280_COMP_H4_GET_MASK_UP,
> > + get_unaligned_be16(&data->bme280_humid_cal_buf[H4]));
> > + h4_upper = FIELD_PREP(BME280_COMP_H4_PREP_MASK_UP, h4_upper);
>
> This is a bit confusing. I would add a tmp variable and have this as
>
> tmp = FIELD_GET(BME280_COMP_H4_GET_MASK_UP,
> get_unaligned_be16(&data->bme280_humid_cal_buf[H4]));
> h4_upper = FIELD_PREP(BME280_COMP_H4_PREP_MASK_UP, tmp);
>
> Also note indentation issues.
>
Hi Andy,
It's been a long time since you last reviewed code of mine, thanks for
finding the time to do this, I appreciate it a lot!
You are right, it looks confusing, I can do what you proposed. I don't
know how I didn't see it before.
Cheers,
Vasilis
> > + h4_lower = FIELD_GET(BME280_COMP_H4_MASK_LOW,
> > + get_unaligned_be16(&data->bme280_humid_cal_buf[H4]));
> > + calib->H4 = sign_extend32(h4_upper | h4_lower, 11);
> > + calib->H5 = sign_extend32(FIELD_GET(BME280_COMP_H5_MASK,
> > + get_unaligned_le16(&data->bme280_humid_cal_buf[H5])), 11);
> > + calib->H6 = data->bme280_humid_cal_buf[H6];
>
> ...
>
> > /* Calibration data buffers */
> > __le16 bmp280_cal_buf[BMP280_CONTIGUOUS_CALIB_REGS / 2];
> > __be16 bmp180_cal_buf[BMP180_REG_CALIB_COUNT / 2];
>
> Side note: I would see rather sizeof(__Xe16) than 2:s in the above definitions.
>
> > + u8 bme280_humid_cal_buf[BME280_CONTIGUOUS_CALIB_REGS];
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Powered by blists - more mailing lists