diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-25 13:50:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-25 13:50:03 -0400 |
commit | ef994fda44d6b55ffef7bfdf06f645ff2ab1ab1a (patch) | |
tree | 564a62822ebb1f6f7e1f86b0eefc34bc769dff7d /drivers/iio | |
parent | 25eeb667599b192ea850a062d69383ee864c06ab (diff) | |
parent | 51b53dc991ae7eebc5d45b06d576da6486fbf823 (diff) |
Merge tag 'iio-for-3.10a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First set of IIO new drivers and cleanup for the 3.10 cycle.
New stuff
1) Add OF support for specifying mappings between iio devices and their
in kernel consumers.
2) Driver for AD7923 (extra functionality and support for ad7904, ad7914 and
ad7924 added later in series)
3) Driver for Exynos adc (dt suppor for phy added later in series).
4) Make iio_push_event save IRQ context - necessary if it is to be used
within an interrupt handler. Users of this functionality to follow.
5) For iio use the device tree node name to provide the hwmon name attribute
if available.
Removal and moves out of staging
1) Drop the adt7410 driver from IIO now that there is a hmwon driver with
equivalent support. This device is very much targeted at hardware
monitoring so hwmon is a more appropriate host for the driver.
2) Move iio_hwmon driver to drivers/hwmon.
Cleanups
1) Minor cleanup in ST common library.
2) Large set of patches to break the info_mask element which previously used
odd and even bits to specify if a channel attribute was either shared across
similar channels or specific to only one. Now we have two bitmaps, one for
those parameters that are specific to this channel and one for those shared
by all channels with the same type as this one. This has no effect on the
userspace abi. It simplifies the core code and provides more space for new
channel parameters. It has been on the todo list for a long time!
Conflicts:
drivers/iio/dac/ad5064.c
Diffstat (limited to 'drivers/iio')
52 files changed, 1292 insertions, 253 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index dd8ea4284934..bbcbd7101f33 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -60,28 +60,28 @@ static const struct iio_chan_spec accel_3d_channels[] = { | |||
60 | .type = IIO_ACCEL, | 60 | .type = IIO_ACCEL, |
61 | .modified = 1, | 61 | .modified = 1, |
62 | .channel2 = IIO_MOD_X, | 62 | .channel2 = IIO_MOD_X, |
63 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 63 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
64 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 64 | BIT(IIO_CHAN_INFO_SCALE) | |
65 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 65 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
66 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 66 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
67 | .scan_index = CHANNEL_SCAN_INDEX_X, | 67 | .scan_index = CHANNEL_SCAN_INDEX_X, |
68 | }, { | 68 | }, { |
69 | .type = IIO_ACCEL, | 69 | .type = IIO_ACCEL, |
70 | .modified = 1, | 70 | .modified = 1, |
71 | .channel2 = IIO_MOD_Y, | 71 | .channel2 = IIO_MOD_Y, |
72 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 72 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
73 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 73 | BIT(IIO_CHAN_INFO_SCALE) | |
74 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 74 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
75 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 75 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
76 | .scan_index = CHANNEL_SCAN_INDEX_Y, | 76 | .scan_index = CHANNEL_SCAN_INDEX_Y, |
77 | }, { | 77 | }, { |
78 | .type = IIO_ACCEL, | 78 | .type = IIO_ACCEL, |
79 | .modified = 1, | 79 | .modified = 1, |
80 | .channel2 = IIO_MOD_Z, | 80 | .channel2 = IIO_MOD_Z, |
81 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 81 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
82 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 82 | BIT(IIO_CHAN_INFO_SCALE) | |
83 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 83 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
84 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 84 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
85 | .scan_index = CHANNEL_SCAN_INDEX_Z, | 85 | .scan_index = CHANNEL_SCAN_INDEX_Z, |
86 | } | 86 | } |
87 | }; | 87 | }; |
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index c2229a521ab9..7229645bf1d7 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c | |||
@@ -177,8 +177,8 @@ error_ret: | |||
177 | .type = IIO_ACCEL, \ | 177 | .type = IIO_ACCEL, \ |
178 | .modified = 1, \ | 178 | .modified = 1, \ |
179 | .channel2 = IIO_MOD_##axis, \ | 179 | .channel2 = IIO_MOD_##axis, \ |
180 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 180 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
181 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 181 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
182 | .address = KXSD9_REG_##axis, \ | 182 | .address = KXSD9_REG_##axis, \ |
183 | } | 183 | } |
184 | 184 | ||
@@ -186,7 +186,7 @@ static const struct iio_chan_spec kxsd9_channels[] = { | |||
186 | KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z), | 186 | KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z), |
187 | { | 187 | { |
188 | .type = IIO_VOLTAGE, | 188 | .type = IIO_VOLTAGE, |
189 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, | 189 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
190 | .indexed = 1, | 190 | .indexed = 1, |
191 | .address = KXSD9_REG_AUX, | 191 | .address = KXSD9_REG_AUX, |
192 | } | 192 | } |
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index e372257a8494..ab0767e6727e 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig | |||
@@ -30,6 +30,18 @@ config AD7298 | |||
30 | To compile this driver as a module, choose M here: the | 30 | To compile this driver as a module, choose M here: the |
31 | module will be called ad7298. | 31 | module will be called ad7298. |
32 | 32 | ||
33 | config AD7923 | ||
34 | tristate "Analog Devices AD7923 and similar ADCs driver" | ||
35 | depends on SPI | ||
36 | select IIO_BUFFER | ||
37 | select IIO_TRIGGERED_BUFFER | ||
38 | help | ||
39 | Say yes here to build support for Analog Devices | ||
40 | AD7904, AD7914, AD7923, AD7924 4 Channel ADCs. | ||
41 | |||
42 | To compile this driver as a module, choose M here: the | ||
43 | module will be called ad7923. | ||
44 | |||
33 | config AD7791 | 45 | config AD7791 |
34 | tristate "Analog Devices AD7791 ADC driver" | 46 | tristate "Analog Devices AD7791 ADC driver" |
35 | depends on SPI | 47 | depends on SPI |
@@ -91,6 +103,14 @@ config AT91_ADC | |||
91 | help | 103 | help |
92 | Say yes here to build support for Atmel AT91 ADC. | 104 | Say yes here to build support for Atmel AT91 ADC. |
93 | 105 | ||
106 | config EXYNOS_ADC | ||
107 | bool "Exynos ADC driver support" | ||
108 | depends on OF | ||
109 | help | ||
110 | Core support for the ADC block found in the Samsung EXYNOS series | ||
111 | of SoCs for drivers such as the touchscreen and hwmon to use to share | ||
112 | this resource. | ||
113 | |||
94 | config LP8788_ADC | 114 | config LP8788_ADC |
95 | bool "LP8788 ADC driver" | 115 | bool "LP8788 ADC driver" |
96 | depends on MFD_LP8788 | 116 | depends on MFD_LP8788 |
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 2d5f10080d8d..0a825bed43f6 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile | |||
@@ -5,11 +5,13 @@ | |||
5 | obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o | 5 | obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o |
6 | obj-$(CONFIG_AD7266) += ad7266.o | 6 | obj-$(CONFIG_AD7266) += ad7266.o |
7 | obj-$(CONFIG_AD7298) += ad7298.o | 7 | obj-$(CONFIG_AD7298) += ad7298.o |
8 | obj-$(CONFIG_AD7923) += ad7923.o | ||
8 | obj-$(CONFIG_AD7476) += ad7476.o | 9 | obj-$(CONFIG_AD7476) += ad7476.o |
9 | obj-$(CONFIG_AD7791) += ad7791.o | 10 | obj-$(CONFIG_AD7791) += ad7791.o |
10 | obj-$(CONFIG_AD7793) += ad7793.o | 11 | obj-$(CONFIG_AD7793) += ad7793.o |
11 | obj-$(CONFIG_AD7887) += ad7887.o | 12 | obj-$(CONFIG_AD7887) += ad7887.o |
12 | obj-$(CONFIG_AT91_ADC) += at91_adc.o | 13 | obj-$(CONFIG_AT91_ADC) += at91_adc.o |
14 | obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o | ||
13 | obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o | 15 | obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o |
14 | obj-$(CONFIG_MAX1363) += max1363.o | 16 | obj-$(CONFIG_MAX1363) += max1363.o |
15 | obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o | 17 | obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o |
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index bbad9b94cd75..c2744a75c3b0 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c | |||
@@ -201,9 +201,9 @@ static int ad7266_read_raw(struct iio_dev *indio_dev, | |||
201 | .indexed = 1, \ | 201 | .indexed = 1, \ |
202 | .channel = (_chan), \ | 202 | .channel = (_chan), \ |
203 | .address = (_chan), \ | 203 | .address = (_chan), \ |
204 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \ | 204 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
205 | | IIO_CHAN_INFO_SCALE_SHARED_BIT \ | 205 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \ |
206 | | IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ | 206 | | BIT(IIO_CHAN_INFO_OFFSET), \ |
207 | .scan_index = (_chan), \ | 207 | .scan_index = (_chan), \ |
208 | .scan_type = { \ | 208 | .scan_type = { \ |
209 | .sign = (_sign), \ | 209 | .sign = (_sign), \ |
@@ -249,9 +249,9 @@ static AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(s, 's'); | |||
249 | .channel = (_chan) * 2, \ | 249 | .channel = (_chan) * 2, \ |
250 | .channel2 = (_chan) * 2 + 1, \ | 250 | .channel2 = (_chan) * 2 + 1, \ |
251 | .address = (_chan), \ | 251 | .address = (_chan), \ |
252 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \ | 252 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
253 | | IIO_CHAN_INFO_SCALE_SHARED_BIT \ | 253 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \ |
254 | | IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ | 254 | | BIT(IIO_CHAN_INFO_OFFSET), \ |
255 | .scan_index = (_chan), \ | 255 | .scan_index = (_chan), \ |
256 | .scan_type = { \ | 256 | .scan_type = { \ |
257 | .sign = _sign, \ | 257 | .sign = _sign, \ |
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index b34d754994d5..03b77189dbfe 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c | |||
@@ -63,8 +63,8 @@ struct ad7298_state { | |||
63 | .type = IIO_VOLTAGE, \ | 63 | .type = IIO_VOLTAGE, \ |
64 | .indexed = 1, \ | 64 | .indexed = 1, \ |
65 | .channel = index, \ | 65 | .channel = index, \ |
66 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 66 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
67 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 67 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
68 | .address = index, \ | 68 | .address = index, \ |
69 | .scan_index = index, \ | 69 | .scan_index = index, \ |
70 | .scan_type = { \ | 70 | .scan_type = { \ |
@@ -80,9 +80,9 @@ static const struct iio_chan_spec ad7298_channels[] = { | |||
80 | .type = IIO_TEMP, | 80 | .type = IIO_TEMP, |
81 | .indexed = 1, | 81 | .indexed = 1, |
82 | .channel = 0, | 82 | .channel = 0, |
83 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 83 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
84 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | 84 | BIT(IIO_CHAN_INFO_SCALE) | |
85 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, | 85 | BIT(IIO_CHAN_INFO_OFFSET), |
86 | .address = AD7298_CH_TEMP, | 86 | .address = AD7298_CH_TEMP, |
87 | .scan_index = -1, | 87 | .scan_index = -1, |
88 | .scan_type = { | 88 | .scan_type = { |
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 1491fa6debb2..2e98bef4af67 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c | |||
@@ -140,12 +140,12 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, | |||
140 | return -EINVAL; | 140 | return -EINVAL; |
141 | } | 141 | } |
142 | 142 | ||
143 | #define _AD7476_CHAN(bits, _shift, _info_mask) \ | 143 | #define _AD7476_CHAN(bits, _shift, _info_mask_sep) \ |
144 | { \ | 144 | { \ |
145 | .type = IIO_VOLTAGE, \ | 145 | .type = IIO_VOLTAGE, \ |
146 | .indexed = 1, \ | 146 | .indexed = 1, \ |
147 | .info_mask = _info_mask | \ | 147 | .info_mask_separate = _info_mask_sep, \ |
148 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 148 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
149 | .scan_type = { \ | 149 | .scan_type = { \ |
150 | .sign = 'u', \ | 150 | .sign = 'u', \ |
151 | .realbits = (bits), \ | 151 | .realbits = (bits), \ |
@@ -156,9 +156,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, | |||
156 | } | 156 | } |
157 | 157 | ||
158 | #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits), \ | 158 | #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits), \ |
159 | IIO_CHAN_INFO_RAW_SEPARATE_BIT) | 159 | BIT(IIO_CHAN_INFO_RAW)) |
160 | #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \ | 160 | #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \ |
161 | IIO_CHAN_INFO_RAW_SEPARATE_BIT) | 161 | BIT(IIO_CHAN_INFO_RAW)) |
162 | #define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0) | 162 | #define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0) |
163 | 163 | ||
164 | static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { | 164 | static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { |
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index a33d5cd1a536..dd15a5b0f701 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c | |||
@@ -207,8 +207,8 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { | |||
207 | .type = IIO_VOLTAGE, | 207 | .type = IIO_VOLTAGE, |
208 | .indexed = 1, | 208 | .indexed = 1, |
209 | .channel = 1, | 209 | .channel = 1, |
210 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 210 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
211 | IIO_CHAN_INFO_SCALE_SHARED_BIT, | 211 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
212 | .address = 1, | 212 | .address = 1, |
213 | .scan_index = 1, | 213 | .scan_index = 1, |
214 | .scan_type = IIO_ST('u', 12, 16, 0), | 214 | .scan_type = IIO_ST('u', 12, 16, 0), |
@@ -217,8 +217,8 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { | |||
217 | .type = IIO_VOLTAGE, | 217 | .type = IIO_VOLTAGE, |
218 | .indexed = 1, | 218 | .indexed = 1, |
219 | .channel = 0, | 219 | .channel = 0, |
220 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 220 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
221 | IIO_CHAN_INFO_SCALE_SHARED_BIT, | 221 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
222 | .address = 0, | 222 | .address = 0, |
223 | .scan_index = 0, | 223 | .scan_index = 0, |
224 | .scan_type = IIO_ST('u', 12, 16, 0), | 224 | .scan_type = IIO_ST('u', 12, 16, 0), |
diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c new file mode 100644 index 000000000000..97fa0d3dc4aa --- /dev/null +++ b/drivers/iio/adc/ad7923.c | |||
@@ -0,0 +1,383 @@ | |||
1 | /* | ||
2 | * AD7904/AD7914/AD7923/AD7924 SPI ADC driver | ||
3 | * | ||
4 | * Copyright 2011 Analog Devices Inc (from AD7923 Driver) | ||
5 | * Copyright 2012 CS Systemes d'Information | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/device.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/sysfs.h> | ||
14 | #include <linux/spi/spi.h> | ||
15 | #include <linux/regulator/consumer.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | |||
21 | #include <linux/iio/iio.h> | ||
22 | #include <linux/iio/sysfs.h> | ||
23 | #include <linux/iio/buffer.h> | ||
24 | #include <linux/iio/trigger_consumer.h> | ||
25 | #include <linux/iio/triggered_buffer.h> | ||
26 | |||
27 | #define AD7923_WRITE_CR (1 << 11) /* write control register */ | ||
28 | #define AD7923_RANGE (1 << 1) /* range to REFin */ | ||
29 | #define AD7923_CODING (1 << 0) /* coding is straight binary */ | ||
30 | #define AD7923_PM_MODE_AS (1) /* auto shutdown */ | ||
31 | #define AD7923_PM_MODE_FS (2) /* full shutdown */ | ||
32 | #define AD7923_PM_MODE_OPS (3) /* normal operation */ | ||
33 | #define AD7923_CHANNEL_0 (0) /* analog input 0 */ | ||
34 | #define AD7923_CHANNEL_1 (1) /* analog input 1 */ | ||
35 | #define AD7923_CHANNEL_2 (2) /* analog input 2 */ | ||
36 | #define AD7923_CHANNEL_3 (3) /* analog input 3 */ | ||
37 | #define AD7923_SEQUENCE_OFF (0) /* no sequence fonction */ | ||
38 | #define AD7923_SEQUENCE_PROTECT (2) /* no interrupt write cycle */ | ||
39 | #define AD7923_SEQUENCE_ON (3) /* continuous sequence */ | ||
40 | |||
41 | #define AD7923_MAX_CHAN 4 | ||
42 | |||
43 | #define AD7923_PM_MODE_WRITE(mode) (mode << 4) /* write mode */ | ||
44 | #define AD7923_CHANNEL_WRITE(channel) (channel << 6) /* write channel */ | ||
45 | #define AD7923_SEQUENCE_WRITE(sequence) (((sequence & 1) << 3) \ | ||
46 | + ((sequence & 2) << 9)) | ||
47 | /* write sequence fonction */ | ||
48 | /* left shift for CR : bit 11 transmit in first */ | ||
49 | #define AD7923_SHIFT_REGISTER 4 | ||
50 | |||
51 | /* val = value, dec = left shift, bits = number of bits of the mask */ | ||
52 | #define EXTRACT(val, dec, bits) ((val >> dec) & ((1 << bits) - 1)) | ||
53 | |||
54 | struct ad7923_state { | ||
55 | struct spi_device *spi; | ||
56 | struct spi_transfer ring_xfer[5]; | ||
57 | struct spi_transfer scan_single_xfer[2]; | ||
58 | struct spi_message ring_msg; | ||
59 | struct spi_message scan_single_msg; | ||
60 | |||
61 | struct regulator *reg; | ||
62 | |||
63 | unsigned int settings; | ||
64 | |||
65 | /* | ||
66 | * DMA (thus cache coherency maintenance) requires the | ||
67 | * transfer buffers to live in their own cache lines. | ||
68 | */ | ||
69 | __be16 rx_buf[4] ____cacheline_aligned; | ||
70 | __be16 tx_buf[4]; | ||
71 | }; | ||
72 | |||
73 | struct ad7923_chip_info { | ||
74 | const struct iio_chan_spec *channels; | ||
75 | unsigned int num_channels; | ||
76 | }; | ||
77 | |||
78 | enum ad7923_id { | ||
79 | AD7904, | ||
80 | AD7914, | ||
81 | AD7924, | ||
82 | }; | ||
83 | |||
84 | #define AD7923_V_CHAN(index, bits) \ | ||
85 | { \ | ||
86 | .type = IIO_VOLTAGE, \ | ||
87 | .indexed = 1, \ | ||
88 | .channel = index, \ | ||
89 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ | ||
90 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ | ||
91 | .address = index, \ | ||
92 | .scan_index = index, \ | ||
93 | .scan_type = { \ | ||
94 | .sign = 'u', \ | ||
95 | .realbits = (bits), \ | ||
96 | .storagebits = 16, \ | ||
97 | .endianness = IIO_BE, \ | ||
98 | }, \ | ||
99 | } | ||
100 | |||
101 | #define DECLARE_AD7923_CHANNELS(name, bits) \ | ||
102 | const struct iio_chan_spec name ## _channels[] = { \ | ||
103 | AD7923_V_CHAN(0, bits), \ | ||
104 | AD7923_V_CHAN(1, bits), \ | ||
105 | AD7923_V_CHAN(2, bits), \ | ||
106 | AD7923_V_CHAN(3, bits), \ | ||
107 | IIO_CHAN_SOFT_TIMESTAMP(4), \ | ||
108 | } | ||
109 | |||
110 | static DECLARE_AD7923_CHANNELS(ad7904, 8); | ||
111 | static DECLARE_AD7923_CHANNELS(ad7914, 10); | ||
112 | static DECLARE_AD7923_CHANNELS(ad7924, 12); | ||
113 | |||
114 | static const struct ad7923_chip_info ad7923_chip_info[] = { | ||
115 | [AD7904] = { | ||
116 | .channels = ad7904_channels, | ||
117 | .num_channels = ARRAY_SIZE(ad7904_channels), | ||
118 | }, | ||
119 | [AD7914] = { | ||
120 | .channels = ad7914_channels, | ||
121 | .num_channels = ARRAY_SIZE(ad7914_channels), | ||
122 | }, | ||
123 | [AD7924] = { | ||
124 | .channels = ad7924_channels, | ||
125 | .num_channels = ARRAY_SIZE(ad7924_channels), | ||
126 | }, | ||
127 | }; | ||
128 | |||
129 | /** | ||
130 | * ad7923_update_scan_mode() setup the spi transfer buffer for the new scan mask | ||
131 | **/ | ||
132 | static int ad7923_update_scan_mode(struct iio_dev *indio_dev, | ||
133 | const unsigned long *active_scan_mask) | ||
134 | { | ||
135 | struct ad7923_state *st = iio_priv(indio_dev); | ||
136 | int i, cmd, len; | ||
137 | |||
138 | len = 0; | ||
139 | for_each_set_bit(i, active_scan_mask, AD7923_MAX_CHAN) { | ||
140 | cmd = AD7923_WRITE_CR | AD7923_CHANNEL_WRITE(i) | | ||
141 | AD7923_SEQUENCE_WRITE(AD7923_SEQUENCE_OFF) | | ||
142 | st->settings; | ||
143 | cmd <<= AD7923_SHIFT_REGISTER; | ||
144 | st->tx_buf[len++] = cpu_to_be16(cmd); | ||
145 | } | ||
146 | /* build spi ring message */ | ||
147 | st->ring_xfer[0].tx_buf = &st->tx_buf[0]; | ||
148 | st->ring_xfer[0].len = len; | ||
149 | st->ring_xfer[0].cs_change = 1; | ||
150 | |||
151 | spi_message_init(&st->ring_msg); | ||
152 | spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg); | ||
153 | |||
154 | for (i = 0; i < len; i++) { | ||
155 | st->ring_xfer[i + 1].rx_buf = &st->rx_buf[i]; | ||
156 | st->ring_xfer[i + 1].len = 2; | ||
157 | st->ring_xfer[i + 1].cs_change = 1; | ||
158 | spi_message_add_tail(&st->ring_xfer[i + 1], &st->ring_msg); | ||
159 | } | ||
160 | /* make sure last transfer cs_change is not set */ | ||
161 | st->ring_xfer[i + 1].cs_change = 0; | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * ad7923_trigger_handler() bh of trigger launched polling to ring buffer | ||
168 | * | ||
169 | * Currently there is no option in this driver to disable the saving of | ||
170 | * timestamps within the ring. | ||
171 | **/ | ||
172 | static irqreturn_t ad7923_trigger_handler(int irq, void *p) | ||
173 | { | ||
174 | struct iio_poll_func *pf = p; | ||
175 | struct iio_dev *indio_dev = pf->indio_dev; | ||
176 | struct ad7923_state *st = iio_priv(indio_dev); | ||
177 | s64 time_ns = 0; | ||
178 | int b_sent; | ||
179 | |||
180 | b_sent = spi_sync(st->spi, &st->ring_msg); | ||
181 | if (b_sent) | ||
182 | goto done; | ||
183 | |||
184 | if (indio_dev->scan_timestamp) { | ||
185 | time_ns = iio_get_time_ns(); | ||
186 | memcpy((u8 *)st->rx_buf + indio_dev->scan_bytes - sizeof(s64), | ||
187 | &time_ns, sizeof(time_ns)); | ||
188 | } | ||
189 | |||
190 | iio_push_to_buffers(indio_dev, (u8 *)st->rx_buf); | ||
191 | |||
192 | done: | ||
193 | iio_trigger_notify_done(indio_dev->trig); | ||
194 | |||
195 | return IRQ_HANDLED; | ||
196 | } | ||
197 | |||
198 | static int ad7923_scan_direct(struct ad7923_state *st, unsigned ch) | ||
199 | { | ||
200 | int ret, cmd; | ||
201 | |||
202 | cmd = AD7923_WRITE_CR | AD7923_CHANNEL_WRITE(ch) | | ||
203 | AD7923_SEQUENCE_WRITE(AD7923_SEQUENCE_OFF) | | ||
204 | st->settings; | ||
205 | cmd <<= AD7923_SHIFT_REGISTER; | ||
206 | st->tx_buf[0] = cpu_to_be16(cmd); | ||
207 | |||
208 | ret = spi_sync(st->spi, &st->scan_single_msg); | ||
209 | if (ret) | ||
210 | return ret; | ||
211 | |||
212 | return be16_to_cpu(st->rx_buf[0]); | ||
213 | } | ||
214 | |||
215 | static int ad7923_get_range(struct ad7923_state *st) | ||
216 | { | ||
217 | int vref; | ||
218 | |||
219 | vref = regulator_get_voltage(st->reg); | ||
220 | if (vref < 0) | ||
221 | return vref; | ||
222 | |||
223 | vref /= 1000; | ||
224 | |||
225 | if (!(st->settings & AD7923_RANGE)) | ||
226 | vref *= 2; | ||
227 | |||
228 | return vref; | ||
229 | } | ||
230 | |||
231 | static int ad7923_read_raw(struct iio_dev *indio_dev, | ||
232 | struct iio_chan_spec const *chan, | ||
233 | int *val, | ||
234 | int *val2, | ||
235 | long m) | ||
236 | { | ||
237 | int ret; | ||
238 | struct ad7923_state *st = iio_priv(indio_dev); | ||
239 | |||
240 | switch (m) { | ||
241 | case IIO_CHAN_INFO_RAW: | ||
242 | mutex_lock(&indio_dev->mlock); | ||
243 | if (iio_buffer_enabled(indio_dev)) | ||
244 | ret = -EBUSY; | ||
245 | else | ||
246 | ret = ad7923_scan_direct(st, chan->address); | ||
247 | mutex_unlock(&indio_dev->mlock); | ||
248 | |||
249 | if (ret < 0) | ||
250 | return ret; | ||
251 | |||
252 | if (chan->address == EXTRACT(ret, 12, 4)) | ||
253 | *val = EXTRACT(ret, 0, 12); | ||
254 | else | ||
255 | return -EIO; | ||
256 | |||
257 | return IIO_VAL_INT; | ||
258 | case IIO_CHAN_INFO_SCALE: | ||
259 | ret = ad7923_get_range(st); | ||
260 | if (ret < 0) | ||
261 | return ret; | ||
262 | *val = ret; | ||
263 | *val2 = chan->scan_type.realbits; | ||
264 | return IIO_VAL_FRACTIONAL_LOG2; | ||
265 | } | ||
266 | return -EINVAL; | ||
267 | } | ||
268 | |||
269 | static const struct iio_info ad7923_info = { | ||
270 | .read_raw = &ad7923_read_raw, | ||
271 | .update_scan_mode = ad7923_update_scan_mode, | ||
272 | .driver_module = THIS_MODULE, | ||
273 | }; | ||
274 | |||
275 | static int ad7923_probe(struct spi_device *spi) | ||
276 | { | ||
277 | struct ad7923_state *st; | ||
278 | struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); | ||
279 | const struct ad7923_chip_info *info; | ||
280 | int ret; | ||
281 | |||
282 | if (indio_dev == NULL) | ||
283 | return -ENOMEM; | ||
284 | |||
285 | st = iio_priv(indio_dev); | ||
286 | |||
287 | spi_set_drvdata(spi, indio_dev); | ||
288 | |||
289 | st->spi = spi; | ||
290 | st->settings = AD7923_CODING | AD7923_RANGE | | ||
291 | AD7923_PM_MODE_WRITE(AD7923_PM_MODE_OPS); | ||
292 | |||
293 | info = &ad7923_chip_info[spi_get_device_id(spi)->driver_data]; | ||
294 | |||
295 | indio_dev->name = spi_get_device_id(spi)->name; | ||
296 | indio_dev->dev.parent = &spi->dev; | ||
297 | indio_dev->modes = INDIO_DIRECT_MODE; | ||
298 | indio_dev->channels = info->channels; | ||
299 | indio_dev->num_channels = info->num_channels; | ||
300 | indio_dev->info = &ad7923_info; | ||
301 | |||
302 | /* Setup default message */ | ||
303 | |||
304 | st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; | ||
305 | st->scan_single_xfer[0].len = 2; | ||
306 | st->scan_single_xfer[0].cs_change = 1; | ||
307 | st->scan_single_xfer[1].rx_buf = &st->rx_buf[0]; | ||
308 | st->scan_single_xfer[1].len = 2; | ||
309 | |||
310 | spi_message_init(&st->scan_single_msg); | ||
311 | spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg); | ||
312 | spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); | ||
313 | |||
314 | st->reg = regulator_get(&spi->dev, "refin"); | ||
315 | if (IS_ERR(st->reg)) { | ||
316 | ret = PTR_ERR(st->reg); | ||
317 | goto error_free; | ||
318 | } | ||
319 | ret = regulator_enable(st->reg); | ||
320 | if (ret) | ||
321 | goto error_put_reg; | ||
322 | |||
323 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | ||
324 | &ad7923_trigger_handler, NULL); | ||
325 | if (ret) | ||
326 | goto error_disable_reg; | ||
327 | |||
328 | ret = iio_device_register(indio_dev); | ||
329 | if (ret) | ||
330 | goto error_cleanup_ring; | ||
331 | |||
332 | return 0; | ||
333 | |||
334 | error_cleanup_ring: | ||
335 | iio_triggered_buffer_cleanup(indio_dev); | ||
336 | error_disable_reg: | ||
337 | regulator_disable(st->reg); | ||
338 | error_put_reg: | ||
339 | regulator_put(st->reg); | ||
340 | error_free: | ||
341 | iio_device_free(indio_dev); | ||
342 | |||
343 | return ret; | ||
344 | } | ||
345 | |||
346 | static int ad7923_remove(struct spi_device *spi) | ||
347 | { | ||
348 | struct iio_dev *indio_dev = spi_get_drvdata(spi); | ||
349 | struct ad7923_state *st = iio_priv(indio_dev); | ||
350 | |||
351 | iio_device_unregister(indio_dev); | ||
352 | iio_triggered_buffer_cleanup(indio_dev); | ||
353 | regulator_disable(st->reg); | ||
354 | regulator_put(st->reg); | ||
355 | iio_device_free(indio_dev); | ||
356 | |||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | static const struct spi_device_id ad7923_id[] = { | ||
361 | {"ad7904", AD7904}, | ||
362 | {"ad7914", AD7914}, | ||
363 | {"ad7923", AD7924}, | ||
364 | {"ad7924", AD7924}, | ||
365 | {} | ||
366 | }; | ||
367 | MODULE_DEVICE_TABLE(spi, ad7923_id); | ||
368 | |||
369 | static struct spi_driver ad7923_driver = { | ||
370 | .driver = { | ||
371 | .name = "ad7923", | ||
372 | .owner = THIS_MODULE, | ||
373 | }, | ||
374 | .probe = ad7923_probe, | ||
375 | .remove = ad7923_remove, | ||
376 | .id_table = ad7923_id, | ||
377 | }; | ||
378 | module_spi_driver(ad7923_driver); | ||
379 | |||
380 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); | ||
381 | MODULE_AUTHOR("Patrick Vasseur <patrick.vasseur@c-s.fr>"); | ||
382 | MODULE_DESCRIPTION("Analog Devices AD7904/AD7914/AD7923/AD7924 ADC"); | ||
383 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 83c836ba600f..92eb6a5b9e72 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -140,8 +140,8 @@ static int at91_adc_channel_init(struct iio_dev *idev) | |||
140 | chan->scan_type.sign = 'u'; | 140 | chan->scan_type.sign = 'u'; |
141 | chan->scan_type.realbits = 10; | 141 | chan->scan_type.realbits = 10; |
142 | chan->scan_type.storagebits = 16; | 142 | chan->scan_type.storagebits = 16; |
143 | chan->info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | | 143 | chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); |
144 | IIO_CHAN_INFO_RAW_SEPARATE_BIT; | 144 | chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); |
145 | idx++; | 145 | idx++; |
146 | } | 146 | } |
147 | timestamp = chan_array + idx; | 147 | timestamp = chan_array + idx; |
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c new file mode 100644 index 000000000000..4a8a9a34228f --- /dev/null +++ b/drivers/iio/adc/exynos_adc.c | |||
@@ -0,0 +1,452 @@ | |||
1 | /* | ||
2 | * exynos_adc.c - Support for ADC in EXYNOS SoCs | ||
3 | * | ||
4 | * 8 ~ 10 channel, 10/12-bit ADC | ||
5 | * | ||
6 | * Copyright (C) 2013 Naveen Krishna Chatradhi <ch.naveen@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/io.h> | ||
30 | #include <linux/clk.h> | ||
31 | #include <linux/completion.h> | ||
32 | #include <linux/of.h> | ||
33 | #include <linux/of_irq.h> | ||
34 | #include <linux/regulator/consumer.h> | ||
35 | #include <linux/of_platform.h> | ||
36 | |||
37 | #include <linux/iio/iio.h> | ||
38 | #include <linux/iio/machine.h> | ||
39 | #include <linux/iio/driver.h> | ||
40 | |||
41 | enum adc_version { | ||
42 | ADC_V1, | ||
43 | ADC_V2 | ||
44 | }; | ||
45 | |||
46 | /* EXYNOS4412/5250 ADC_V1 registers definitions */ | ||
47 | #define ADC_V1_CON(x) ((x) + 0x00) | ||
48 | #define ADC_V1_DLY(x) ((x) + 0x08) | ||
49 | #define ADC_V1_DATX(x) ((x) + 0x0C) | ||
50 | #define ADC_V1_INTCLR(x) ((x) + 0x18) | ||
51 | #define ADC_V1_MUX(x) ((x) + 0x1c) | ||
52 | |||
53 | /* Future ADC_V2 registers definitions */ | ||
54 | #define ADC_V2_CON1(x) ((x) + 0x00) | ||
55 | #define ADC_V2_CON2(x) ((x) + 0x04) | ||
56 | #define ADC_V2_STAT(x) ((x) + 0x08) | ||
57 | #define ADC_V2_INT_EN(x) ((x) + 0x10) | ||
58 | #define ADC_V2_INT_ST(x) ((x) + 0x14) | ||
59 | #define ADC_V2_VER(x) ((x) + 0x20) | ||
60 | |||
61 | /* Bit definitions for ADC_V1 */ | ||
62 | #define ADC_V1_CON_RES (1u << 16) | ||
63 | #define ADC_V1_CON_PRSCEN (1u << 14) | ||
64 | #define ADC_V1_CON_PRSCLV(x) (((x) & 0xFF) << 6) | ||
65 | #define ADC_V1_CON_STANDBY (1u << 2) | ||
66 | |||
67 | /* Bit definitions for ADC_V2 */ | ||
68 | #define ADC_V2_CON1_SOFT_RESET (1u << 2) | ||
69 | |||
70 | #define ADC_V2_CON2_OSEL (1u << 10) | ||
71 | #define ADC_V2_CON2_ESEL (1u << 9) | ||
72 | #define ADC_V2_CON2_HIGHF (1u << 8) | ||
73 | #define ADC_V2_CON2_C_TIME(x) (((x) & 7) << 4) | ||
74 | #define ADC_V2_CON2_ACH_SEL(x) (((x) & 0xF) << 0) | ||
75 | #define ADC_V2_CON2_ACH_MASK 0xF | ||
76 | |||
77 | #define MAX_ADC_V2_CHANNELS 10 | ||
78 | #define MAX_ADC_V1_CHANNELS 8 | ||
79 | |||
80 | /* Bit definitions common for ADC_V1 and ADC_V2 */ | ||
81 | #define ADC_CON_EN_START (1u << 0) | ||
82 | #define ADC_DATX_MASK 0xFFF | ||
83 | |||
84 | #define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(1000)) | ||
85 | |||
86 | struct exynos_adc { | ||
87 | void __iomem *regs; | ||
88 | void __iomem *enable_reg; | ||
89 | struct clk *clk; | ||
90 | unsigned int irq; | ||
91 | struct regulator *vdd; | ||
92 | |||
93 | struct completion completion; | ||
94 | |||
95 | u32 value; | ||
96 | unsigned int version; | ||
97 | }; | ||
98 | |||
99 | static const struct of_device_id exynos_adc_match[] = { | ||
100 | { .compatible = "samsung,exynos-adc-v1", .data = (void *)ADC_V1 }, | ||
101 | { .compatible = "samsung,exynos-adc-v2", .data = (void *)ADC_V2 }, | ||
102 | {}, | ||
103 | }; | ||
104 | MODULE_DEVICE_TABLE(of, exynos_adc_match); | ||
105 | |||
106 | static inline unsigned int exynos_adc_get_version(struct platform_device *pdev) | ||
107 | { | ||
108 | const struct of_device_id *match; | ||
109 | |||
110 | match = of_match_node(exynos_adc_match, pdev->dev.of_node); | ||
111 | return (unsigned int)match->data; | ||
112 | } | ||
113 | |||
114 | static int exynos_read_raw(struct iio_dev *indio_dev, | ||
115 | struct iio_chan_spec const *chan, | ||
116 | int *val, | ||
117 | int *val2, | ||
118 | long mask) | ||
119 | { | ||
120 | struct exynos_adc *info = iio_priv(indio_dev); | ||
121 | unsigned long timeout; | ||
122 | u32 con1, con2; | ||
123 | |||
124 | if (mask != IIO_CHAN_INFO_RAW) | ||
125 | return -EINVAL; | ||
126 | |||
127 | mutex_lock(&indio_dev->mlock); | ||
128 | |||
129 | /* Select the channel to be used and Trigger conversion */ | ||
130 | if (info->version == ADC_V2) { | ||
131 | con2 = readl(ADC_V2_CON2(info->regs)); | ||
132 | con2 &= ~ADC_V2_CON2_ACH_MASK; | ||
133 | con2 |= ADC_V2_CON2_ACH_SEL(chan->address); | ||
134 | writel(con2, ADC_V2_CON2(info->regs)); | ||
135 | |||
136 | con1 = readl(ADC_V2_CON1(info->regs)); | ||
137 | writel(con1 | ADC_CON_EN_START, | ||
138 | ADC_V2_CON1(info->regs)); | ||
139 | } else { | ||
140 | writel(chan->address, ADC_V1_MUX(info->regs)); | ||
141 | |||
142 | con1 = readl(ADC_V1_CON(info->regs)); | ||
143 | writel(con1 | ADC_CON_EN_START, | ||
144 | ADC_V1_CON(info->regs)); | ||
145 | } | ||
146 | |||
147 | timeout = wait_for_completion_interruptible_timeout | ||
148 | (&info->completion, EXYNOS_ADC_TIMEOUT); | ||
149 | *val = info->value; | ||
150 | |||
151 | mutex_unlock(&indio_dev->mlock); | ||
152 | |||
153 | if (timeout == 0) | ||
154 | return -ETIMEDOUT; | ||
155 | |||
156 | return IIO_VAL_INT; | ||
157 | } | ||
158 | |||
159 | static irqreturn_t exynos_adc_isr(int irq, void *dev_id) | ||
160 | { | ||
161 | struct exynos_adc *info = (struct exynos_adc *)dev_id; | ||
162 | |||
163 | /* Read value */ | ||
164 | info->value = readl(ADC_V1_DATX(info->regs)) & | ||
165 | ADC_DATX_MASK; | ||
166 | /* clear irq */ | ||
167 | if (info->version == ADC_V2) | ||
168 | writel(1, ADC_V2_INT_ST(info->regs)); | ||
169 | else | ||
170 | writel(1, ADC_V1_INTCLR(info->regs)); | ||
171 | |||
172 | complete(&info->completion); | ||
173 | |||
174 | return IRQ_HANDLED; | ||
175 | } | ||
176 | |||
177 | static int exynos_adc_reg_access(struct iio_dev *indio_dev, | ||
178 | unsigned reg, unsigned writeval, | ||
179 | unsigned *readval) | ||
180 | { | ||
181 | struct exynos_adc *info = iio_priv(indio_dev); | ||
182 | |||
183 | if (readval == NULL) | ||
184 | return -EINVAL; | ||
185 | |||
186 | *readval = readl(info->regs + reg); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static const struct iio_info exynos_adc_iio_info = { | ||
192 | .read_raw = &exynos_read_raw, | ||
193 | .debugfs_reg_access = &exynos_adc_reg_access, | ||
194 | .driver_module = THIS_MODULE, | ||
195 | }; | ||
196 | |||
197 | #define ADC_CHANNEL(_index, _id) { \ | ||
198 | .type = IIO_VOLTAGE, \ | ||
199 | .indexed = 1, \ | ||
200 | .channel = _index, \ | ||
201 | .address = _index, \ | ||
202 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ | ||
203 | .datasheet_name = _id, \ | ||
204 | } | ||
205 | |||
206 | static const struct iio_chan_spec exynos_adc_iio_channels[] = { | ||
207 | ADC_CHANNEL(0, "adc0"), | ||
208 | ADC_CHANNEL(1, "adc1"), | ||
209 | ADC_CHANNEL(2, "adc2"), | ||
210 | ADC_CHANNEL(3, "adc3"), | ||
211 | ADC_CHANNEL(4, "adc4"), | ||
212 | ADC_CHANNEL(5, "adc5"), | ||
213 | ADC_CHANNEL(6, "adc6"), | ||
214 | ADC_CHANNEL(7, "adc7"), | ||
215 | ADC_CHANNEL(8, "adc8"), | ||
216 | ADC_CHANNEL(9, "adc9"), | ||
217 | }; | ||
218 | |||
219 | static int exynos_adc_remove_devices(struct device *dev, void *c) | ||
220 | { | ||
221 | struct platform_device *pdev = to_platform_device(dev); | ||
222 | |||
223 | platform_device_unregister(pdev); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | static void exynos_adc_hw_init(struct exynos_adc *info) | ||
229 | { | ||
230 | u32 con1, con2; | ||
231 | |||
232 | if (info->version == ADC_V2) { | ||
233 | con1 = ADC_V2_CON1_SOFT_RESET; | ||
234 | writel(con1, ADC_V2_CON1(info->regs)); | ||
235 | |||
236 | con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | | ||
237 | ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); | ||
238 | writel(con2, ADC_V2_CON2(info->regs)); | ||
239 | |||
240 | /* Enable interrupts */ | ||
241 | writel(1, ADC_V2_INT_EN(info->regs)); | ||
242 | } else { | ||
243 | /* set default prescaler values and Enable prescaler */ | ||
244 | con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; | ||
245 | |||
246 | /* Enable 12-bit ADC resolution */ | ||
247 | con1 |= ADC_V1_CON_RES; | ||
248 | writel(con1, ADC_V1_CON(info->regs)); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | static int exynos_adc_probe(struct platform_device *pdev) | ||
253 | { | ||
254 | struct exynos_adc *info = NULL; | ||
255 | struct device_node *np = pdev->dev.of_node; | ||
256 | struct iio_dev *indio_dev = NULL; | ||
257 | struct resource *mem; | ||
258 | int ret = -ENODEV; | ||
259 | int irq; | ||
260 | |||
261 | if (!np) | ||
262 | return ret; | ||
263 | |||
264 | indio_dev = iio_device_alloc(sizeof(struct exynos_adc)); | ||
265 | if (!indio_dev) { | ||
266 | dev_err(&pdev->dev, "failed allocating iio device\n"); | ||
267 | return -ENOMEM; | ||
268 | } | ||
269 | |||
270 | info = iio_priv(indio_dev); | ||
271 | |||
272 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
273 | info->regs = devm_request_and_ioremap(&pdev->dev, mem); | ||
274 | if (!info->regs) { | ||
275 | ret = -ENOMEM; | ||
276 | goto err_iio; | ||
277 | } | ||
278 | |||
279 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
280 | info->enable_reg = devm_request_and_ioremap(&pdev->dev, mem); | ||
281 | if (!info->enable_reg) { | ||
282 | ret = -ENOMEM; | ||
283 | goto err_iio; | ||
284 | } | ||
285 | |||
286 | irq = platform_get_irq(pdev, 0); | ||
287 | if (irq < 0) { | ||
288 | dev_err(&pdev->dev, "no irq resource?\n"); | ||
289 | ret = irq; | ||
290 | goto err_iio; | ||
291 | } | ||
292 | |||
293 | info->irq = irq; | ||
294 | |||
295 | init_completion(&info->completion); | ||
296 | |||
297 | ret = request_irq(info->irq, exynos_adc_isr, | ||
298 | 0, dev_name(&pdev->dev), info); | ||
299 | if (ret < 0) { | ||
300 | dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", | ||
301 | info->irq); | ||
302 | goto err_iio; | ||
303 | } | ||
304 | |||
305 | writel(1, info->enable_reg); | ||
306 | |||
307 | info->clk = devm_clk_get(&pdev->dev, "adc"); | ||
308 | if (IS_ERR(info->clk)) { | ||
309 | dev_err(&pdev->dev, "failed getting clock, err = %ld\n", | ||
310 | PTR_ERR(info->clk)); | ||
311 | ret = PTR_ERR(info->clk); | ||
312 | goto err_irq; | ||
313 | } | ||
314 | |||
315 | info->vdd = devm_regulator_get(&pdev->dev, "vdd"); | ||
316 | if (IS_ERR(info->vdd)) { | ||
317 | dev_err(&pdev->dev, "failed getting regulator, err = %ld\n", | ||
318 | PTR_ERR(info->vdd)); | ||
319 | ret = PTR_ERR(info->vdd); | ||
320 | goto err_irq; | ||
321 | } | ||
322 | |||
323 | info->version = exynos_adc_get_version(pdev); | ||
324 | |||
325 | platform_set_drvdata(pdev, indio_dev); | ||
326 | |||
327 | indio_dev->name = dev_name(&pdev->dev); | ||
328 | indio_dev->dev.parent = &pdev->dev; | ||
329 | indio_dev->dev.of_node = pdev->dev.of_node; | ||
330 | indio_dev->info = &exynos_adc_iio_info; | ||
331 | indio_dev->modes = INDIO_DIRECT_MODE; | ||
332 | indio_dev->channels = exynos_adc_iio_channels; | ||
333 | |||
334 | if (info->version == ADC_V1) | ||
335 | indio_dev->num_channels = MAX_ADC_V1_CHANNELS; | ||
336 | else | ||
337 | indio_dev->num_channels = MAX_ADC_V2_CHANNELS; | ||
338 | |||
339 | ret = iio_device_register(indio_dev); | ||
340 | if (ret) | ||
341 | goto err_irq; | ||
342 | |||
343 | ret = regulator_enable(info->vdd); | ||
344 | if (ret) | ||
345 | goto err_iio_dev; | ||
346 | |||
347 | clk_prepare_enable(info->clk); | ||
348 | |||
349 | exynos_adc_hw_init(info); | ||
350 | |||
351 | ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev); | ||
352 | if (ret < 0) { | ||
353 | dev_err(&pdev->dev, "failed adding child nodes\n"); | ||
354 | goto err_of_populate; | ||
355 | } | ||
356 | |||
357 | return 0; | ||
358 | |||
359 | err_of_populate: | ||
360 | device_for_each_child(&pdev->dev, NULL, | ||
361 | exynos_adc_remove_devices); | ||
362 | regulator_disable(info->vdd); | ||
363 | clk_disable_unprepare(info->clk); | ||
364 | err_iio_dev: | ||
365 | iio_device_unregister(indio_dev); | ||
366 | err_irq: | ||
367 | free_irq(info->irq, info); | ||
368 | err_iio: | ||
369 | iio_device_free(indio_dev); | ||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | static int exynos_adc_remove(struct platform_device *pdev) | ||
374 | { | ||
375 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | ||
376 | struct exynos_adc *info = iio_priv(indio_dev); | ||
377 | |||
378 | device_for_each_child(&pdev->dev, NULL, | ||
379 | exynos_adc_remove_devices); | ||
380 | regulator_disable(info->vdd); | ||
381 | clk_disable_unprepare(info->clk); | ||
382 | writel(0, info->enable_reg); | ||
383 | iio_device_unregister(indio_dev); | ||
384 | free_irq(info->irq, info); | ||
385 | iio_device_free(indio_dev); | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | #ifdef CONFIG_PM_SLEEP | ||
391 | static int exynos_adc_suspend(struct device *dev) | ||
392 | { | ||
393 | struct platform_device *pdev = to_platform_device(dev); | ||
394 | struct exynos_adc *info = platform_get_drvdata(pdev); | ||
395 | u32 con; | ||
396 | |||
397 | if (info->version == ADC_V2) { | ||
398 | con = readl(ADC_V2_CON1(info->regs)); | ||
399 | con &= ~ADC_CON_EN_START; | ||
400 | writel(con, ADC_V2_CON1(info->regs)); | ||
401 | } else { | ||
402 | con = readl(ADC_V1_CON(info->regs)); | ||
403 | con |= ADC_V1_CON_STANDBY; | ||
404 | writel(con, ADC_V1_CON(info->regs)); | ||
405 | } | ||
406 | |||
407 | clk_disable_unprepare(info->clk); | ||
408 | writel(0, info->enable_reg); | ||
409 | regulator_disable(info->vdd); | ||
410 | |||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static int exynos_adc_resume(struct device *dev) | ||
415 | { | ||
416 | struct platform_device *pdev = to_platform_device(dev); | ||
417 | struct exynos_adc *info = platform_get_drvdata(pdev); | ||
418 | int ret; | ||
419 | |||
420 | ret = regulator_enable(info->vdd); | ||
421 | if (ret) | ||
422 | return ret; | ||
423 | |||
424 | writel(1, info->enable_reg); | ||
425 | clk_prepare_enable(info->clk); | ||
426 | |||
427 | exynos_adc_hw_init(info); | ||
428 | |||
429 | return 0; | ||
430 | } | ||
431 | #endif | ||
432 | |||
433 | static SIMPLE_DEV_PM_OPS(exynos_adc_pm_ops, | ||
434 | exynos_adc_suspend, | ||
435 | exynos_adc_resume); | ||
436 | |||
437 | static struct platform_driver exynos_adc_driver = { | ||
438 | .probe = exynos_adc_probe, | ||
439 | .remove = exynos_adc_remove, | ||
440 | .driver = { | ||
441 | .name = "exynos-adc", | ||
442 | .owner = THIS_MODULE, | ||
443 | .of_match_table = of_match_ptr(exynos_adc_match), | ||
444 | .pm = &exynos_adc_pm_ops, | ||
445 | }, | ||
446 | }; | ||
447 | |||
448 | module_platform_driver(exynos_adc_driver); | ||
449 | |||
450 | MODULE_AUTHOR("Naveen Krishna Chatradhi <ch.naveen@samsung.com>"); | ||
451 | MODULE_DESCRIPTION("Samsung EXYNOS5 ADC driver"); | ||
452 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 763f57565ee4..62bc39e9c94f 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c | |||
@@ -132,8 +132,8 @@ static const struct iio_info lp8788_adc_info = { | |||
132 | .type = _type, \ | 132 | .type = _type, \ |
133 | .indexed = 1, \ | 133 | .indexed = 1, \ |
134 | .channel = LPADC_##_id, \ | 134 | .channel = LPADC_##_id, \ |
135 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 135 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
136 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 136 | BIT(IIO_CHAN_INFO_SCALE), \ |
137 | .datasheet_name = #_id, \ | 137 | .datasheet_name = #_id, \ |
138 | } | 138 | } |
139 | 139 | ||
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 6c1cfb74bdfc..9e6da72ad823 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c | |||
@@ -427,15 +427,15 @@ static const enum max1363_modes max1363_mode_list[] = { | |||
427 | #define MAX1363_EV_M \ | 427 | #define MAX1363_EV_M \ |
428 | (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) \ | 428 | (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) \ |
429 | | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) | 429 | | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) |
430 | #define MAX1363_INFO_MASK (IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 430 | |
431 | IIO_CHAN_INFO_SCALE_SHARED_BIT) | ||
432 | #define MAX1363_CHAN_U(num, addr, si, bits, evmask) \ | 431 | #define MAX1363_CHAN_U(num, addr, si, bits, evmask) \ |
433 | { \ | 432 | { \ |
434 | .type = IIO_VOLTAGE, \ | 433 | .type = IIO_VOLTAGE, \ |
435 | .indexed = 1, \ | 434 | .indexed = 1, \ |
436 | .channel = num, \ | 435 | .channel = num, \ |
437 | .address = addr, \ | 436 | .address = addr, \ |
438 | .info_mask = MAX1363_INFO_MASK, \ | 437 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
438 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ | ||
439 | .datasheet_name = "AIN"#num, \ | 439 | .datasheet_name = "AIN"#num, \ |
440 | .scan_type = { \ | 440 | .scan_type = { \ |
441 | .sign = 'u', \ | 441 | .sign = 'u', \ |
@@ -456,7 +456,8 @@ static const enum max1363_modes max1363_mode_list[] = { | |||
456 | .channel = num, \ | 456 | .channel = num, \ |
457 | .channel2 = num2, \ | 457 | .channel2 = num2, \ |
458 | .address = addr, \ | 458 | .address = addr, \ |
459 | .info_mask = MAX1363_INFO_MASK, \ | 459 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
460 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ | ||
460 | .datasheet_name = "AIN"#num"-AIN"#num2, \ | 461 | .datasheet_name = "AIN"#num"-AIN"#num2, \ |
461 | .scan_type = { \ | 462 | .scan_type = { \ |
462 | .sign = 's', \ | 463 | .sign = 's', \ |
diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index f4a46dd8f43b..2826faae706c 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c | |||
@@ -55,8 +55,8 @@ static int adc081c_read_raw(struct iio_dev *iio, | |||
55 | 55 | ||
56 | static const struct iio_chan_spec adc081c_channel = { | 56 | static const struct iio_chan_spec adc081c_channel = { |
57 | .type = IIO_VOLTAGE, | 57 | .type = IIO_VOLTAGE, |
58 | .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | | 58 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
59 | IIO_CHAN_INFO_RAW_SEPARATE_BIT, | 59 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static const struct iio_info adc081c_info = { | 62 | static const struct iio_info adc081c_info = { |
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index cd030e100c39..5f9a7e7d3135 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -89,7 +89,7 @@ static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) | |||
89 | chan->type = IIO_VOLTAGE; | 89 | chan->type = IIO_VOLTAGE; |
90 | chan->indexed = 1; | 90 | chan->indexed = 1; |
91 | chan->channel = i; | 91 | chan->channel = i; |
92 | chan->info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT; | 92 | chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); |
93 | } | 93 | } |
94 | 94 | ||
95 | indio_dev->channels = chan_array; | 95 | indio_dev->channels = chan_array; |
diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index ad0261533dee..56ac481c73c0 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c | |||
@@ -41,7 +41,7 @@ struct vprbrd_adc { | |||
41 | .type = IIO_VOLTAGE, \ | 41 | .type = IIO_VOLTAGE, \ |
42 | .indexed = 1, \ | 42 | .indexed = 1, \ |
43 | .channel = _index, \ | 43 | .channel = _index, \ |
44 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \ | 44 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
45 | .scan_index = _index, \ | 45 | .scan_index = _index, \ |
46 | .scan_type = { \ | 46 | .scan_type = { \ |
47 | .sign = 'u', \ | 47 | .sign = 'u', \ |
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index d6c0af23a2a7..d354554b51b3 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c | |||
@@ -125,7 +125,7 @@ static const struct iio_info ad8366_info = { | |||
125 | .output = 1, \ | 125 | .output = 1, \ |
126 | .indexed = 1, \ | 126 | .indexed = 1, \ |
127 | .channel = _channel, \ | 127 | .channel = _channel, \ |
128 | .info_mask = IIO_CHAN_INFO_HARDWAREGAIN_SEPARATE_BIT,\ | 128 | .info_mask_separate = BIT(IIO_CHAN_INFO_HARDWAREGAIN),\ |
129 | } | 129 | } |
130 | 130 | ||
131 | static const struct iio_chan_spec ad8366_channels[] = { | 131 | static const struct iio_chan_spec ad8366_channels[] = { |
diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c index f0aa2f105222..251baf6abc25 100644 --- a/drivers/iio/common/st_sensors/st_sensors_spi.c +++ b/drivers/iio/common/st_sensors/st_sensors_spi.c | |||
@@ -29,7 +29,6 @@ static unsigned int st_sensors_spi_get_irq(struct iio_dev *indio_dev) | |||
29 | static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb, | 29 | static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb, |
30 | struct device *dev, u8 reg_addr, int len, u8 *data, bool multiread_bit) | 30 | struct device *dev, u8 reg_addr, int len, u8 *data, bool multiread_bit) |
31 | { | 31 | { |
32 | struct spi_message msg; | ||
33 | int err; | 32 | int err; |
34 | 33 | ||
35 | struct spi_transfer xfers[] = { | 34 | struct spi_transfer xfers[] = { |
@@ -51,10 +50,7 @@ static int st_sensors_spi_read(struct st_sensor_transfer_buffer *tb, | |||
51 | else | 50 | else |
52 | tb->tx_buf[0] = reg_addr | ST_SENSORS_SPI_READ; | 51 | tb->tx_buf[0] = reg_addr | ST_SENSORS_SPI_READ; |
53 | 52 | ||
54 | spi_message_init(&msg); | 53 | err = spi_sync_transfer(to_spi_device(dev), xfers, ARRAY_SIZE(xfers)); |
55 | spi_message_add_tail(&xfers[0], &msg); | ||
56 | spi_message_add_tail(&xfers[1], &msg); | ||
57 | err = spi_sync(to_spi_device(dev), &msg); | ||
58 | if (err) | 54 | if (err) |
59 | goto acc_spi_read_error; | 55 | goto acc_spi_read_error; |
60 | 56 | ||
@@ -83,7 +79,6 @@ static int st_sensors_spi_read_multiple_byte( | |||
83 | static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb, | 79 | static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb, |
84 | struct device *dev, u8 reg_addr, u8 data) | 80 | struct device *dev, u8 reg_addr, u8 data) |
85 | { | 81 | { |
86 | struct spi_message msg; | ||
87 | int err; | 82 | int err; |
88 | 83 | ||
89 | struct spi_transfer xfers = { | 84 | struct spi_transfer xfers = { |
@@ -96,9 +91,7 @@ static int st_sensors_spi_write_byte(struct st_sensor_transfer_buffer *tb, | |||
96 | tb->tx_buf[0] = reg_addr; | 91 | tb->tx_buf[0] = reg_addr; |
97 | tb->tx_buf[1] = data; | 92 | tb->tx_buf[1] = data; |
98 | 93 | ||
99 | spi_message_init(&msg); | 94 | err = spi_sync_transfer(to_spi_device(dev), &xfers, 1); |
100 | spi_message_add_tail(&xfers, &msg); | ||
101 | err = spi_sync(to_spi_device(dev), &msg); | ||
102 | mutex_unlock(&tb->buf_lock); | 95 | mutex_unlock(&tb->buf_lock); |
103 | 96 | ||
104 | return err; | 97 | return err; |
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index 74f2d52795f6..aa26d50ab638 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c | |||
@@ -296,8 +296,8 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { | |||
296 | .indexed = 1, \ | 296 | .indexed = 1, \ |
297 | .output = 1, \ | 297 | .output = 1, \ |
298 | .channel = (chan), \ | 298 | .channel = (chan), \ |
299 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 299 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
300 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 300 | BIT(IIO_CHAN_INFO_SCALE), \ |
301 | .address = addr, \ | 301 | .address = addr, \ |
302 | .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \ | 302 | .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \ |
303 | .ext_info = ad5064_ext_info, \ | 303 | .ext_info = ad5064_ext_info, \ |
diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 92771217f665..80923af424f2 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c | |||
@@ -102,11 +102,11 @@ enum ad5360_type { | |||
102 | .type = IIO_VOLTAGE, \ | 102 | .type = IIO_VOLTAGE, \ |
103 | .indexed = 1, \ | 103 | .indexed = 1, \ |
104 | .output = 1, \ | 104 | .output = 1, \ |
105 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 105 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
106 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ | 106 | BIT(IIO_CHAN_INFO_SCALE) | \ |
107 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \ | 107 | BIT(IIO_CHAN_INFO_OFFSET) | \ |
108 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ | 108 | BIT(IIO_CHAN_INFO_CALIBSCALE) | \ |
109 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ | 109 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
110 | .scan_type = IIO_ST('u', (bits), 16, 16 - (bits)) \ | 110 | .scan_type = IIO_ST('u', (bits), 16, 16 - (bits)) \ |
111 | } | 111 | } |
112 | 112 | ||
diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index 483fc379a2da..bf2db02215c2 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c | |||
@@ -257,10 +257,10 @@ static struct iio_chan_spec_ext_info ad5380_ext_info[] = { | |||
257 | .type = IIO_VOLTAGE, \ | 257 | .type = IIO_VOLTAGE, \ |
258 | .indexed = 1, \ | 258 | .indexed = 1, \ |
259 | .output = 1, \ | 259 | .output = 1, \ |
260 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 260 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
261 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 261 | BIT(IIO_CHAN_INFO_CALIBSCALE) | \ |
262 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ | 262 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
263 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ | 263 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
264 | .scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)), \ | 264 | .scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)), \ |
265 | .ext_info = ad5380_ext_info, \ | 265 | .ext_info = ad5380_ext_info, \ |
266 | } | 266 | } |
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 6b86a638dad0..98f24407c3ce 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c | |||
@@ -86,11 +86,11 @@ static const struct iio_chan_spec ad5421_channels[] = { | |||
86 | .indexed = 1, | 86 | .indexed = 1, |
87 | .output = 1, | 87 | .output = 1, |
88 | .channel = 0, | 88 | .channel = 0, |
89 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 89 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
90 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 90 | BIT(IIO_CHAN_INFO_CALIBSCALE) | |
91 | IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 91 | BIT(IIO_CHAN_INFO_CALIBBIAS), |
92 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | | 92 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | |
93 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, | 93 | BIT(IIO_CHAN_INFO_OFFSET), |
94 | .scan_type = IIO_ST('u', 16, 16, 0), | 94 | .scan_type = IIO_ST('u', 16, 16, 0), |
95 | .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | | 95 | .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | |
96 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), | 96 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), |
diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index f5583aedfb59..cae8f6056ac3 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c | |||
@@ -143,8 +143,8 @@ static const struct iio_chan_spec_ext_info ad5446_ext_info_powerdown[] = { | |||
143 | .indexed = 1, \ | 143 | .indexed = 1, \ |
144 | .output = 1, \ | 144 | .output = 1, \ |
145 | .channel = 0, \ | 145 | .channel = 0, \ |
146 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 146 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
147 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 147 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
148 | .scan_type = IIO_ST('u', (bits), (storage), (shift)), \ | 148 | .scan_type = IIO_ST('u', (bits), (storage), (shift)), \ |
149 | .ext_info = (ext), \ | 149 | .ext_info = (ext), \ |
150 | } | 150 | } |
diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c index c4731b7b577b..ba1c914b0399 100644 --- a/drivers/iio/dac/ad5449.c +++ b/drivers/iio/dac/ad5449.c | |||
@@ -206,8 +206,8 @@ static const struct iio_info ad5449_info = { | |||
206 | .indexed = 1, \ | 206 | .indexed = 1, \ |
207 | .output = 1, \ | 207 | .output = 1, \ |
208 | .channel = (chan), \ | 208 | .channel = (chan), \ |
209 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 209 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
210 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 210 | BIT(IIO_CHAN_INFO_SCALE), \ |
211 | .address = (chan), \ | 211 | .address = (chan), \ |
212 | .scan_type = IIO_ST('u', (bits), 16, 12 - (bits)), \ | 212 | .scan_type = IIO_ST('u', (bits), 16, 12 - (bits)), \ |
213 | } | 213 | } |
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index e5e59749f109..139206e84cb7 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c | |||
@@ -259,8 +259,8 @@ static const struct iio_chan_spec_ext_info ad5504_ext_info[] = { | |||
259 | .indexed = 1, \ | 259 | .indexed = 1, \ |
260 | .output = 1, \ | 260 | .output = 1, \ |
261 | .channel = (_chan), \ | 261 | .channel = (_chan), \ |
262 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 262 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
263 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 263 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
264 | .address = AD5504_ADDR_DAC(_chan), \ | 264 | .address = AD5504_ADDR_DAC(_chan), \ |
265 | .scan_type = IIO_ST('u', 12, 16, 0), \ | 265 | .scan_type = IIO_ST('u', 12, 16, 0), \ |
266 | .ext_info = ad5504_ext_info, \ | 266 | .ext_info = ad5504_ext_info, \ |
diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index f6e116627b71..bb298aaff321 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c | |||
@@ -174,8 +174,8 @@ static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = { | |||
174 | .indexed = 1, \ | 174 | .indexed = 1, \ |
175 | .output = 1, \ | 175 | .output = 1, \ |
176 | .channel = (_chan), \ | 176 | .channel = (_chan), \ |
177 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 177 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
178 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 178 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
179 | .address = (_chan), \ | 179 | .address = (_chan), \ |
180 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ | 180 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ |
181 | .ext_info = ad5624r_ext_info, \ | 181 | .ext_info = ad5624r_ext_info, \ |
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 5e554af21703..06439b1af9b6 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c | |||
@@ -276,9 +276,9 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = { | |||
276 | .indexed = 1, \ | 276 | .indexed = 1, \ |
277 | .output = 1, \ | 277 | .output = 1, \ |
278 | .channel = chan, \ | 278 | .channel = chan, \ |
279 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 279 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
280 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 280 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\ |
281 | .address = AD5686_ADDR_DAC(chan), \ | 281 | .address = AD5686_ADDR_DAC(chan), \ |
282 | .scan_type = IIO_ST('u', bits, 16, shift), \ | 282 | .scan_type = IIO_ST('u', bits, 16, shift), \ |
283 | .ext_info = ad5686_ext_info, \ | 283 | .ext_info = ad5686_ext_info, \ |
284 | } | 284 | } |
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 71faabc6b14e..12bb315e55f8 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c | |||
@@ -393,11 +393,11 @@ static const struct iio_chan_spec_ext_info ad5755_ext_info[] = { | |||
393 | #define AD5755_CHANNEL(_bits) { \ | 393 | #define AD5755_CHANNEL(_bits) { \ |
394 | .indexed = 1, \ | 394 | .indexed = 1, \ |
395 | .output = 1, \ | 395 | .output = 1, \ |
396 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 396 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
397 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ | 397 | BIT(IIO_CHAN_INFO_SCALE) | \ |
398 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \ | 398 | BIT(IIO_CHAN_INFO_OFFSET) | \ |
399 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ | 399 | BIT(IIO_CHAN_INFO_CALIBSCALE) | \ |
400 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ | 400 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
401 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ | 401 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ |
402 | .ext_info = ad5755_ext_info, \ | 402 | .ext_info = ad5755_ext_info, \ |
403 | } | 403 | } |
diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 5b7acd3a2c77..7a53f7d70dac 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c | |||
@@ -78,11 +78,11 @@ enum ad5764_type { | |||
78 | .output = 1, \ | 78 | .output = 1, \ |
79 | .channel = (_chan), \ | 79 | .channel = (_chan), \ |
80 | .address = (_chan), \ | 80 | .address = (_chan), \ |
81 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 81 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
82 | IIO_CHAN_INFO_OFFSET_SHARED_BIT | \ | 82 | BIT(IIO_CHAN_INFO_SCALE) | \ |
83 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ | 83 | BIT(IIO_CHAN_INFO_CALIBSCALE) | \ |
84 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ | 84 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
85 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ | 85 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET), \ |
86 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)) \ | 86 | .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)) \ |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 8dfd3da8a07b..97c1e5d780df 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c | |||
@@ -302,9 +302,9 @@ static const struct iio_chan_spec_ext_info ad5791_ext_info[] = { | |||
302 | .indexed = 1, \ | 302 | .indexed = 1, \ |
303 | .address = AD5791_ADDR_DAC0, \ | 303 | .address = AD5791_ADDR_DAC0, \ |
304 | .channel = 0, \ | 304 | .channel = 0, \ |
305 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 305 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
306 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 306 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
307 | IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ | 307 | BIT(IIO_CHAN_INFO_OFFSET), \ |
308 | .scan_type = IIO_ST('u', bits, 24, shift), \ | 308 | .scan_type = IIO_ST('u', bits, 24, shift), \ |
309 | .ext_info = ad5791_ext_info, \ | 309 | .ext_info = ad5791_ext_info, \ |
310 | } | 310 | } |
diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index 352abe2004a4..ebfaa4156246 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c | |||
@@ -146,8 +146,8 @@ static const struct iio_info max517_info = { | |||
146 | .indexed = 1, \ | 146 | .indexed = 1, \ |
147 | .output = 1, \ | 147 | .output = 1, \ |
148 | .channel = (chan), \ | 148 | .channel = (chan), \ |
149 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 149 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
150 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 150 | BIT(IIO_CHAN_INFO_SCALE), \ |
151 | .scan_type = IIO_ST('u', 8, 8, 0), \ | 151 | .scan_type = IIO_ST('u', 8, 8, 0), \ |
152 | } | 152 | } |
153 | 153 | ||
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 8f88cc4059a2..a612ec766d96 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c | |||
@@ -69,8 +69,8 @@ static const struct iio_chan_spec mcp4725_channel = { | |||
69 | .indexed = 1, | 69 | .indexed = 1, |
70 | .output = 1, | 70 | .output = 1, |
71 | .channel = 0, | 71 | .channel = 0, |
72 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 72 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
73 | IIO_CHAN_INFO_SCALE_SHARED_BIT, | 73 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
74 | .scan_type = IIO_ST('u', 12, 16, 0), | 74 | .scan_type = IIO_ST('u', 12, 16, 0), |
75 | }; | 75 | }; |
76 | 76 | ||
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 1ea132e239ea..92276deeb026 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c | |||
@@ -920,10 +920,10 @@ static int ad9523_setup(struct iio_dev *indio_dev) | |||
920 | st->ad9523_channels[i].channel = chan->channel_num; | 920 | st->ad9523_channels[i].channel = chan->channel_num; |
921 | st->ad9523_channels[i].extend_name = | 921 | st->ad9523_channels[i].extend_name = |
922 | chan->extended_name; | 922 | chan->extended_name; |
923 | st->ad9523_channels[i].info_mask = | 923 | st->ad9523_channels[i].info_mask_separate = |
924 | IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 924 | BIT(IIO_CHAN_INFO_RAW) | |
925 | IIO_CHAN_INFO_PHASE_SEPARATE_BIT | | 925 | BIT(IIO_CHAN_INFO_PHASE) | |
926 | IIO_CHAN_INFO_FREQUENCY_SEPARATE_BIT; | 926 | BIT(IIO_CHAN_INFO_FREQUENCY); |
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c index 1861287911f1..e1bb5f994a54 100644 --- a/drivers/iio/gyro/adis16080.c +++ b/drivers/iio/gyro/adis16080.c | |||
@@ -136,32 +136,32 @@ static const struct iio_chan_spec adis16080_channels[] = { | |||
136 | .type = IIO_ANGL_VEL, | 136 | .type = IIO_ANGL_VEL, |
137 | .modified = 1, | 137 | .modified = 1, |
138 | .channel2 = IIO_MOD_Z, | 138 | .channel2 = IIO_MOD_Z, |
139 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 139 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
140 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 140 | BIT(IIO_CHAN_INFO_SCALE), |
141 | .address = ADIS16080_DIN_GYRO, | 141 | .address = ADIS16080_DIN_GYRO, |
142 | }, { | 142 | }, { |
143 | .type = IIO_VOLTAGE, | 143 | .type = IIO_VOLTAGE, |
144 | .indexed = 1, | 144 | .indexed = 1, |
145 | .channel = 0, | 145 | .channel = 0, |
146 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 146 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
147 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | 147 | BIT(IIO_CHAN_INFO_SCALE) | |
148 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, | 148 | BIT(IIO_CHAN_INFO_OFFSET), |
149 | .address = ADIS16080_DIN_AIN1, | 149 | .address = ADIS16080_DIN_AIN1, |
150 | }, { | 150 | }, { |
151 | .type = IIO_VOLTAGE, | 151 | .type = IIO_VOLTAGE, |
152 | .indexed = 1, | 152 | .indexed = 1, |
153 | .channel = 1, | 153 | .channel = 1, |
154 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 154 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
155 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | 155 | BIT(IIO_CHAN_INFO_SCALE) | |
156 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, | 156 | BIT(IIO_CHAN_INFO_OFFSET), |
157 | .address = ADIS16080_DIN_AIN2, | 157 | .address = ADIS16080_DIN_AIN2, |
158 | }, { | 158 | }, { |
159 | .type = IIO_TEMP, | 159 | .type = IIO_TEMP, |
160 | .indexed = 1, | 160 | .indexed = 1, |
161 | .channel = 0, | 161 | .channel = 0, |
162 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 162 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
163 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | 163 | BIT(IIO_CHAN_INFO_SCALE) | |
164 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, | 164 | BIT(IIO_CHAN_INFO_OFFSET), |
165 | .address = ADIS16080_DIN_TEMP, | 165 | .address = ADIS16080_DIN_TEMP, |
166 | } | 166 | } |
167 | }; | 167 | }; |
diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c index 8cb0bcbfd609..058e6d5c955f 100644 --- a/drivers/iio/gyro/adis16136.c +++ b/drivers/iio/gyro/adis16136.c | |||
@@ -357,10 +357,11 @@ static const struct iio_chan_spec adis16136_channels[] = { | |||
357 | .type = IIO_ANGL_VEL, | 357 | .type = IIO_ANGL_VEL, |
358 | .modified = 1, | 358 | .modified = 1, |
359 | .channel2 = IIO_MOD_X, | 359 | .channel2 = IIO_MOD_X, |
360 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 360 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
361 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | | 361 | BIT(IIO_CHAN_INFO_CALIBBIAS) | |
362 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 362 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), |
363 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SEPARATE_BIT, | 363 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
364 | |||
364 | .address = ADIS16136_REG_GYRO_OUT2, | 365 | .address = ADIS16136_REG_GYRO_OUT2, |
365 | .scan_index = ADIS16136_SCAN_GYRO, | 366 | .scan_index = ADIS16136_SCAN_GYRO, |
366 | .scan_type = { | 367 | .scan_type = { |
@@ -373,8 +374,8 @@ static const struct iio_chan_spec adis16136_channels[] = { | |||
373 | .type = IIO_TEMP, | 374 | .type = IIO_TEMP, |
374 | .indexed = 1, | 375 | .indexed = 1, |
375 | .channel = 0, | 376 | .channel = 0, |
376 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 377 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
377 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 378 | BIT(IIO_CHAN_INFO_SCALE), |
378 | .address = ADIS16136_REG_TEMP_OUT, | 379 | .address = ADIS16136_REG_TEMP_OUT, |
379 | .scan_index = ADIS16136_SCAN_TEMP, | 380 | .scan_index = ADIS16136_SCAN_TEMP, |
380 | .scan_type = { | 381 | .scan_type = { |
diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index 5b79953f7011..8bd72b490b7f 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c | |||
@@ -383,16 +383,16 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = { | |||
383 | .type = IIO_ANGL_VEL, | 383 | .type = IIO_ANGL_VEL, |
384 | .modified = 1, | 384 | .modified = 1, |
385 | .channel2 = IIO_MOD_Z, | 385 | .channel2 = IIO_MOD_Z, |
386 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 386 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
387 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | | 387 | BIT(IIO_CHAN_INFO_CALIBBIAS) | |
388 | IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | | 388 | BIT(IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW) | |
389 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 389 | BIT(IIO_CHAN_INFO_SCALE), |
390 | }, { | 390 | }, { |
391 | .type = IIO_TEMP, | 391 | .type = IIO_TEMP, |
392 | .indexed = 1, | 392 | .indexed = 1, |
393 | .channel = 0, | 393 | .channel = 0, |
394 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 394 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
395 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 395 | BIT(IIO_CHAN_INFO_SCALE), |
396 | } | 396 | } |
397 | }, | 397 | }, |
398 | [ID_ADXRS453] = { | 398 | [ID_ADXRS453] = { |
@@ -400,15 +400,15 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = { | |||
400 | .type = IIO_ANGL_VEL, | 400 | .type = IIO_ANGL_VEL, |
401 | .modified = 1, | 401 | .modified = 1, |
402 | .channel2 = IIO_MOD_Z, | 402 | .channel2 = IIO_MOD_Z, |
403 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 403 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
404 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | | 404 | BIT(IIO_CHAN_INFO_SCALE) | |
405 | IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, | 405 | BIT(IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW), |
406 | }, { | 406 | }, { |
407 | .type = IIO_TEMP, | 407 | .type = IIO_TEMP, |
408 | .indexed = 1, | 408 | .indexed = 1, |
409 | .channel = 0, | 409 | .channel = 0, |
410 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 410 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
411 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 411 | BIT(IIO_CHAN_INFO_SCALE), |
412 | } | 412 | } |
413 | }, | 413 | }, |
414 | }; | 414 | }; |
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index fcfc83a9f861..bc943dd47da5 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c | |||
@@ -60,28 +60,28 @@ static const struct iio_chan_spec gyro_3d_channels[] = { | |||
60 | .type = IIO_ANGL_VEL, | 60 | .type = IIO_ANGL_VEL, |
61 | .modified = 1, | 61 | .modified = 1, |
62 | .channel2 = IIO_MOD_X, | 62 | .channel2 = IIO_MOD_X, |
63 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 63 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
64 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 64 | BIT(IIO_CHAN_INFO_SCALE) | |
65 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 65 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
66 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 66 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
67 | .scan_index = CHANNEL_SCAN_INDEX_X, | 67 | .scan_index = CHANNEL_SCAN_INDEX_X, |
68 | }, { | 68 | }, { |
69 | .type = IIO_ANGL_VEL, | 69 | .type = IIO_ANGL_VEL, |
70 | .modified = 1, | 70 | .modified = 1, |
71 | .channel2 = IIO_MOD_Y, | 71 | .channel2 = IIO_MOD_Y, |
72 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 72 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
73 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 73 | BIT(IIO_CHAN_INFO_SCALE) | |
74 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 74 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
75 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 75 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
76 | .scan_index = CHANNEL_SCAN_INDEX_Y, | 76 | .scan_index = CHANNEL_SCAN_INDEX_Y, |
77 | }, { | 77 | }, { |
78 | .type = IIO_ANGL_VEL, | 78 | .type = IIO_ANGL_VEL, |
79 | .modified = 1, | 79 | .modified = 1, |
80 | .channel2 = IIO_MOD_Z, | 80 | .channel2 = IIO_MOD_Z, |
81 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 81 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
82 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 82 | BIT(IIO_CHAN_INFO_SCALE) | |
83 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 83 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
84 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 84 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
85 | .scan_index = CHANNEL_SCAN_INDEX_Z, | 85 | .scan_index = CHANNEL_SCAN_INDEX_Z, |
86 | } | 86 | } |
87 | }; | 87 | }; |
diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index df2e6aa5d73b..d66605d2629d 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c | |||
@@ -248,12 +248,6 @@ err_ret: | |||
248 | return ret; | 248 | return ret; |
249 | } | 249 | } |
250 | 250 | ||
251 | #define ITG3200_TEMP_INFO_MASK (IIO_CHAN_INFO_OFFSET_SHARED_BIT | \ | ||
252 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | ||
253 | IIO_CHAN_INFO_RAW_SEPARATE_BIT) | ||
254 | #define ITG3200_GYRO_INFO_MASK (IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | ||
255 | IIO_CHAN_INFO_RAW_SEPARATE_BIT) | ||
256 | |||
257 | #define ITG3200_ST \ | 251 | #define ITG3200_ST \ |
258 | { .sign = 's', .realbits = 16, .storagebits = 16, .endianness = IIO_BE } | 252 | { .sign = 's', .realbits = 16, .storagebits = 16, .endianness = IIO_BE } |
259 | 253 | ||
@@ -261,7 +255,8 @@ err_ret: | |||
261 | .type = IIO_ANGL_VEL, \ | 255 | .type = IIO_ANGL_VEL, \ |
262 | .modified = 1, \ | 256 | .modified = 1, \ |
263 | .channel2 = IIO_MOD_ ## _mod, \ | 257 | .channel2 = IIO_MOD_ ## _mod, \ |
264 | .info_mask = ITG3200_GYRO_INFO_MASK, \ | 258 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
259 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ | ||
265 | .address = ITG3200_REG_GYRO_ ## _mod ## OUT_H, \ | 260 | .address = ITG3200_REG_GYRO_ ## _mod ## OUT_H, \ |
266 | .scan_index = ITG3200_SCAN_GYRO_ ## _mod, \ | 261 | .scan_index = ITG3200_SCAN_GYRO_ ## _mod, \ |
267 | .scan_type = ITG3200_ST, \ | 262 | .scan_type = ITG3200_ST, \ |
@@ -271,7 +266,9 @@ static const struct iio_chan_spec itg3200_channels[] = { | |||
271 | { | 266 | { |
272 | .type = IIO_TEMP, | 267 | .type = IIO_TEMP, |
273 | .channel2 = IIO_NO_MOD, | 268 | .channel2 = IIO_NO_MOD, |
274 | .info_mask = ITG3200_TEMP_INFO_MASK, | 269 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
270 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | | ||
271 | BIT(IIO_CHAN_INFO_SCALE), | ||
275 | .address = ITG3200_REG_TEMP_OUT_H, | 272 | .address = ITG3200_REG_TEMP_OUT_H, |
276 | .scan_index = ITG3200_SCAN_TEMP, | 273 | .scan_index = ITG3200_SCAN_TEMP, |
277 | .scan_type = ITG3200_ST, | 274 | .scan_type = ITG3200_ST, |
diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h index f652e6ae5a35..05c1b74502a3 100644 --- a/drivers/iio/iio_core.h +++ b/drivers/iio/iio_core.h | |||
@@ -18,6 +18,7 @@ | |||
18 | struct iio_chan_spec; | 18 | struct iio_chan_spec; |
19 | struct iio_dev; | 19 | struct iio_dev; |
20 | 20 | ||
21 | extern struct device_type iio_device_type; | ||
21 | 22 | ||
22 | int __iio_add_chan_devattr(const char *postfix, | 23 | int __iio_add_chan_devattr(const char *postfix, |
23 | struct iio_chan_spec const *chan, | 24 | struct iio_chan_spec const *chan, |
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index b7f215eab5de..f60591f0b925 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c | |||
@@ -484,8 +484,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
484 | .indexed = 1, \ | 484 | .indexed = 1, \ |
485 | .channel = 0, \ | 485 | .channel = 0, \ |
486 | .extend_name = name, \ | 486 | .extend_name = name, \ |
487 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 487 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
488 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 488 | BIT(IIO_CHAN_INFO_SCALE), \ |
489 | .address = (addr), \ | 489 | .address = (addr), \ |
490 | .scan_index = (si), \ | 490 | .scan_index = (si), \ |
491 | .scan_type = { \ | 491 | .scan_type = { \ |
@@ -507,10 +507,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
507 | .type = IIO_ANGL_VEL, \ | 507 | .type = IIO_ANGL_VEL, \ |
508 | .modified = 1, \ | 508 | .modified = 1, \ |
509 | .channel2 = IIO_MOD_ ## mod, \ | 509 | .channel2 = IIO_MOD_ ## mod, \ |
510 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 510 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
511 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \ | 511 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
512 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 512 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
513 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \ | 513 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ |
514 | .address = addr, \ | 514 | .address = addr, \ |
515 | .scan_index = ADIS16400_SCAN_GYRO_ ## mod, \ | 515 | .scan_index = ADIS16400_SCAN_GYRO_ ## mod, \ |
516 | .scan_type = { \ | 516 | .scan_type = { \ |
@@ -526,10 +526,10 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
526 | .type = IIO_ACCEL, \ | 526 | .type = IIO_ACCEL, \ |
527 | .modified = 1, \ | 527 | .modified = 1, \ |
528 | .channel2 = IIO_MOD_ ## mod, \ | 528 | .channel2 = IIO_MOD_ ## mod, \ |
529 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 529 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
530 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \ | 530 | BIT(IIO_CHAN_INFO_CALIBBIAS), \ |
531 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 531 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
532 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \ | 532 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ |
533 | .address = (addr), \ | 533 | .address = (addr), \ |
534 | .scan_index = ADIS16400_SCAN_ACC_ ## mod, \ | 534 | .scan_index = ADIS16400_SCAN_ACC_ ## mod, \ |
535 | .scan_type = { \ | 535 | .scan_type = { \ |
@@ -545,9 +545,9 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
545 | .type = IIO_MAGN, \ | 545 | .type = IIO_MAGN, \ |
546 | .modified = 1, \ | 546 | .modified = 1, \ |
547 | .channel2 = IIO_MOD_ ## mod, \ | 547 | .channel2 = IIO_MOD_ ## mod, \ |
548 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 548 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
549 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 549 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
550 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \ | 550 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ |
551 | .address = (addr), \ | 551 | .address = (addr), \ |
552 | .scan_index = ADIS16400_SCAN_MAGN_ ## mod, \ | 552 | .scan_index = ADIS16400_SCAN_MAGN_ ## mod, \ |
553 | .scan_type = { \ | 553 | .scan_type = { \ |
@@ -568,10 +568,11 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
568 | .indexed = 1, \ | 568 | .indexed = 1, \ |
569 | .channel = 0, \ | 569 | .channel = 0, \ |
570 | .extend_name = ADIS16400_MOD_TEMP_NAME_ ## mod, \ | 570 | .extend_name = ADIS16400_MOD_TEMP_NAME_ ## mod, \ |
571 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 571 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
572 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \ | 572 | BIT(IIO_CHAN_INFO_OFFSET) | \ |
573 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ | 573 | BIT(IIO_CHAN_INFO_SCALE), \ |
574 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \ | 574 | .info_mask_shared_by_type = \ |
575 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ | ||
575 | .address = (addr), \ | 576 | .address = (addr), \ |
576 | .scan_index = ADIS16350_SCAN_TEMP_ ## mod, \ | 577 | .scan_index = ADIS16350_SCAN_TEMP_ ## mod, \ |
577 | .scan_type = { \ | 578 | .scan_type = { \ |
@@ -587,9 +588,9 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
587 | .type = IIO_TEMP, \ | 588 | .type = IIO_TEMP, \ |
588 | .indexed = 1, \ | 589 | .indexed = 1, \ |
589 | .channel = 0, \ | 590 | .channel = 0, \ |
590 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 591 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
591 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \ | 592 | BIT(IIO_CHAN_INFO_OFFSET) | \ |
592 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 593 | BIT(IIO_CHAN_INFO_SCALE), \ |
593 | .address = (addr), \ | 594 | .address = (addr), \ |
594 | .scan_index = ADIS16350_SCAN_TEMP_X, \ | 595 | .scan_index = ADIS16350_SCAN_TEMP_X, \ |
595 | .scan_type = { \ | 596 | .scan_type = { \ |
@@ -605,8 +606,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, | |||
605 | .type = IIO_INCLI, \ | 606 | .type = IIO_INCLI, \ |
606 | .modified = 1, \ | 607 | .modified = 1, \ |
607 | .channel2 = IIO_MOD_ ## mod, \ | 608 | .channel2 = IIO_MOD_ ## mod, \ |
608 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 609 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
609 | IIO_CHAN_INFO_SCALE_SHARED_BIT, \ | 610 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
610 | .address = (addr), \ | 611 | .address = (addr), \ |
611 | .scan_index = ADIS16300_SCAN_INCLI_ ## mod, \ | 612 | .scan_index = ADIS16300_SCAN_INCLI_ ## mod, \ |
612 | .scan_type = { \ | 613 | .scan_type = { \ |
@@ -646,8 +647,8 @@ static const struct iio_chan_spec adis16448_channels[] = { | |||
646 | ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 16), | 647 | ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 16), |
647 | { | 648 | { |
648 | .type = IIO_PRESSURE, | 649 | .type = IIO_PRESSURE, |
649 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 650 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
650 | IIO_CHAN_INFO_SCALE_SHARED_BIT, | 651 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
651 | .address = ADIS16448_BARO_OUT, | 652 | .address = ADIS16448_BARO_OUT, |
652 | .scan_index = ADIS16400_SCAN_BARO, | 653 | .scan_index = ADIS16400_SCAN_BARO, |
653 | .scan_type = IIO_ST('s', 16, 16, 0), | 654 | .scan_type = IIO_ST('s', 16, 16, 0), |
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 8c26a5f7cd5d..b7db38376295 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c | |||
@@ -591,15 +591,15 @@ static int adis16480_write_raw(struct iio_dev *indio_dev, | |||
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | #define ADIS16480_MOD_CHANNEL(_type, _mod, _address, _si, _info, _bits) \ | 594 | #define ADIS16480_MOD_CHANNEL(_type, _mod, _address, _si, _info_sep, _bits) \ |
595 | { \ | 595 | { \ |
596 | .type = (_type), \ | 596 | .type = (_type), \ |
597 | .modified = 1, \ | 597 | .modified = 1, \ |
598 | .channel2 = (_mod), \ | 598 | .channel2 = (_mod), \ |
599 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 599 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
600 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \ | 600 | BIT(IIO_CHAN_INFO_CALIBBIAS) | \ |
601 | IIO_CHAN_INFO_SCALE_SHARED_BIT | \ | 601 | _info_sep, \ |
602 | _info, \ | 602 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
603 | .address = (_address), \ | 603 | .address = (_address), \ |
604 | .scan_index = (_si), \ | 604 | .scan_index = (_si), \ |
605 | .scan_type = { \ | 605 | .scan_type = { \ |
@@ -613,21 +613,21 @@ static int adis16480_write_raw(struct iio_dev *indio_dev, | |||
613 | #define ADIS16480_GYRO_CHANNEL(_mod) \ | 613 | #define ADIS16480_GYRO_CHANNEL(_mod) \ |
614 | ADIS16480_MOD_CHANNEL(IIO_ANGL_VEL, IIO_MOD_ ## _mod, \ | 614 | ADIS16480_MOD_CHANNEL(IIO_ANGL_VEL, IIO_MOD_ ## _mod, \ |
615 | ADIS16480_REG_ ## _mod ## _GYRO_OUT, ADIS16480_SCAN_GYRO_ ## _mod, \ | 615 | ADIS16480_REG_ ## _mod ## _GYRO_OUT, ADIS16480_SCAN_GYRO_ ## _mod, \ |
616 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SEPARATE_BIT | \ | 616 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY) | \ |
617 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, \ | 617 | BIT(IIO_CHAN_INFO_CALIBSCALE), \ |
618 | 32) | 618 | 32) |
619 | 619 | ||
620 | #define ADIS16480_ACCEL_CHANNEL(_mod) \ | 620 | #define ADIS16480_ACCEL_CHANNEL(_mod) \ |
621 | ADIS16480_MOD_CHANNEL(IIO_ACCEL, IIO_MOD_ ## _mod, \ | 621 | ADIS16480_MOD_CHANNEL(IIO_ACCEL, IIO_MOD_ ## _mod, \ |
622 | ADIS16480_REG_ ## _mod ## _ACCEL_OUT, ADIS16480_SCAN_ACCEL_ ## _mod, \ | 622 | ADIS16480_REG_ ## _mod ## _ACCEL_OUT, ADIS16480_SCAN_ACCEL_ ## _mod, \ |
623 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SEPARATE_BIT | \ | 623 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY) | \ |
624 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, \ | 624 | BIT(IIO_CHAN_INFO_CALIBSCALE), \ |
625 | 32) | 625 | 32) |
626 | 626 | ||
627 | #define ADIS16480_MAGN_CHANNEL(_mod) \ | 627 | #define ADIS16480_MAGN_CHANNEL(_mod) \ |
628 | ADIS16480_MOD_CHANNEL(IIO_MAGN, IIO_MOD_ ## _mod, \ | 628 | ADIS16480_MOD_CHANNEL(IIO_MAGN, IIO_MOD_ ## _mod, \ |
629 | ADIS16480_REG_ ## _mod ## _MAGN_OUT, ADIS16480_SCAN_MAGN_ ## _mod, \ | 629 | ADIS16480_REG_ ## _mod ## _MAGN_OUT, ADIS16480_SCAN_MAGN_ ## _mod, \ |
630 | IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SEPARATE_BIT, \ | 630 | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ |
631 | 16) | 631 | 16) |
632 | 632 | ||
633 | #define ADIS16480_PRESSURE_CHANNEL() \ | 633 | #define ADIS16480_PRESSURE_CHANNEL() \ |
@@ -635,9 +635,9 @@ static int adis16480_write_raw(struct iio_dev *indio_dev, | |||
635 | .type = IIO_PRESSURE, \ | 635 | .type = IIO_PRESSURE, \ |
636 | .indexed = 1, \ | 636 | .indexed = 1, \ |
637 | .channel = 0, \ | 637 | .channel = 0, \ |
638 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 638 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
639 | IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \ | 639 | BIT(IIO_CHAN_INFO_CALIBBIAS) | \ |
640 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ | 640 | BIT(IIO_CHAN_INFO_SCALE), \ |
641 | .address = ADIS16480_REG_BAROM_OUT, \ | 641 | .address = ADIS16480_REG_BAROM_OUT, \ |
642 | .scan_index = ADIS16480_SCAN_BARO, \ | 642 | .scan_index = ADIS16480_SCAN_BARO, \ |
643 | .scan_type = { \ | 643 | .scan_type = { \ |
@@ -652,9 +652,9 @@ static int adis16480_write_raw(struct iio_dev *indio_dev, | |||
652 | .type = IIO_TEMP, \ | 652 | .type = IIO_TEMP, \ |
653 | .indexed = 1, \ | 653 | .indexed = 1, \ |
654 | .channel = 0, \ | 654 | .channel = 0, \ |
655 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 655 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
656 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ | 656 | BIT(IIO_CHAN_INFO_SCALE) | \ |
657 | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, \ | 657 | BIT(IIO_CHAN_INFO_OFFSET), \ |
658 | .address = ADIS16480_REG_TEMP_OUT, \ | 658 | .address = ADIS16480_REG_TEMP_OUT, \ |
659 | .scan_index = ADIS16480_SCAN_TEMP, \ | 659 | .scan_index = ADIS16480_SCAN_TEMP, \ |
660 | .scan_type = { \ | 660 | .scan_type = { \ |
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 37ca05b47e4b..fe4c61e219f3 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | |||
@@ -544,8 +544,8 @@ static int inv_mpu6050_validate_trigger(struct iio_dev *indio_dev, | |||
544 | .type = _type, \ | 544 | .type = _type, \ |
545 | .modified = 1, \ | 545 | .modified = 1, \ |
546 | .channel2 = _channel2, \ | 546 | .channel2 = _channel2, \ |
547 | .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT \ | 547 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
548 | | IIO_CHAN_INFO_RAW_SEPARATE_BIT, \ | 548 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
549 | .scan_index = _index, \ | 549 | .scan_index = _index, \ |
550 | .scan_type = { \ | 550 | .scan_type = { \ |
551 | .sign = 's', \ | 551 | .sign = 's', \ |
@@ -564,9 +564,9 @@ static const struct iio_chan_spec inv_mpu_channels[] = { | |||
564 | */ | 564 | */ |
565 | { | 565 | { |
566 | .type = IIO_TEMP, | 566 | .type = IIO_TEMP, |
567 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | 567 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
568 | | IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | 568 | | BIT(IIO_CHAN_INFO_OFFSET) |
569 | | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 569 | | BIT(IIO_CHAN_INFO_SCALE), |
570 | .scan_index = -1, | 570 | .scan_index = -1, |
571 | }, | 571 | }, |
572 | INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), | 572 | INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU6050_SCAN_GYRO_X), |
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 331781ffbb15..7da0832f187b 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | |||
@@ -105,9 +105,8 @@ irqreturn_t inv_mpu6050_irq_handler(int irq, void *p) | |||
105 | s64 timestamp; | 105 | s64 timestamp; |
106 | 106 | ||
107 | timestamp = iio_get_time_ns(); | 107 | timestamp = iio_get_time_ns(); |
108 | spin_lock(&st->time_stamp_lock); | 108 | kfifo_in_spinlocked(&st->timestamps, ×tamp, 1, |
109 | kfifo_in(&st->timestamps, ×tamp, 1); | 109 | &st->time_stamp_lock); |
110 | spin_unlock(&st->time_stamp_lock); | ||
111 | 110 | ||
112 | return IRQ_WAKE_THREAD; | 111 | return IRQ_WAKE_THREAD; |
113 | } | 112 | } |
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 8848f16c547b..e145931ef1b8 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
@@ -691,21 +691,34 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev, | |||
691 | 691 | ||
692 | if (chan->channel < 0) | 692 | if (chan->channel < 0) |
693 | return 0; | 693 | return 0; |
694 | for_each_set_bit(i, &chan->info_mask, sizeof(long)*8) { | 694 | for_each_set_bit(i, &chan->info_mask_separate, sizeof(long)*8) { |
695 | ret = __iio_add_chan_devattr(iio_chan_info_postfix[i/2], | 695 | ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], |
696 | chan, | 696 | chan, |
697 | &iio_read_channel_info, | 697 | &iio_read_channel_info, |
698 | &iio_write_channel_info, | 698 | &iio_write_channel_info, |
699 | i/2, | 699 | i, |
700 | !(i%2), | 700 | 0, |
701 | &indio_dev->dev, | 701 | &indio_dev->dev, |
702 | &indio_dev->channel_attr_list); | 702 | &indio_dev->channel_attr_list); |
703 | if (ret == -EBUSY && (i%2 == 0)) { | 703 | if (ret < 0) |
704 | goto error_ret; | ||
705 | attrcount++; | ||
706 | } | ||
707 | for_each_set_bit(i, &chan->info_mask_shared_by_type, sizeof(long)*8) { | ||
708 | ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], | ||
709 | chan, | ||
710 | &iio_read_channel_info, | ||
711 | &iio_write_channel_info, | ||
712 | i, | ||
713 | 1, | ||
714 | &indio_dev->dev, | ||
715 | &indio_dev->channel_attr_list); | ||
716 | if (ret == -EBUSY) { | ||
704 | ret = 0; | 717 | ret = 0; |
705 | continue; | 718 | continue; |
706 | } | 719 | } else if (ret < 0) { |
707 | if (ret < 0) | ||
708 | goto error_ret; | 720 | goto error_ret; |
721 | } | ||
709 | attrcount++; | 722 | attrcount++; |
710 | } | 723 | } |
711 | 724 | ||
@@ -847,7 +860,7 @@ static void iio_dev_release(struct device *device) | |||
847 | kfree(indio_dev); | 860 | kfree(indio_dev); |
848 | } | 861 | } |
849 | 862 | ||
850 | static struct device_type iio_dev_type = { | 863 | struct device_type iio_device_type = { |
851 | .name = "iio_device", | 864 | .name = "iio_device", |
852 | .release = iio_dev_release, | 865 | .release = iio_dev_release, |
853 | }; | 866 | }; |
@@ -869,7 +882,7 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) | |||
869 | 882 | ||
870 | if (dev) { | 883 | if (dev) { |
871 | dev->dev.groups = dev->groups; | 884 | dev->dev.groups = dev->groups; |
872 | dev->dev.type = &iio_dev_type; | 885 | dev->dev.type = &iio_device_type; |
873 | dev->dev.bus = &iio_bus_type; | 886 | dev->dev.bus = &iio_bus_type; |
874 | device_initialize(&dev->dev); | 887 | device_initialize(&dev->dev); |
875 | dev_set_drvdata(&dev->dev, (void *)dev); | 888 | dev_set_drvdata(&dev->dev, (void *)dev); |
@@ -960,6 +973,10 @@ int iio_device_register(struct iio_dev *indio_dev) | |||
960 | { | 973 | { |
961 | int ret; | 974 | int ret; |
962 | 975 | ||
976 | /* If the calling driver did not initialize of_node, do it here */ | ||
977 | if (!indio_dev->dev.of_node && indio_dev->dev.parent) | ||
978 | indio_dev->dev.of_node = indio_dev->dev.parent->of_node; | ||
979 | |||
963 | /* configure elements for the chrdev */ | 980 | /* configure elements for the chrdev */ |
964 | indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); | 981 | indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); |
965 | 982 | ||
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 261cae00557e..10aa9ef86cec 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c | |||
@@ -46,10 +46,11 @@ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) | |||
46 | { | 46 | { |
47 | struct iio_event_interface *ev_int = indio_dev->event_interface; | 47 | struct iio_event_interface *ev_int = indio_dev->event_interface; |
48 | struct iio_event_data ev; | 48 | struct iio_event_data ev; |
49 | unsigned long flags; | ||
49 | int copied; | 50 | int copied; |
50 | 51 | ||
51 | /* Does anyone care? */ | 52 | /* Does anyone care? */ |
52 | spin_lock(&ev_int->wait.lock); | 53 | spin_lock_irqsave(&ev_int->wait.lock, flags); |
53 | if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { | 54 | if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { |
54 | 55 | ||
55 | ev.id = ev_code; | 56 | ev.id = ev_code; |
@@ -59,7 +60,7 @@ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) | |||
59 | if (copied != 0) | 60 | if (copied != 0) |
60 | wake_up_locked_poll(&ev_int->wait, POLLIN); | 61 | wake_up_locked_poll(&ev_int->wait, POLLIN); |
61 | } | 62 | } |
62 | spin_unlock(&ev_int->wait.lock); | 63 | spin_unlock_irqrestore(&ev_int->wait.lock, flags); |
63 | 64 | ||
64 | return 0; | 65 | return 0; |
65 | } | 66 | } |
@@ -76,10 +77,10 @@ static unsigned int iio_event_poll(struct file *filep, | |||
76 | 77 | ||
77 | poll_wait(filep, &ev_int->wait, wait); | 78 | poll_wait(filep, &ev_int->wait, wait); |
78 | 79 | ||
79 | spin_lock(&ev_int->wait.lock); | 80 | spin_lock_irq(&ev_int->wait.lock); |
80 | if (!kfifo_is_empty(&ev_int->det_events)) | 81 | if (!kfifo_is_empty(&ev_int->det_events)) |
81 | events = POLLIN | POLLRDNORM; | 82 | events = POLLIN | POLLRDNORM; |
82 | spin_unlock(&ev_int->wait.lock); | 83 | spin_unlock_irq(&ev_int->wait.lock); |
83 | 84 | ||
84 | return events; | 85 | return events; |
85 | } | 86 | } |
@@ -96,14 +97,14 @@ static ssize_t iio_event_chrdev_read(struct file *filep, | |||
96 | if (count < sizeof(struct iio_event_data)) | 97 | if (count < sizeof(struct iio_event_data)) |
97 | return -EINVAL; | 98 | return -EINVAL; |
98 | 99 | ||
99 | spin_lock(&ev_int->wait.lock); | 100 | spin_lock_irq(&ev_int->wait.lock); |
100 | if (kfifo_is_empty(&ev_int->det_events)) { | 101 | if (kfifo_is_empty(&ev_int->det_events)) { |
101 | if (filep->f_flags & O_NONBLOCK) { | 102 | if (filep->f_flags & O_NONBLOCK) { |
102 | ret = -EAGAIN; | 103 | ret = -EAGAIN; |
103 | goto error_unlock; | 104 | goto error_unlock; |
104 | } | 105 | } |
105 | /* Blocking on device; waiting for something to be there */ | 106 | /* Blocking on device; waiting for something to be there */ |
106 | ret = wait_event_interruptible_locked(ev_int->wait, | 107 | ret = wait_event_interruptible_locked_irq(ev_int->wait, |
107 | !kfifo_is_empty(&ev_int->det_events)); | 108 | !kfifo_is_empty(&ev_int->det_events)); |
108 | if (ret) | 109 | if (ret) |
109 | goto error_unlock; | 110 | goto error_unlock; |
@@ -113,7 +114,7 @@ static ssize_t iio_event_chrdev_read(struct file *filep, | |||
113 | ret = kfifo_to_user(&ev_int->det_events, buf, count, &copied); | 114 | ret = kfifo_to_user(&ev_int->det_events, buf, count, &copied); |
114 | 115 | ||
115 | error_unlock: | 116 | error_unlock: |
116 | spin_unlock(&ev_int->wait.lock); | 117 | spin_unlock_irq(&ev_int->wait.lock); |
117 | 118 | ||
118 | return ret ? ret : copied; | 119 | return ret ? ret : copied; |
119 | } | 120 | } |
@@ -122,7 +123,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) | |||
122 | { | 123 | { |
123 | struct iio_event_interface *ev_int = filep->private_data; | 124 | struct iio_event_interface *ev_int = filep->private_data; |
124 | 125 | ||
125 | spin_lock(&ev_int->wait.lock); | 126 | spin_lock_irq(&ev_int->wait.lock); |
126 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); | 127 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); |
127 | /* | 128 | /* |
128 | * In order to maintain a clean state for reopening, | 129 | * In order to maintain a clean state for reopening, |
@@ -130,7 +131,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) | |||
130 | * any new __iio_push_event calls running. | 131 | * any new __iio_push_event calls running. |
131 | */ | 132 | */ |
132 | kfifo_reset_out(&ev_int->det_events); | 133 | kfifo_reset_out(&ev_int->det_events); |
133 | spin_unlock(&ev_int->wait.lock); | 134 | spin_unlock_irq(&ev_int->wait.lock); |
134 | 135 | ||
135 | return 0; | 136 | return 0; |
136 | } | 137 | } |
@@ -151,18 +152,18 @@ int iio_event_getfd(struct iio_dev *indio_dev) | |||
151 | if (ev_int == NULL) | 152 | if (ev_int == NULL) |
152 | return -ENODEV; | 153 | return -ENODEV; |
153 | 154 | ||
154 | spin_lock(&ev_int->wait.lock); | 155 | spin_lock_irq(&ev_int->wait.lock); |
155 | if (__test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { | 156 | if (__test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { |
156 | spin_unlock(&ev_int->wait.lock); | 157 | spin_unlock_irq(&ev_int->wait.lock); |
157 | return -EBUSY; | 158 | return -EBUSY; |
158 | } | 159 | } |
159 | spin_unlock(&ev_int->wait.lock); | 160 | spin_unlock_irq(&ev_int->wait.lock); |
160 | fd = anon_inode_getfd("iio:event", | 161 | fd = anon_inode_getfd("iio:event", |
161 | &iio_event_chrdev_fileops, ev_int, O_RDONLY); | 162 | &iio_event_chrdev_fileops, ev_int, O_RDONLY); |
162 | if (fd < 0) { | 163 | if (fd < 0) { |
163 | spin_lock(&ev_int->wait.lock); | 164 | spin_lock_irq(&ev_int->wait.lock); |
164 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); | 165 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); |
165 | spin_unlock(&ev_int->wait.lock); | 166 | spin_unlock_irq(&ev_int->wait.lock); |
166 | } | 167 | } |
167 | return fd; | 168 | return fd; |
168 | } | 169 | } |
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index b289915b8469..795d100b4c36 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/mutex.h> | 12 | #include <linux/mutex.h> |
13 | #include <linux/of.h> | ||
13 | 14 | ||
14 | #include <linux/iio/iio.h> | 15 | #include <linux/iio/iio.h> |
15 | #include "iio_core.h" | 16 | #include "iio_core.h" |
@@ -92,6 +93,164 @@ static const struct iio_chan_spec | |||
92 | return chan; | 93 | return chan; |
93 | } | 94 | } |
94 | 95 | ||
96 | #ifdef CONFIG_OF | ||
97 | |||
98 | static int iio_dev_node_match(struct device *dev, void *data) | ||
99 | { | ||
100 | return dev->of_node == data && dev->type == &iio_device_type; | ||
101 | } | ||
102 | |||
103 | static int __of_iio_channel_get(struct iio_channel *channel, | ||
104 | struct device_node *np, int index) | ||
105 | { | ||
106 | struct device *idev; | ||
107 | struct iio_dev *indio_dev; | ||
108 | int err; | ||
109 | struct of_phandle_args iiospec; | ||
110 | |||
111 | err = of_parse_phandle_with_args(np, "io-channels", | ||
112 | "#io-channel-cells", | ||
113 | index, &iiospec); | ||
114 | if (err) | ||
115 | return err; | ||
116 | |||
117 | idev = bus_find_device(&iio_bus_type, NULL, iiospec.np, | ||
118 | iio_dev_node_match); | ||
119 | of_node_put(iiospec.np); | ||
120 | if (idev == NULL) | ||
121 | return -EPROBE_DEFER; | ||
122 | |||
123 | indio_dev = dev_to_iio_dev(idev); | ||
124 | channel->indio_dev = indio_dev; | ||
125 | index = iiospec.args_count ? iiospec.args[0] : 0; | ||
126 | if (index >= indio_dev->num_channels) { | ||
127 | return -EINVAL; | ||
128 | goto err_put; | ||
129 | } | ||
130 | channel->channel = &indio_dev->channels[index]; | ||
131 | |||
132 | return 0; | ||
133 | |||
134 | err_put: | ||
135 | iio_device_put(indio_dev); | ||
136 | return err; | ||
137 | } | ||
138 | |||
139 | static struct iio_channel *of_iio_channel_get(struct device_node *np, int index) | ||
140 | { | ||
141 | struct iio_channel *channel; | ||
142 | int err; | ||
143 | |||
144 | if (index < 0) | ||
145 | return ERR_PTR(-EINVAL); | ||
146 | |||
147 | channel = kzalloc(sizeof(*channel), GFP_KERNEL); | ||
148 | if (channel == NULL) | ||
149 | return ERR_PTR(-ENOMEM); | ||
150 | |||
151 | err = __of_iio_channel_get(channel, np, index); | ||
152 | if (err) | ||
153 | goto err_free_channel; | ||
154 | |||
155 | return channel; | ||
156 | |||
157 | err_free_channel: | ||
158 | kfree(channel); | ||
159 | return ERR_PTR(err); | ||
160 | } | ||
161 | |||
162 | static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, | ||
163 | const char *name) | ||
164 | { | ||
165 | struct iio_channel *chan = NULL; | ||
166 | |||
167 | /* Walk up the tree of devices looking for a matching iio channel */ | ||
168 | while (np) { | ||
169 | int index = 0; | ||
170 | |||
171 | /* | ||
172 | * For named iio channels, first look up the name in the | ||
173 | * "io-channel-names" property. If it cannot be found, the | ||
174 | * index will be an error code, and of_iio_channel_get() | ||
175 | * will fail. | ||
176 | */ | ||
177 | if (name) | ||
178 | index = of_property_match_string(np, "io-channel-names", | ||
179 | name); | ||
180 | chan = of_iio_channel_get(np, index); | ||
181 | if (!IS_ERR(chan)) | ||
182 | break; | ||
183 | else if (name && index >= 0) { | ||
184 | pr_err("ERROR: could not get IIO channel %s:%s(%i)\n", | ||
185 | np->full_name, name ? name : "", index); | ||
186 | return chan; | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * No matching IIO channel found on this node. | ||
191 | * If the parent node has a "io-channel-ranges" property, | ||
192 | * then we can try one of its channels. | ||
193 | */ | ||
194 | np = np->parent; | ||
195 | if (np && !of_get_property(np, "io-channel-ranges", NULL)) | ||
196 | break; | ||
197 | } | ||
198 | return chan; | ||
199 | } | ||
200 | |||
201 | static struct iio_channel *of_iio_channel_get_all(struct device *dev) | ||
202 | { | ||
203 | struct iio_channel *chans; | ||
204 | int i, mapind, nummaps = 0; | ||
205 | int ret; | ||
206 | |||
207 | do { | ||
208 | ret = of_parse_phandle_with_args(dev->of_node, | ||
209 | "io-channels", | ||
210 | "#io-channel-cells", | ||
211 | nummaps, NULL); | ||
212 | if (ret < 0) | ||
213 | break; | ||
214 | } while (++nummaps); | ||
215 | |||
216 | if (nummaps == 0) /* no error, return NULL to search map table */ | ||
217 | return NULL; | ||
218 | |||
219 | /* NULL terminated array to save passing size */ | ||
220 | chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); | ||
221 | if (chans == NULL) | ||
222 | return ERR_PTR(-ENOMEM); | ||
223 | |||
224 | /* Search for OF matches */ | ||
225 | for (mapind = 0; mapind < nummaps; mapind++) { | ||
226 | ret = __of_iio_channel_get(&chans[mapind], dev->of_node, | ||
227 | mapind); | ||
228 | if (ret) | ||
229 | goto error_free_chans; | ||
230 | } | ||
231 | return chans; | ||
232 | |||
233 | error_free_chans: | ||
234 | for (i = 0; i < mapind; i++) | ||
235 | iio_device_put(chans[i].indio_dev); | ||
236 | kfree(chans); | ||
237 | return ERR_PTR(ret); | ||
238 | } | ||
239 | |||
240 | #else /* CONFIG_OF */ | ||
241 | |||
242 | static inline struct iio_channel * | ||
243 | of_iio_channel_get_by_name(struct device_node *np, const char *name) | ||
244 | { | ||
245 | return NULL; | ||
246 | } | ||
247 | |||
248 | static inline struct iio_channel *of_iio_channel_get_all(struct device *dev) | ||
249 | { | ||
250 | return NULL; | ||
251 | } | ||
252 | |||
253 | #endif /* CONFIG_OF */ | ||
95 | 254 | ||
96 | static struct iio_channel *iio_channel_get_sys(const char *name, | 255 | static struct iio_channel *iio_channel_get_sys(const char *name, |
97 | const char *channel_name) | 256 | const char *channel_name) |
@@ -150,7 +309,14 @@ struct iio_channel *iio_channel_get(struct device *dev, | |||
150 | const char *channel_name) | 309 | const char *channel_name) |
151 | { | 310 | { |
152 | const char *name = dev ? dev_name(dev) : NULL; | 311 | const char *name = dev ? dev_name(dev) : NULL; |
312 | struct iio_channel *channel; | ||
153 | 313 | ||
314 | if (dev) { | ||
315 | channel = of_iio_channel_get_by_name(dev->of_node, | ||
316 | channel_name); | ||
317 | if (channel != NULL) | ||
318 | return channel; | ||
319 | } | ||
154 | return iio_channel_get_sys(name, channel_name); | 320 | return iio_channel_get_sys(name, channel_name); |
155 | } | 321 | } |
156 | EXPORT_SYMBOL_GPL(iio_channel_get); | 322 | EXPORT_SYMBOL_GPL(iio_channel_get); |
@@ -173,6 +339,11 @@ struct iio_channel *iio_channel_get_all(struct device *dev) | |||
173 | 339 | ||
174 | if (dev == NULL) | 340 | if (dev == NULL) |
175 | return ERR_PTR(-EINVAL); | 341 | return ERR_PTR(-EINVAL); |
342 | |||
343 | chans = of_iio_channel_get_all(dev); | ||
344 | if (chans) | ||
345 | return chans; | ||
346 | |||
176 | name = dev_name(dev); | 347 | name = dev_name(dev); |
177 | 348 | ||
178 | mutex_lock(&iio_map_list_lock); | 349 | mutex_lock(&iio_map_list_lock); |
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index d5b9d39d95b2..5f4749e60b04 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c | |||
@@ -207,8 +207,8 @@ static const struct iio_chan_spec_ext_info adjd_s311_ext_info[] = { | |||
207 | .type = IIO_INTENSITY, \ | 207 | .type = IIO_INTENSITY, \ |
208 | .modified = 1, \ | 208 | .modified = 1, \ |
209 | .address = (IDX_##_color), \ | 209 | .address = (IDX_##_color), \ |
210 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ | 210 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
211 | IIO_CHAN_INFO_HARDWAREGAIN_SEPARATE_BIT, \ | 211 | BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ |
212 | .channel2 = (IIO_MOD_LIGHT_##_color), \ | 212 | .channel2 = (IIO_MOD_LIGHT_##_color), \ |
213 | .scan_index = (_scan_idx), \ | 213 | .scan_index = (_scan_idx), \ |
214 | .scan_type = IIO_ST('u', 10, 16, 0), \ | 214 | .scan_type = IIO_ST('u', 10, 16, 0), \ |
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 3d7e8c9b4beb..80d68ff02d29 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c | |||
@@ -49,10 +49,10 @@ static const struct iio_chan_spec als_channels[] = { | |||
49 | .type = IIO_INTENSITY, | 49 | .type = IIO_INTENSITY, |
50 | .modified = 1, | 50 | .modified = 1, |
51 | .channel2 = IIO_MOD_LIGHT_BOTH, | 51 | .channel2 = IIO_MOD_LIGHT_BOTH, |
52 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 52 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
53 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 53 | BIT(IIO_CHAN_INFO_SCALE) | |
54 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 54 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
55 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 55 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
56 | .scan_index = CHANNEL_SCAN_INDEX_ILLUM, | 56 | .scan_index = CHANNEL_SCAN_INDEX_ILLUM, |
57 | } | 57 | } |
58 | }; | 58 | }; |
diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c index 7503012ce933..5fa31a4ef82a 100644 --- a/drivers/iio/light/lm3533-als.c +++ b/drivers/iio/light/lm3533-als.c | |||
@@ -231,7 +231,7 @@ static int lm3533_als_read_raw(struct iio_dev *indio_dev, | |||
231 | .channel = _channel, \ | 231 | .channel = _channel, \ |
232 | .indexed = true, \ | 232 | .indexed = true, \ |
233 | .output = true, \ | 233 | .output = true, \ |
234 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \ | 234 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
235 | } | 235 | } |
236 | 236 | ||
237 | static const struct iio_chan_spec lm3533_als_channels[] = { | 237 | static const struct iio_chan_spec lm3533_als_channels[] = { |
@@ -239,8 +239,8 @@ static const struct iio_chan_spec lm3533_als_channels[] = { | |||
239 | .type = IIO_LIGHT, | 239 | .type = IIO_LIGHT, |
240 | .channel = 0, | 240 | .channel = 0, |
241 | .indexed = true, | 241 | .indexed = true, |
242 | .info_mask = (IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT | | 242 | .info_mask_separate = BIT(IIO_CHAN_INFO_AVERAGE_RAW) | |
243 | IIO_CHAN_INFO_RAW_SEPARATE_BIT), | 243 | BIT(IIO_CHAN_INFO_RAW), |
244 | }, | 244 | }, |
245 | CHANNEL_CURRENT(0), | 245 | CHANNEL_CURRENT(0), |
246 | CHANNEL_CURRENT(1), | 246 | CHANNEL_CURRENT(1), |
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index fd8be69b7d05..1f529f36f138 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c | |||
@@ -530,14 +530,14 @@ static const struct iio_chan_spec tsl2563_channels[] = { | |||
530 | { | 530 | { |
531 | .type = IIO_LIGHT, | 531 | .type = IIO_LIGHT, |
532 | .indexed = 1, | 532 | .indexed = 1, |
533 | .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT, | 533 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), |
534 | .channel = 0, | 534 | .channel = 0, |
535 | }, { | 535 | }, { |
536 | .type = IIO_INTENSITY, | 536 | .type = IIO_INTENSITY, |
537 | .modified = 1, | 537 | .modified = 1, |
538 | .channel2 = IIO_MOD_LIGHT_BOTH, | 538 | .channel2 = IIO_MOD_LIGHT_BOTH, |
539 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 539 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
540 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, | 540 | BIT(IIO_CHAN_INFO_CALIBSCALE), |
541 | .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, | 541 | .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, |
542 | IIO_EV_DIR_RISING) | | 542 | IIO_EV_DIR_RISING) | |
543 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, | 543 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, |
@@ -546,8 +546,8 @@ static const struct iio_chan_spec tsl2563_channels[] = { | |||
546 | .type = IIO_INTENSITY, | 546 | .type = IIO_INTENSITY, |
547 | .modified = 1, | 547 | .modified = 1, |
548 | .channel2 = IIO_MOD_LIGHT_IR, | 548 | .channel2 = IIO_MOD_LIGHT_IR, |
549 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 549 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
550 | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT, | 550 | BIT(IIO_CHAN_INFO_CALIBSCALE), |
551 | } | 551 | } |
552 | }; | 552 | }; |
553 | 553 | ||
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 2aa748fbdc0e..1014943d949a 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c | |||
@@ -93,11 +93,11 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, | |||
93 | static const struct iio_chan_spec vcnl4000_channels[] = { | 93 | static const struct iio_chan_spec vcnl4000_channels[] = { |
94 | { | 94 | { |
95 | .type = IIO_LIGHT, | 95 | .type = IIO_LIGHT, |
96 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | | 96 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
97 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | 97 | BIT(IIO_CHAN_INFO_SCALE), |
98 | }, { | 98 | }, { |
99 | .type = IIO_PROXIMITY, | 99 | .type = IIO_PROXIMITY, |
100 | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, | 100 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
101 | } | 101 | } |
102 | }; | 102 | }; |
103 | 103 | ||
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index d8d01265220b..99f4e494513b 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c | |||
@@ -60,28 +60,28 @@ static const struct iio_chan_spec magn_3d_channels[] = { | |||
60 | .type = IIO_MAGN, | 60 | .type = IIO_MAGN, |
61 | .modified = 1, | 61 | .modified = 1, |
62 | .channel2 = IIO_MOD_X, | 62 | .channel2 = IIO_MOD_X, |
63 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 63 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
64 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 64 | BIT(IIO_CHAN_INFO_SCALE) | |
65 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 65 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
66 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 66 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
67 | .scan_index = CHANNEL_SCAN_INDEX_X, | 67 | .scan_index = CHANNEL_SCAN_INDEX_X, |
68 | }, { | 68 | }, { |
69 | .type = IIO_MAGN, | 69 | .type = IIO_MAGN, |
70 | .modified = 1, | 70 | .modified = 1, |
71 | .channel2 = IIO_MOD_Y, | 71 | .channel2 = IIO_MOD_Y, |
72 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 72 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
73 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 73 | BIT(IIO_CHAN_INFO_SCALE) | |
74 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 74 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
75 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 75 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
76 | .scan_index = CHANNEL_SCAN_INDEX_Y, | 76 | .scan_index = CHANNEL_SCAN_INDEX_Y, |
77 | }, { | 77 | }, { |
78 | .type = IIO_MAGN, | 78 | .type = IIO_MAGN, |
79 | .modified = 1, | 79 | .modified = 1, |
80 | .channel2 = IIO_MOD_Z, | 80 | .channel2 = IIO_MOD_Z, |
81 | .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | | 81 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | |
82 | IIO_CHAN_INFO_SCALE_SHARED_BIT | | 82 | BIT(IIO_CHAN_INFO_SCALE) | |
83 | IIO_CHAN_INFO_SAMP_FREQ_SHARED_BIT | | 83 | BIT(IIO_CHAN_INFO_SAMP_FREQ) | |
84 | IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT, | 84 | BIT(IIO_CHAN_INFO_HYSTERESIS), |
85 | .scan_index = CHANNEL_SCAN_INDEX_Z, | 85 | .scan_index = CHANNEL_SCAN_INDEX_Z, |
86 | } | 86 | } |
87 | }; | 87 | }; |