Re: [PATCH v1 2/3] iio: ltr501: Add interrupt rate control support

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

 





On 04/01/2015 07:04 AM, Daniel Baluta wrote:
On Wed, Apr 1, 2015 at 5:55 AM, Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx> wrote:
Added rate control support for ALS and proximity
threshold interrupts.

Setting <n> to ALS intr_persist sysfs node would
generate interrupt whenever ALS data cross either
upper or lower threshold limits <n> number of times.
Similarly setting <m> to proximity intr_persist sysfs
node would genere interrupt whenever proximity data falls
outside threshold limit <m> number of times.

<snip>

+static ssize_t ltr501_read_intr_prst(struct iio_dev *indio_dev,
+                                  uintptr_t private,
+                                  const struct iio_chan_spec *chan,
+                                  char *buf)
+{
+       struct ltr501_data *data = iio_priv(indio_dev);
+       int ret = -EINVAL;
+
+       switch (chan->type) {
+       case IIO_INTENSITY:
+               mutex_lock(&data->lock_als);
+               ret = i2c_smbus_read_byte_data(data->client, LTR501_INTR_PRST);
+               mutex_unlock(&data->lock_als);
I am not sure I understand why is the mutex needed here? AFAIK I2C transactions
are serialized.
That's mutex is to protect the ALS register updates. I want it serialized so that no data can be read when we are changing the control settings.

<snip>

+static const struct iio_chan_spec_ext_info ltr501_ext_info[] = {
+       {
+               .name = "intr_persist",
+               .read = ltr501_read_intr_prst,
+               .write = ltr501_write_intr_prst,
+               .shared = IIO_SHARED_BY_TYPE,
+       },
+       {},
+};
+
Would be nice to standardize persistence attribute (IIO_CHAN_INFO_PERSISTENCE).
Agreed. I will work on it.

thanks,
Daniel.


--
Sathyanarayanan Kuppuswamy
Android kernel developer

--
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