Re: [PATCH v2 5/5] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer

From: Mehdi Djait
Date: Mon Apr 24 2023 - 10:57:06 EST


Hello again,

On Sun, Apr 23, 2023 at 10:57:00PM +0200, Mehdi Djait wrote:
> Hello Andy,
>
> thank you for the review.
>
> On Sat, Apr 22, 2023 at 07:09:12PM +0300, Andy Shevchenko wrote:
> > On Sat, Apr 22, 2023 at 07:19:44AM +0800, kernel test robot wrote:
> > > Hi Mehdi,
> > >
> > > kernel test robot noticed the following build warnings:
> >
> > I believe it's not just a warning, it's a full functional error in the code.
> >
> > > 686 {
> > > 687 struct device *dev = regmap_get_device(data->regmap);
> > > 688 __le16 buf_status;
> > > 689 int ret, fifo_bytes;
> > > 690
> > > 691 ret = regmap_bulk_read(data->regmap, data->chip_info->buf_status1,
> > > 692 &buf_status, sizeof(buf_status));
> > > 693 if (ret) {
> > > 694 dev_err(dev, "Error reading buffer status\n");
> > > 695 return ret;
> > > 696 }
> > > 697
> > > > 698 buf_status &= data->chip_info->buf_smp_lvl_mask;
> > > 699 fifo_bytes = le16_to_cpu(buf_status);
> >
> > You need to mask in the same endianess space, i.o.w. either on CPU or device side.
> >
> > I believe you wanted to have fifo_bytes to be masked, but I'm not sure.
>
> I wanted to read the registers buf_status_1 and buf_status_2 --> 16 bits
> and mask the result of the read to get the bits 0..9 which is the
> buf_status: the number of bytes in the buffer
>
> This is due to my lack of experience, but I have a question:
> If I don't get any warnings when testing, how should I go about this ? I
> will obviously fix this, but this is for the future.

just ignore this question. I installed sparse and I am using it now when
building.

--
Kind Regards
Mehdi Djait