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.

iio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw()

Simplify the locking scheme in rzg2l_adc_read_raw() by using
guard(mutex)().

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-8-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Claudiu Beznea and committed by
Jonathan Cameron
5d7fb2d5 b7549624

+7 -6
+7 -6
drivers/iio/adc/rzg2l_adc.c
··· 8 8 */ 9 9 10 10 #include <linux/bitfield.h> 11 + #include <linux/cleanup.h> 11 12 #include <linux/completion.h> 12 13 #include <linux/delay.h> 13 14 #include <linux/iio/iio.h> ··· 221 220 u8 ch; 222 221 223 222 switch (mask) { 224 - case IIO_CHAN_INFO_RAW: 223 + case IIO_CHAN_INFO_RAW: { 225 224 if (chan->type != IIO_VOLTAGE) 226 225 return -EINVAL; 227 226 228 - mutex_lock(&adc->lock); 227 + guard(mutex)(&adc->lock); 228 + 229 229 ch = chan->channel & RZG2L_ADC_CHN_MASK; 230 230 ret = rzg2l_adc_conversion(indio_dev, adc, ch); 231 - if (ret) { 232 - mutex_unlock(&adc->lock); 231 + if (ret) 233 232 return ret; 234 - } 233 + 235 234 *val = adc->last_val[ch]; 236 - mutex_unlock(&adc->lock); 237 235 238 236 return IIO_VAL_INT; 237 + } 239 238 240 239 default: 241 240 return -EINVAL;