On 08/01/2015 05:58 AM, Matt Ranostay wrote: > +static int lidar_read_raw(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, > + int *val, int *val2, long mask) > +{ > + struct lidar_data *data = iio_priv(indio_dev); > + int ret = -EINVAL; > + > + if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) > + return -EBUSY; For this to work without race conditions you need to hold the indio_dev->mlock while doing the check and until the conversion is done. > + > + mutex_lock(&data->lock); > + > + switch (mask) { > + case IIO_CHAN_INFO_RAW: { > + u16 reg; > + > + ret = lidar_get_measurement(data, ®); > + if (!ret) { > + *val = reg / 100; > + *val2 = (reg % 100) * 10000; > + ret = IIO_VAL_INT_PLUS_MICRO; > + } > + break; > + } -- 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