Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: <jic23@kernel.org>, <linux-iio@vger.kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH] iio: accel: kxsd9: Fix alignment of local buffer.
Date: Mon, 4 May 2020 10:47:50 +0100	[thread overview]
Message-ID: <20200504104750.000073a4@Huawei.com> (raw)
In-Reply-To: <8069360d699a6699eb7768a07681c78e4b94b250.camel@gmail.com>

On Sun, 3 May 2020 20:01:56 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sun, 2020-05-03 at 18:22 +0100, jic23@kernel.org wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > iio_push_to_buffers_with_timestamp assumes 8 byte alignment which
> > is not guaranteed by an array of 8 __be16.
> > 
> > Reported-by: Lars-Peter Clausen <lars@metafoo.de>
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> >  drivers/iio/accel/kxsd9.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
> > index 0b876b2dc5bd..4c42d1200914 100644
> > --- a/drivers/iio/accel/kxsd9.c
> > +++ b/drivers/iio/accel/kxsd9.c
> > @@ -209,14 +209,16 @@ static irqreturn_t kxsd9_trigger_handler(int
> > irq, void *p)
> >  	const struct iio_poll_func *pf = p;
> >  	struct iio_dev *indio_dev = pf->indio_dev;
> >  	struct kxsd9_state *st = iio_priv(indio_dev);
> > +	struct {
> > +		__be16 chan[4];
> > +		u64 ts;
> > +	} hw_values;  
> 
> A nitpick from my side. Maybe a comment woudn't be that noisy. It might
> be not that obvious for some people why this construct is needed and it
> might prevent new driver's from doing the same mistake.

Good point. I'll add something like

/* Ensure correct positioning and alignment of timestamp */

above the struct definition.


> 
> - Nuno Sá
> 
> 



      reply	other threads:[~2020-05-04  9:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 17:22 [PATCH] iio: accel: kxsd9: Fix alignment of local buffer jic23
2020-05-03 18:01 ` Nuno Sá
2020-05-04  9:47   ` Jonathan Cameron [this message]

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=20200504104750.000073a4@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=noname.nuno@gmail.com \
    /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