RE: [PATCH v3 3/3] iio: add driver for Freescale MMA9553

From: Tirdea, Irina
Date: Wed Apr 08 2015 - 11:47:50 EST




> -----Original Message-----
> From: linux-iio-owner@xxxxxxxxxxxxxxx [mailto:linux-iio-owner@xxxxxxxxxxxxxxx] On Behalf Of Tirdea, Irina
> Sent: 06 April, 2015 17:33
> To: Hartmut Knaack; Jonathan Cameron; linux-iio@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx; Baluta, Daniel; Lars-Peter Clausen; Peter Meerwald
> Subject: RE: [PATCH v3 3/3] iio: add driver for Freescale MMA9553
>
>
>
> > -----Original Message-----
> > From: Hartmut Knaack [mailto:knaack.h@xxxxxx]
> > Sent: 05 April, 2015 2:18
> > To: Tirdea, Irina; Jonathan Cameron; linux-iio@xxxxxxxxxxxxxxx
> > Cc: linux-kernel@xxxxxxxxxxxxxxx; Baluta, Daniel; Lars-Peter Clausen; Peter Meerwald
> > Subject: Re: [PATCH v3 3/3] iio: add driver for Freescale MMA9553
> >
> > Irina Tirdea schrieb am 27.01.2015 um 19:41:
> > > Add support for Freescale MMA9553L Intelligent Pedometer Platform.
> > >
> > > The following functionalities are supported:
> > > - step counter (counts the number of steps using a HW register)
> > > - step detector (generates an iio event at every step the user takes)
> > > - activity recognition (rest, walking, jogging, running)
> > > - speed
> > > - calories
> > > - distance
> > >
<snip>
> > > +static int mma9553_read_activity_stepcnt(struct mma9553_data *data,
> > > + u8 *activity, u16 *stepcnt)
> > > +{
> > > + u32 status_stepcnt;
> > > + u16 status;
> > > + int ret;
> > > +
> > > + ret = mma9551_read_status_words(data->client, MMA9551_APPID_PEDOMETER,
> > > + MMA9553_REG_STATUS, sizeof(u32),
> > > + (u16 *) &status_stepcnt);
> > > + if (ret < 0) {
> > > + dev_err(&data->client->dev,
> > > + "error reading status and stepcnt\n");
> > > + return ret;
> > > + }
> > > +
> >
> > I think this could be done a bit simpler by using u16 buf[2] instead of
> > status_stepcnt (making status obsolete). That's what it would boil down
> > to:
> > *activity = mma9553_get_bits(buf[0], MMA9553_MASK_STATUS_ACTIVITY);
> > *stepcnt = buf[1];
> >
> That does look more simple. Will change it accordingly.
This does not only look more simple, it actually fixes an endianness bug on big endian hosts.
Thanks for the suggestion!

Irina
<snip>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/