Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: tsc2007 - use guard notation when acquiring mutexes

This makes the code more compact and error handling more robust.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+6 -10
+4 -3
drivers/input/touchscreen/tsc2007_core.c
··· 122 122 123 123 /* pen is down, continue with the measurement */ 124 124 125 - mutex_lock(&ts->mlock); 126 - tsc2007_read_values(ts, &tc); 127 - mutex_unlock(&ts->mlock); 125 + /* Serialize access between the ISR and IIO reads. */ 126 + scoped_guard(mutex, &ts->mlock) { 127 + tsc2007_read_values(ts, &tc); 128 + } 128 129 129 130 rt = tsc2007_calculate_resistance(ts, &tc); 130 131
+2 -7
drivers/input/touchscreen/tsc2007_iio.c
··· 41 41 struct tsc2007_iio *iio = iio_priv(indio_dev); 42 42 struct tsc2007 *tsc = iio->ts; 43 43 int adc_chan = chan->channel; 44 - int ret = 0; 45 44 46 45 if (adc_chan >= ARRAY_SIZE(tsc2007_iio_channel)) 47 46 return -EINVAL; ··· 48 49 if (mask != IIO_CHAN_INFO_RAW) 49 50 return -EINVAL; 50 51 51 - mutex_lock(&tsc->mlock); 52 + guard(mutex)(&tsc->mlock); 52 53 53 54 switch (chan->channel) { 54 55 case 0: ··· 91 92 /* Prepare for next touch reading - power down ADC, enable PENIRQ */ 92 93 tsc2007_xfer(tsc, PWRDOWN); 93 94 94 - mutex_unlock(&tsc->mlock); 95 - 96 - ret = IIO_VAL_INT; 97 - 98 - return ret; 95 + return IIO_VAL_INT; 99 96 } 100 97 101 98 static const struct iio_info tsc2007_iio_info = {