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

staging: iio: adis16240: Remove mutex_lock() and mutex_unlock() function call.

Remove mutex_lock() and mutex_unlock() function calls, as the
adis16240_spi_read_signed() function can be run parallel and safely
multiple times. Also remove the mutex.h header file and comment, which
are no longer required.

As indio_dev is declared and initialized in adis16240_spi_read_signed(),
again declaration to same type and initialization to same value is not
required, remove it from adis16240_read_12bit_signed().

Simplify the return logic, by merging assignment and return into a single
line.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Varsha Rao and committed by
Jonathan Cameron
2e2c8d22 01d2de39

+1 -16
+1 -16
drivers/staging/iio/accel/adis16240.c
··· 10 10 #include <linux/irq.h> 11 11 #include <linux/gpio.h> 12 12 #include <linux/delay.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/device.h> 15 14 #include <linux/kernel.h> 16 15 #include <linux/spi/spi.h> ··· 228 229 struct device_attribute *attr, 229 230 char *buf) 230 231 { 231 - ssize_t ret; 232 - struct iio_dev *indio_dev = dev_to_iio_dev(dev); 233 - 234 - /* Take the iio_dev status lock */ 235 - mutex_lock(&indio_dev->mlock); 236 - ret = adis16240_spi_read_signed(dev, attr, buf, 12); 237 - mutex_unlock(&indio_dev->mlock); 238 - 239 - return ret; 232 + return adis16240_spi_read_signed(dev, attr, buf, 12); 240 233 } 241 234 242 235 static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, 0444, ··· 288 297 return IIO_VAL_INT; 289 298 case IIO_CHAN_INFO_CALIBBIAS: 290 299 bits = 10; 291 - mutex_lock(&indio_dev->mlock); 292 300 addr = adis16240_addresses[chan->scan_index][0]; 293 301 ret = adis_read_reg_16(st, addr, &val16); 294 302 if (ret) { 295 - mutex_unlock(&indio_dev->mlock); 296 303 return ret; 297 304 } 298 305 val16 &= (1 << bits) - 1; 299 306 val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); 300 307 *val = val16; 301 - mutex_unlock(&indio_dev->mlock); 302 308 return IIO_VAL_INT; 303 309 case IIO_CHAN_INFO_PEAK: 304 310 bits = 10; 305 - mutex_lock(&indio_dev->mlock); 306 311 addr = adis16240_addresses[chan->scan_index][1]; 307 312 ret = adis_read_reg_16(st, addr, &val16); 308 313 if (ret) { 309 - mutex_unlock(&indio_dev->mlock); 310 314 return ret; 311 315 } 312 316 val16 &= (1 << bits) - 1; 313 317 val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); 314 318 *val = val16; 315 - mutex_unlock(&indio_dev->mlock); 316 319 return IIO_VAL_INT; 317 320 } 318 321 return -EINVAL;