Re: [RFC 2/8] iio: bmc150: refactor slope duration and threshold update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 23, 2014 at 11:58 PM, Hartmut Knaack <knaack.h@xxxxxx> wrote:
>
> Octavian Purdila schrieb am 17.11.2014 18:56:
> > Move the slope duration and threshold update in separate functions
> > to reduce code duplicate between chip init and motion interrupt setup.
> >
> > The patch also moves the update from the motion interrupt setup
> > function to the write event function so that we can later refactor the
> > interrupt code.
> >
> > Signed-off-by: Octavian Purdila <octavian.purdila@xxxxxxxxx>
> > ---
> >  drivers/iio/accel/bmc150-accel.c | 109 ++++++++++++++++++++++-----------------
> >  1 file changed, 62 insertions(+), 47 deletions(-)
> >
> > diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
> > index 22c096c..5bfb09d 100644
> > --- a/drivers/iio/accel/bmc150-accel.c
> > +++ b/drivers/iio/accel/bmc150-accel.c
> > @@ -266,6 +266,51 @@ static int bmc150_accel_set_bw(struct bmc150_accel_data *data, int val,
> >       return -EINVAL;
> >  }
> >
> > +static int bmc150_accel_update_slope_threshold(struct bmc150_accel_data *data,
> > +                                            int val)
> > +{
> > +     int ret = 0;
> > +
> > +     val &= 0xFF;
> > +
> > +     ret = i2c_smbus_write_byte_data(data->client, BMC150_ACCEL_REG_INT_6,
> > +                                     val);
> > +     if (ret < 0) {
> > +             dev_err(&data->client->dev, "Error writing reg_int_6\n");
> > +             return ret;
> > +     }
> > +     data->slope_thres = val;
> > +
> > +     dev_dbg(&data->client->dev, "%s: %x\n", __func__, val);
> > +
> > +     return ret;
> > +}
> > +
> > +static int bmc150_accel_update_slope_duration(struct bmc150_accel_data *data,
> > +                                           int val)
> > +{
> > +     int ret;
> > +
> > +     val &= BMC150_ACCEL_SLOPE_DUR_MASK;
> > +
> > +     ret = i2c_smbus_read_byte_data(data->client, BMC150_ACCEL_REG_INT_5);
> > +     if (ret < 0) {
> > +             dev_err(&data->client->dev, "Error reading reg_int_5\n");
> > +             return ret;
> > +     }
> > +     ret = i2c_smbus_write_byte_data(data->client, BMC150_ACCEL_REG_INT_5,
> > +                                     val | ret);
> You will have more joy if you clear the appropriate bits in ret before setting new ones.

Yes, Daniel caught as well. I will fix it in v2.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux