hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/iio/dac/ad5380.c
....@@ -1,10 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Analog devices AD5380, AD5381, AD5382, AD5383, AD5390, AD5391, AD5392
34 * multi-channel Digital to Analog Converters driver
45 *
56 * Copyright 2011 Analog Devices Inc.
6
- *
7
- * Licensed under the GPL-2.
87 */
98
109 #include <linux/device.h>
....@@ -52,6 +51,7 @@
5251 * @vref_reg: vref supply regulator
5352 * @vref: actual reference voltage used in uA
5453 * @pwr_down: whether the chip is currently in power down mode
54
+ * @lock: lock to protect the data buffer during regmap ops
5555 */
5656
5757 struct ad5380_state {
....@@ -60,6 +60,7 @@
6060 struct regulator *vref_reg;
6161 int vref;
6262 bool pwr_down;
63
+ struct mutex lock;
6364 };
6465
6566 enum ad5380_type {
....@@ -99,7 +100,7 @@
99100 if (ret)
100101 return ret;
101102
102
- mutex_lock(&indio_dev->mlock);
103
+ mutex_lock(&st->lock);
103104
104105 if (pwr_down)
105106 ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0);
....@@ -108,7 +109,7 @@
108109
109110 st->pwr_down = pwr_down;
110111
111
- mutex_unlock(&indio_dev->mlock);
112
+ mutex_unlock(&st->lock);
112113
113114 return ret ? ret : len;
114115 }
....@@ -239,7 +240,7 @@
239240 .write_raw = ad5380_write_raw,
240241 };
241242
242
-static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
243
+static const struct iio_chan_spec_ext_info ad5380_ext_info[] = {
243244 {
244245 .name = "powerdown",
245246 .read = ad5380_read_dac_powerdown,
....@@ -385,12 +386,13 @@
385386 st->chip_info = &ad5380_chip_info_tbl[type];
386387 st->regmap = regmap;
387388
388
- indio_dev->dev.parent = dev;
389389 indio_dev->name = name;
390390 indio_dev->info = &ad5380_info;
391391 indio_dev->modes = INDIO_DIRECT_MODE;
392392 indio_dev->num_channels = st->chip_info->num_channels;
393393
394
+ mutex_init(&st->lock);
395
+
394396 ret = ad5380_alloc_channels(indio_dev);
395397 if (ret) {
396398 dev_err(dev, "Failed to allocate channel spec: %d\n", ret);