linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Stephan Gerhold" <stephan@gerhold.net>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Hans de Goede" <hdegoede@redhat.com>
Subject: Re: [PATCH 04/19] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Date: Thu, 13 May 2021 18:33:26 +0100	[thread overview]
Message-ID: <20210513183326.0f39cb74@jic23-huawei> (raw)
In-Reply-To: <CAHp75Vc9hOe66LaC7AzbmbZ5+EMCSdgCnxCLY0NQdurmWtyFVQ@mail.gmail.com>

On Sat, 1 May 2021 22:10:48 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sat, May 1, 2021 at 8:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > To make code more readable, use a structure to express the channel
> > layout and ensure the timestamp is 8 byte aligned.
> >
> > Found during an audit of all calls of this function.
> >
> > Fixes: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > ---
> >  drivers/iio/accel/kxcjk-1013.c | 24 ++++++++++++++----------
> >  1 file changed, 14 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> > index ff724bc17a45..96ab247f17b3 100644
> > --- a/drivers/iio/accel/kxcjk-1013.c
> > +++ b/drivers/iio/accel/kxcjk-1013.c
> > @@ -133,6 +133,13 @@ enum kx_acpi_type {
> >         ACPI_KIOX010A,
> >  };
> >
> > +enum kxcjk1013_axis {
> > +       AXIS_X,
> > +       AXIS_Y,
> > +       AXIS_Z,  
> 
> > +       AXIS_MAX,  
> 
> I see that this is from original code, though I think you have a
> chance to remove unneeded comma here. Let's make the terminator line
> terminate.

Good idea.  Did that whilst applying.  This one had a lot of fuzz
due to support of new parts added to the driver in the meantime, but
the patch seems to have applied cleanly.

+CC various people involved in that series so they know this change
is going in as well (and can perhaps give it a spin!:)

Thanks,

Jonathan

> 
> > +};
> > +
> >  struct kxcjk1013_data {
> >         struct regulator_bulk_data regulators[2];
> >         struct i2c_client *client;
> > @@ -140,7 +147,11 @@ struct kxcjk1013_data {
> >         struct iio_trigger *motion_trig;
> >         struct iio_mount_matrix orientation;
> >         struct mutex mutex;
> > -       s16 buffer[8];
> > +       /* Ensure timestamp naturally aligned */
> > +       struct {
> > +               s16 chans[AXIS_MAX];
> > +               s64 timestamp __aligned(8);
> > +       } scan;
> >         u8 odr_bits;
> >         u8 range;
> >         int wake_thres;
> > @@ -154,13 +165,6 @@ struct kxcjk1013_data {
> >         enum kx_acpi_type acpi_type;
> >  };
> >
> > -enum kxcjk1013_axis {
> > -       AXIS_X,
> > -       AXIS_Y,
> > -       AXIS_Z,
> > -       AXIS_MAX,
> > -};
> > -
> >  enum kxcjk1013_mode {
> >         STANDBY,
> >         OPERATION,
> > @@ -1094,12 +1098,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
> >         ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
> >                                                         KXCJK1013_REG_XOUT_L,
> >                                                         AXIS_MAX * 2,
> > -                                                       (u8 *)data->buffer);
> > +                                                       (u8 *)data->scan.chans);
> >         mutex_unlock(&data->mutex);
> >         if (ret < 0)
> >                 goto err;
> >
> > -       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> > +       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
> >                                            data->timestamp);
> >  err:
> >         iio_trigger_notify_done(indio_dev->trig);
> > --
> > 2.31.1
> >  
> 
> 


  reply	other threads:[~2021-05-13 17:32 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01 17:01 [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Jonathan Cameron
2021-05-01 17:01 ` [PATCH 01/19] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
2021-05-13 17:22   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 02/19] iio: accel: bma220: " Jonathan Cameron
2021-05-13 17:26   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 03/19] iio: accel: hid: " Jonathan Cameron
2021-05-13 17:28   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 04/19] iio: accel: kxcjk-1013: " Jonathan Cameron
2021-05-01 19:10   ` Andy Shevchenko
2021-05-13 17:33     ` Jonathan Cameron [this message]
2021-05-01 17:01 ` [PATCH 05/19] iio: accel: mxc4005: Fix overread of data and alignment issue Jonathan Cameron
2021-05-13 17:37   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 06/19] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Jonathan Cameron
2021-05-13 17:39   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 07/19] iio: accel: stk8ba50: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 08/19] iio: adc: ti-ads1015: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 09/19] iio: adc: vf610: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 10/19] iio: gyro: bmg160: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 11/19] iio: humidity: am2315: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 12/19] iio: prox: srf08: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 13/19] iio: prox: pulsed-light: " Jonathan Cameron
2021-05-06  6:46   ` Matt Ranostay
2021-05-01 17:01 ` [PATCH 14/19] iio: prox: as3935: " Jonathan Cameron
2021-05-06  6:45   ` Matt Ranostay
2021-05-01 17:01 ` [PATCH 15/19] iio: magn: hmc5843: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 16/19] iio: magn: bmc150: " Jonathan Cameron
2021-05-05 12:57   ` Linus Walleij
2021-05-07  9:23     ` Jonathan Cameron
2021-05-13 17:50   ` Jonathan Cameron
2021-05-01 17:01 ` [PATCH 17/19] iio: light: isl29125: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 18/19] iio: light: tcs3414: " Jonathan Cameron
2021-05-01 17:01 ` [PATCH 19/19] iio: light: tcs3472: " Jonathan Cameron
2021-05-01 19:09   ` Andy Shevchenko
2021-05-01 19:12 ` [PATCH 00/19] IIO: Alignment fixes part 2 - struct used to ensure alignment Andy Shevchenko
2021-05-13 17:54   ` Jonathan Cameron

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=20210513183326.0f39cb74@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=stephan@gerhold.net \
    --subject='Re: [PATCH 04/19] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox