hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/iio/gyro/adis16080.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ADIS16080/100 Yaw Rate Gyroscope with SPI driver
34 *
45 * Copyright 2010 Analog Devices Inc.
5
- *
6
- * Licensed under the GPL-2 or later.
76 */
87 #include <linux/delay.h>
98 #include <linux/mutex.h>
....@@ -39,10 +38,12 @@
3938 * @us: actual spi_device to write data
4039 * @info: chip specific parameters
4140 * @buf: transmit or receive buffer
41
+ * @lock: lock to protect buffer during reads
4242 **/
4343 struct adis16080_state {
4444 struct spi_device *us;
4545 const struct adis16080_chip_info *info;
46
+ struct mutex lock;
4647
4748 __be16 buf ____cacheline_aligned;
4849 };
....@@ -83,9 +84,9 @@
8384
8485 switch (mask) {
8586 case IIO_CHAN_INFO_RAW:
86
- mutex_lock(&indio_dev->mlock);
87
+ mutex_lock(&st->lock);
8788 ret = adis16080_read_sample(indio_dev, chan->address, val);
88
- mutex_unlock(&indio_dev->mlock);
89
+ mutex_unlock(&st->lock);
8990 return ret ? ret : IIO_VAL_INT;
9091 case IIO_CHAN_INFO_SCALE:
9192 switch (chan->type) {
....@@ -197,6 +198,8 @@
197198 /* this is only used for removal purposes */
198199 spi_set_drvdata(spi, indio_dev);
199200
201
+ mutex_init(&st->lock);
202
+
200203 /* Allocate the comms buffers */
201204 st->us = spi;
202205 st->info = &adis16080_chip_info[id->driver_data];
....@@ -204,7 +207,6 @@
204207 indio_dev->name = spi->dev.driver->name;
205208 indio_dev->channels = adis16080_channels;
206209 indio_dev->num_channels = ARRAY_SIZE(adis16080_channels);
207
- indio_dev->dev.parent = &spi->dev;
208210 indio_dev->info = &adis16080_info;
209211 indio_dev->modes = INDIO_DIRECT_MODE;
210212