.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Common library for ADIS16XXX devices |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2012 Analog Devices Inc. |
---|
5 | 6 | * Author: Lars-Peter Clausen <lars@metafoo.de> |
---|
6 | | - * |
---|
7 | | - * Licensed under the GPL-2 or later. |
---|
8 | 7 | */ |
---|
9 | 8 | |
---|
10 | 9 | #ifndef __IIO_ADIS_H__ |
---|
.. | .. |
---|
23 | 22 | struct adis; |
---|
24 | 23 | |
---|
25 | 24 | /** |
---|
| 25 | + * struct adis_timeouts - ADIS chip variant timeouts |
---|
| 26 | + * @reset_ms - Wait time after rst pin goes inactive |
---|
| 27 | + * @sw_reset_ms - Wait time after sw reset command |
---|
| 28 | + * @self_test_ms - Wait time after self test command |
---|
| 29 | + */ |
---|
| 30 | +struct adis_timeout { |
---|
| 31 | + u16 reset_ms; |
---|
| 32 | + u16 sw_reset_ms; |
---|
| 33 | + u16 self_test_ms; |
---|
| 34 | +}; |
---|
| 35 | + |
---|
| 36 | +/** |
---|
26 | 37 | * struct adis_data - ADIS chip variant specific data |
---|
27 | 38 | * @read_delay: SPI delay for read operations in us |
---|
28 | 39 | * @write_delay: SPI delay for write operations in us |
---|
| 40 | + * @cs_change_delay: SPI delay between CS changes in us |
---|
29 | 41 | * @glob_cmd_reg: Register address of the GLOB_CMD register |
---|
30 | 42 | * @msc_ctrl_reg: Register address of the MSC_CTRL register |
---|
31 | 43 | * @diag_stat_reg: Register address of the DIAG_STAT register |
---|
32 | | - * @status_error_msgs: Array of error messgaes |
---|
33 | | - * @status_error_mask: |
---|
| 44 | + * @prod_id_reg: Register address of the PROD_ID register |
---|
| 45 | + * @prod_id: Product ID code that should be expected when reading @prod_id_reg |
---|
| 46 | + * @self_test_mask: Bitmask of supported self-test operations |
---|
| 47 | + * @self_test_reg: Register address to request self test command |
---|
| 48 | + * @self_test_no_autoclear: True if device's self-test needs clear of ctrl reg |
---|
| 49 | + * @status_error_msgs: Array of error messages |
---|
| 50 | + * @status_error_mask: Bitmask of errors supported by the device |
---|
| 51 | + * @timeouts: Chip specific delays |
---|
| 52 | + * @enable_irq: Hook for ADIS devices that have a special IRQ enable/disable |
---|
| 53 | + * @unmasked_drdy: True for devices that cannot mask/unmask the data ready pin |
---|
| 54 | + * @has_paging: True if ADIS device has paged registers |
---|
| 55 | + * @burst_reg_cmd: Register command that triggers burst |
---|
| 56 | + * @burst_len: Burst size in the SPI RX buffer. If @burst_max_len is defined, |
---|
| 57 | + * this should be the minimum size supported by the device. |
---|
| 58 | + * @burst_max_len: Holds the maximum burst size when the device supports |
---|
| 59 | + * more than one burst mode with different sizes |
---|
34 | 60 | */ |
---|
35 | 61 | struct adis_data { |
---|
36 | 62 | unsigned int read_delay; |
---|
37 | 63 | unsigned int write_delay; |
---|
| 64 | + unsigned int cs_change_delay; |
---|
38 | 65 | |
---|
39 | 66 | unsigned int glob_cmd_reg; |
---|
40 | 67 | unsigned int msc_ctrl_reg; |
---|
41 | 68 | unsigned int diag_stat_reg; |
---|
| 69 | + unsigned int prod_id_reg; |
---|
| 70 | + |
---|
| 71 | + unsigned int prod_id; |
---|
42 | 72 | |
---|
43 | 73 | unsigned int self_test_mask; |
---|
| 74 | + unsigned int self_test_reg; |
---|
44 | 75 | bool self_test_no_autoclear; |
---|
45 | | - unsigned int startup_delay; |
---|
| 76 | + const struct adis_timeout *timeouts; |
---|
46 | 77 | |
---|
47 | 78 | const char * const *status_error_msgs; |
---|
48 | 79 | unsigned int status_error_mask; |
---|
49 | 80 | |
---|
50 | 81 | int (*enable_irq)(struct adis *adis, bool enable); |
---|
| 82 | + bool unmasked_drdy; |
---|
51 | 83 | |
---|
52 | 84 | bool has_paging; |
---|
| 85 | + |
---|
| 86 | + unsigned int burst_reg_cmd; |
---|
| 87 | + unsigned int burst_len; |
---|
| 88 | + unsigned int burst_max_len; |
---|
53 | 89 | }; |
---|
54 | 90 | |
---|
| 91 | +/** |
---|
| 92 | + * struct adis - ADIS device instance data |
---|
| 93 | + * @spi: Reference to SPI device which owns this ADIS IIO device |
---|
| 94 | + * @trig: IIO trigger object data |
---|
| 95 | + * @data: ADIS chip variant specific data |
---|
| 96 | + * @burst: ADIS burst transfer information |
---|
| 97 | + * @burst_extra_len: Burst extra length. Should only be used by devices that can |
---|
| 98 | + * dynamically change their burst mode length. |
---|
| 99 | + * @state_lock: Lock used by the device to protect state |
---|
| 100 | + * @msg: SPI message object |
---|
| 101 | + * @xfer: SPI transfer objects to be used for a @msg |
---|
| 102 | + * @current_page: Some ADIS devices have registers, this selects current page |
---|
| 103 | + * @irq_flag: IRQ handling flags as passed to request_irq() |
---|
| 104 | + * @buffer: Data buffer for information read from the device |
---|
| 105 | + * @tx: DMA safe TX buffer for SPI transfers |
---|
| 106 | + * @rx: DMA safe RX buffer for SPI transfers |
---|
| 107 | + */ |
---|
55 | 108 | struct adis { |
---|
56 | 109 | struct spi_device *spi; |
---|
57 | 110 | struct iio_trigger *trig; |
---|
58 | 111 | |
---|
59 | 112 | const struct adis_data *data; |
---|
60 | | - |
---|
61 | | - struct mutex txrx_lock; |
---|
| 113 | + unsigned int burst_extra_len; |
---|
| 114 | + /** |
---|
| 115 | + * The state_lock is meant to be used during operations that require |
---|
| 116 | + * a sequence of SPI R/W in order to protect the SPI transfer |
---|
| 117 | + * information (fields 'xfer', 'msg' & 'current_page') between |
---|
| 118 | + * potential concurrent accesses. |
---|
| 119 | + * This lock is used by all "adis_{functions}" that have to read/write |
---|
| 120 | + * registers. These functions also have unlocked variants |
---|
| 121 | + * (see "__adis_{functions}"), which don't hold this lock. |
---|
| 122 | + * This allows users of the ADIS library to group SPI R/W into |
---|
| 123 | + * the drivers, but they also must manage this lock themselves. |
---|
| 124 | + */ |
---|
| 125 | + struct mutex state_lock; |
---|
62 | 126 | struct spi_message msg; |
---|
63 | 127 | struct spi_transfer *xfer; |
---|
64 | 128 | unsigned int current_page; |
---|
| 129 | + unsigned long irq_flag; |
---|
65 | 130 | void *buffer; |
---|
66 | 131 | |
---|
67 | | - uint8_t tx[10] ____cacheline_aligned; |
---|
68 | | - uint8_t rx[4]; |
---|
| 132 | + u8 tx[10] ____cacheline_aligned; |
---|
| 133 | + u8 rx[4]; |
---|
69 | 134 | }; |
---|
70 | 135 | |
---|
71 | 136 | int adis_init(struct adis *adis, struct iio_dev *indio_dev, |
---|
72 | | - struct spi_device *spi, const struct adis_data *data); |
---|
73 | | -int adis_reset(struct adis *adis); |
---|
| 137 | + struct spi_device *spi, const struct adis_data *data); |
---|
| 138 | +int __adis_reset(struct adis *adis); |
---|
74 | 139 | |
---|
75 | | -int adis_write_reg(struct adis *adis, unsigned int reg, |
---|
76 | | - unsigned int val, unsigned int size); |
---|
77 | | -int adis_read_reg(struct adis *adis, unsigned int reg, |
---|
78 | | - unsigned int *val, unsigned int size); |
---|
| 140 | +/** |
---|
| 141 | + * adis_reset() - Reset the device |
---|
| 142 | + * @adis: The adis device |
---|
| 143 | + * |
---|
| 144 | + * Returns 0 on success, a negative error code otherwise |
---|
| 145 | + */ |
---|
| 146 | +static inline int adis_reset(struct adis *adis) |
---|
| 147 | +{ |
---|
| 148 | + int ret; |
---|
| 149 | + |
---|
| 150 | + mutex_lock(&adis->state_lock); |
---|
| 151 | + ret = __adis_reset(adis); |
---|
| 152 | + mutex_unlock(&adis->state_lock); |
---|
| 153 | + |
---|
| 154 | + return ret; |
---|
| 155 | +} |
---|
| 156 | + |
---|
| 157 | +int __adis_write_reg(struct adis *adis, unsigned int reg, |
---|
| 158 | + unsigned int val, unsigned int size); |
---|
| 159 | +int __adis_read_reg(struct adis *adis, unsigned int reg, |
---|
| 160 | + unsigned int *val, unsigned int size); |
---|
| 161 | + |
---|
| 162 | +/** |
---|
| 163 | + * __adis_write_reg_8() - Write single byte to a register (unlocked) |
---|
| 164 | + * @adis: The adis device |
---|
| 165 | + * @reg: The address of the register to be written |
---|
| 166 | + * @value: The value to write |
---|
| 167 | + */ |
---|
| 168 | +static inline int __adis_write_reg_8(struct adis *adis, unsigned int reg, |
---|
| 169 | + u8 val) |
---|
| 170 | +{ |
---|
| 171 | + return __adis_write_reg(adis, reg, val, 1); |
---|
| 172 | +} |
---|
| 173 | + |
---|
| 174 | +/** |
---|
| 175 | + * __adis_write_reg_16() - Write 2 bytes to a pair of registers (unlocked) |
---|
| 176 | + * @adis: The adis device |
---|
| 177 | + * @reg: The address of the lower of the two registers |
---|
| 178 | + * @value: Value to be written |
---|
| 179 | + */ |
---|
| 180 | +static inline int __adis_write_reg_16(struct adis *adis, unsigned int reg, |
---|
| 181 | + u16 val) |
---|
| 182 | +{ |
---|
| 183 | + return __adis_write_reg(adis, reg, val, 2); |
---|
| 184 | +} |
---|
| 185 | + |
---|
| 186 | +/** |
---|
| 187 | + * __adis_write_reg_32() - write 4 bytes to four registers (unlocked) |
---|
| 188 | + * @adis: The adis device |
---|
| 189 | + * @reg: The address of the lower of the four register |
---|
| 190 | + * @value: Value to be written |
---|
| 191 | + */ |
---|
| 192 | +static inline int __adis_write_reg_32(struct adis *adis, unsigned int reg, |
---|
| 193 | + u32 val) |
---|
| 194 | +{ |
---|
| 195 | + return __adis_write_reg(adis, reg, val, 4); |
---|
| 196 | +} |
---|
| 197 | + |
---|
| 198 | +/** |
---|
| 199 | + * __adis_read_reg_16() - read 2 bytes from a 16-bit register (unlocked) |
---|
| 200 | + * @adis: The adis device |
---|
| 201 | + * @reg: The address of the lower of the two registers |
---|
| 202 | + * @val: The value read back from the device |
---|
| 203 | + */ |
---|
| 204 | +static inline int __adis_read_reg_16(struct adis *adis, unsigned int reg, |
---|
| 205 | + u16 *val) |
---|
| 206 | +{ |
---|
| 207 | + unsigned int tmp; |
---|
| 208 | + int ret; |
---|
| 209 | + |
---|
| 210 | + ret = __adis_read_reg(adis, reg, &tmp, 2); |
---|
| 211 | + if (ret == 0) |
---|
| 212 | + *val = tmp; |
---|
| 213 | + |
---|
| 214 | + return ret; |
---|
| 215 | +} |
---|
| 216 | + |
---|
| 217 | +/** |
---|
| 218 | + * __adis_read_reg_32() - read 4 bytes from a 32-bit register (unlocked) |
---|
| 219 | + * @adis: The adis device |
---|
| 220 | + * @reg: The address of the lower of the two registers |
---|
| 221 | + * @val: The value read back from the device |
---|
| 222 | + */ |
---|
| 223 | +static inline int __adis_read_reg_32(struct adis *adis, unsigned int reg, |
---|
| 224 | + u32 *val) |
---|
| 225 | +{ |
---|
| 226 | + unsigned int tmp; |
---|
| 227 | + int ret; |
---|
| 228 | + |
---|
| 229 | + ret = __adis_read_reg(adis, reg, &tmp, 4); |
---|
| 230 | + if (ret == 0) |
---|
| 231 | + *val = tmp; |
---|
| 232 | + |
---|
| 233 | + return ret; |
---|
| 234 | +} |
---|
| 235 | + |
---|
| 236 | +/** |
---|
| 237 | + * adis_write_reg() - write N bytes to register |
---|
| 238 | + * @adis: The adis device |
---|
| 239 | + * @reg: The address of the lower of the two registers |
---|
| 240 | + * @value: The value to write to device (up to 4 bytes) |
---|
| 241 | + * @size: The size of the @value (in bytes) |
---|
| 242 | + */ |
---|
| 243 | +static inline int adis_write_reg(struct adis *adis, unsigned int reg, |
---|
| 244 | + unsigned int val, unsigned int size) |
---|
| 245 | +{ |
---|
| 246 | + int ret; |
---|
| 247 | + |
---|
| 248 | + mutex_lock(&adis->state_lock); |
---|
| 249 | + ret = __adis_write_reg(adis, reg, val, size); |
---|
| 250 | + mutex_unlock(&adis->state_lock); |
---|
| 251 | + |
---|
| 252 | + return ret; |
---|
| 253 | +} |
---|
| 254 | + |
---|
| 255 | +/** |
---|
| 256 | + * adis_read_reg() - read N bytes from register |
---|
| 257 | + * @adis: The adis device |
---|
| 258 | + * @reg: The address of the lower of the two registers |
---|
| 259 | + * @val: The value read back from the device |
---|
| 260 | + * @size: The size of the @val buffer |
---|
| 261 | + */ |
---|
| 262 | +static int adis_read_reg(struct adis *adis, unsigned int reg, |
---|
| 263 | + unsigned int *val, unsigned int size) |
---|
| 264 | +{ |
---|
| 265 | + int ret; |
---|
| 266 | + |
---|
| 267 | + mutex_lock(&adis->state_lock); |
---|
| 268 | + ret = __adis_read_reg(adis, reg, val, size); |
---|
| 269 | + mutex_unlock(&adis->state_lock); |
---|
| 270 | + |
---|
| 271 | + return ret; |
---|
| 272 | +} |
---|
79 | 273 | |
---|
80 | 274 | /** |
---|
81 | 275 | * adis_write_reg_8() - Write single byte to a register |
---|
.. | .. |
---|
84 | 278 | * @value: The value to write |
---|
85 | 279 | */ |
---|
86 | 280 | static inline int adis_write_reg_8(struct adis *adis, unsigned int reg, |
---|
87 | | - uint8_t val) |
---|
| 281 | + u8 val) |
---|
88 | 282 | { |
---|
89 | 283 | return adis_write_reg(adis, reg, val, 1); |
---|
90 | 284 | } |
---|
.. | .. |
---|
96 | 290 | * @value: Value to be written |
---|
97 | 291 | */ |
---|
98 | 292 | static inline int adis_write_reg_16(struct adis *adis, unsigned int reg, |
---|
99 | | - uint16_t val) |
---|
| 293 | + u16 val) |
---|
100 | 294 | { |
---|
101 | 295 | return adis_write_reg(adis, reg, val, 2); |
---|
102 | 296 | } |
---|
.. | .. |
---|
108 | 302 | * @value: Value to be written |
---|
109 | 303 | */ |
---|
110 | 304 | static inline int adis_write_reg_32(struct adis *adis, unsigned int reg, |
---|
111 | | - uint32_t val) |
---|
| 305 | + u32 val) |
---|
112 | 306 | { |
---|
113 | 307 | return adis_write_reg(adis, reg, val, 4); |
---|
114 | 308 | } |
---|
.. | .. |
---|
120 | 314 | * @val: The value read back from the device |
---|
121 | 315 | */ |
---|
122 | 316 | static inline int adis_read_reg_16(struct adis *adis, unsigned int reg, |
---|
123 | | - uint16_t *val) |
---|
| 317 | + u16 *val) |
---|
124 | 318 | { |
---|
125 | 319 | unsigned int tmp; |
---|
126 | 320 | int ret; |
---|
127 | 321 | |
---|
128 | 322 | ret = adis_read_reg(adis, reg, &tmp, 2); |
---|
129 | | - *val = tmp; |
---|
| 323 | + if (ret == 0) |
---|
| 324 | + *val = tmp; |
---|
130 | 325 | |
---|
131 | 326 | return ret; |
---|
132 | 327 | } |
---|
.. | .. |
---|
138 | 333 | * @val: The value read back from the device |
---|
139 | 334 | */ |
---|
140 | 335 | static inline int adis_read_reg_32(struct adis *adis, unsigned int reg, |
---|
141 | | - uint32_t *val) |
---|
| 336 | + u32 *val) |
---|
142 | 337 | { |
---|
143 | 338 | unsigned int tmp; |
---|
144 | 339 | int ret; |
---|
145 | 340 | |
---|
146 | 341 | ret = adis_read_reg(adis, reg, &tmp, 4); |
---|
147 | | - *val = tmp; |
---|
| 342 | + if (ret == 0) |
---|
| 343 | + *val = tmp; |
---|
148 | 344 | |
---|
149 | 345 | return ret; |
---|
150 | 346 | } |
---|
151 | 347 | |
---|
152 | | -int adis_enable_irq(struct adis *adis, bool enable); |
---|
153 | | -int adis_check_status(struct adis *adis); |
---|
| 348 | +int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask, |
---|
| 349 | + const u32 val, u8 size); |
---|
| 350 | +/** |
---|
| 351 | + * adis_update_bits_base() - ADIS Update bits function - Locked version |
---|
| 352 | + * @adis: The adis device |
---|
| 353 | + * @reg: The address of the lower of the two registers |
---|
| 354 | + * @mask: Bitmask to change |
---|
| 355 | + * @val: Value to be written |
---|
| 356 | + * @size: Size of the register to update |
---|
| 357 | + * |
---|
| 358 | + * Updates the desired bits of @reg in accordance with @mask and @val. |
---|
| 359 | + */ |
---|
| 360 | +static inline int adis_update_bits_base(struct adis *adis, unsigned int reg, |
---|
| 361 | + const u32 mask, const u32 val, u8 size) |
---|
| 362 | +{ |
---|
| 363 | + int ret; |
---|
154 | 364 | |
---|
155 | | -int adis_initial_startup(struct adis *adis); |
---|
| 365 | + mutex_lock(&adis->state_lock); |
---|
| 366 | + ret = __adis_update_bits_base(adis, reg, mask, val, size); |
---|
| 367 | + mutex_unlock(&adis->state_lock); |
---|
| 368 | + return ret; |
---|
| 369 | +} |
---|
| 370 | + |
---|
| 371 | +/** |
---|
| 372 | + * adis_update_bits() - Wrapper macro for adis_update_bits_base - Locked version |
---|
| 373 | + * @adis: The adis device |
---|
| 374 | + * @reg: The address of the lower of the two registers |
---|
| 375 | + * @mask: Bitmask to change |
---|
| 376 | + * @val: Value to be written |
---|
| 377 | + * |
---|
| 378 | + * This macro evaluates the sizeof of @val at compile time and calls |
---|
| 379 | + * adis_update_bits_base() accordingly. Be aware that using MACROS/DEFINES for |
---|
| 380 | + * @val can lead to undesired behavior if the register to update is 16bit. |
---|
| 381 | + */ |
---|
| 382 | +#define adis_update_bits(adis, reg, mask, val) ({ \ |
---|
| 383 | + BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \ |
---|
| 384 | + __builtin_choose_expr(sizeof(val) == 4, \ |
---|
| 385 | + adis_update_bits_base(adis, reg, mask, val, 4), \ |
---|
| 386 | + adis_update_bits_base(adis, reg, mask, val, 2)); \ |
---|
| 387 | +}) |
---|
| 388 | + |
---|
| 389 | +/** |
---|
| 390 | + * adis_update_bits() - Wrapper macro for adis_update_bits_base |
---|
| 391 | + * @adis: The adis device |
---|
| 392 | + * @reg: The address of the lower of the two registers |
---|
| 393 | + * @mask: Bitmask to change |
---|
| 394 | + * @val: Value to be written |
---|
| 395 | + * |
---|
| 396 | + * This macro evaluates the sizeof of @val at compile time and calls |
---|
| 397 | + * adis_update_bits_base() accordingly. Be aware that using MACROS/DEFINES for |
---|
| 398 | + * @val can lead to undesired behavior if the register to update is 16bit. |
---|
| 399 | + */ |
---|
| 400 | +#define __adis_update_bits(adis, reg, mask, val) ({ \ |
---|
| 401 | + BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \ |
---|
| 402 | + __builtin_choose_expr(sizeof(val) == 4, \ |
---|
| 403 | + __adis_update_bits_base(adis, reg, mask, val, 4), \ |
---|
| 404 | + __adis_update_bits_base(adis, reg, mask, val, 2)); \ |
---|
| 405 | +}) |
---|
| 406 | + |
---|
| 407 | +int __adis_check_status(struct adis *adis); |
---|
| 408 | +int __adis_initial_startup(struct adis *adis); |
---|
| 409 | +int __adis_enable_irq(struct adis *adis, bool enable); |
---|
| 410 | + |
---|
| 411 | +static inline int adis_enable_irq(struct adis *adis, bool enable) |
---|
| 412 | +{ |
---|
| 413 | + int ret; |
---|
| 414 | + |
---|
| 415 | + mutex_lock(&adis->state_lock); |
---|
| 416 | + ret = __adis_enable_irq(adis, enable); |
---|
| 417 | + mutex_unlock(&adis->state_lock); |
---|
| 418 | + |
---|
| 419 | + return ret; |
---|
| 420 | +} |
---|
| 421 | + |
---|
| 422 | +static inline int adis_check_status(struct adis *adis) |
---|
| 423 | +{ |
---|
| 424 | + int ret; |
---|
| 425 | + |
---|
| 426 | + mutex_lock(&adis->state_lock); |
---|
| 427 | + ret = __adis_check_status(adis); |
---|
| 428 | + mutex_unlock(&adis->state_lock); |
---|
| 429 | + |
---|
| 430 | + return ret; |
---|
| 431 | +} |
---|
| 432 | + |
---|
| 433 | +/* locked version of __adis_initial_startup() */ |
---|
| 434 | +static inline int adis_initial_startup(struct adis *adis) |
---|
| 435 | +{ |
---|
| 436 | + int ret; |
---|
| 437 | + |
---|
| 438 | + mutex_lock(&adis->state_lock); |
---|
| 439 | + ret = __adis_initial_startup(adis); |
---|
| 440 | + mutex_unlock(&adis->state_lock); |
---|
| 441 | + |
---|
| 442 | + return ret; |
---|
| 443 | +} |
---|
156 | 444 | |
---|
157 | 445 | int adis_single_conversion(struct iio_dev *indio_dev, |
---|
158 | | - const struct iio_chan_spec *chan, unsigned int error_mask, |
---|
159 | | - int *val); |
---|
| 446 | + const struct iio_chan_spec *chan, |
---|
| 447 | + unsigned int error_mask, int *val); |
---|
160 | 448 | |
---|
161 | 449 | #define ADIS_VOLTAGE_CHAN(addr, si, chan, name, info_all, bits) { \ |
---|
162 | 450 | .type = IIO_VOLTAGE, \ |
---|
.. | .. |
---|
205 | 493 | .modified = 1, \ |
---|
206 | 494 | .channel2 = IIO_MOD_ ## mod, \ |
---|
207 | 495 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ |
---|
208 | | - info_sep, \ |
---|
| 496 | + (info_sep), \ |
---|
209 | 497 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ |
---|
210 | 498 | .info_mask_shared_by_all = info_all, \ |
---|
211 | 499 | .address = (addr), \ |
---|
.. | .. |
---|
232 | 520 | |
---|
233 | 521 | #ifdef CONFIG_IIO_ADIS_LIB_BUFFER |
---|
234 | 522 | |
---|
235 | | -int adis_setup_buffer_and_trigger(struct adis *adis, |
---|
236 | | - struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *)); |
---|
237 | | -void adis_cleanup_buffer_and_trigger(struct adis *adis, |
---|
238 | | - struct iio_dev *indio_dev); |
---|
| 523 | +int |
---|
| 524 | +devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev, |
---|
| 525 | + irq_handler_t trigger_handler); |
---|
239 | 526 | |
---|
240 | | -int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev); |
---|
241 | | -void adis_remove_trigger(struct adis *adis); |
---|
| 527 | +int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev); |
---|
242 | 528 | |
---|
243 | 529 | int adis_update_scan_mode(struct iio_dev *indio_dev, |
---|
244 | | - const unsigned long *scan_mask); |
---|
| 530 | + const unsigned long *scan_mask); |
---|
245 | 531 | |
---|
246 | 532 | #else /* CONFIG_IIO_BUFFER */ |
---|
247 | 533 | |
---|
248 | | -static inline int adis_setup_buffer_and_trigger(struct adis *adis, |
---|
249 | | - struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *)) |
---|
| 534 | +static inline int |
---|
| 535 | +devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev, |
---|
| 536 | + irq_handler_t trigger_handler) |
---|
250 | 537 | { |
---|
251 | 538 | return 0; |
---|
252 | 539 | } |
---|
253 | 540 | |
---|
254 | | -static inline void adis_cleanup_buffer_and_trigger(struct adis *adis, |
---|
255 | | - struct iio_dev *indio_dev) |
---|
256 | | -{ |
---|
257 | | -} |
---|
258 | | - |
---|
259 | | -static inline int adis_probe_trigger(struct adis *adis, |
---|
260 | | - struct iio_dev *indio_dev) |
---|
| 541 | +static inline int devm_adis_probe_trigger(struct adis *adis, |
---|
| 542 | + struct iio_dev *indio_dev) |
---|
261 | 543 | { |
---|
262 | 544 | return 0; |
---|
263 | | -} |
---|
264 | | - |
---|
265 | | -static inline void adis_remove_trigger(struct adis *adis) |
---|
266 | | -{ |
---|
267 | 545 | } |
---|
268 | 546 | |
---|
269 | 547 | #define adis_update_scan_mode NULL |
---|
.. | .. |
---|
273 | 551 | #ifdef CONFIG_DEBUG_FS |
---|
274 | 552 | |
---|
275 | 553 | int adis_debugfs_reg_access(struct iio_dev *indio_dev, |
---|
276 | | - unsigned int reg, unsigned int writeval, unsigned int *readval); |
---|
| 554 | + unsigned int reg, unsigned int writeval, |
---|
| 555 | + unsigned int *readval); |
---|
277 | 556 | |
---|
278 | 557 | #else |
---|
279 | 558 | |
---|