/* pen is down, continue with the measurement */
- mutex_lock(&ts->mlock);
- tsc2007_read_values(ts, &tc);
- mutex_unlock(&ts->mlock);
+ /* Serialize access between the ISR and IIO reads. */
+ scoped_guard(mutex, &ts->mlock) {
+ tsc2007_read_values(ts, &tc);
+ }
rt = tsc2007_calculate_resistance(ts, &tc);
struct tsc2007_iio *iio = iio_priv(indio_dev);
struct tsc2007 *tsc = iio->ts;
int adc_chan = chan->channel;
- int ret = 0;
if (adc_chan >= ARRAY_SIZE(tsc2007_iio_channel))
return -EINVAL;
if (mask != IIO_CHAN_INFO_RAW)
return -EINVAL;
- mutex_lock(&tsc->mlock);
+ guard(mutex)(&tsc->mlock);
switch (chan->channel) {
case 0:
/* Prepare for next touch reading - power down ADC, enable PENIRQ */
tsc2007_xfer(tsc, PWRDOWN);
- mutex_unlock(&tsc->mlock);
-
- ret = IIO_VAL_INT;
-
- return ret;
+ return IIO_VAL_INT;
}
static const struct iio_info tsc2007_iio_info = {