]>
Commit | Line | Data |
---|---|---|
ed9eccbe DS |
1 | /* |
2 | include/linux/comedidev.h | |
3 | header file for kernel-only structures, variables, and constants | |
4 | ||
5 | COMEDI - Linux Control and Measurement Device Interface | |
6 | Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org> | |
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 | ||
24 | #ifndef _COMEDIDEV_H | |
25 | #define _COMEDIDEV_H | |
26 | ||
27 | #include <linux/kernel.h> | |
28 | #include <linux/module.h> | |
ed9eccbe DS |
29 | #include <linux/kdev_t.h> |
30 | #include <linux/slab.h> | |
f9c51375 | 31 | #include <linux/delay.h> |
ed9eccbe DS |
32 | #include <linux/errno.h> |
33 | #include <linux/spinlock.h> | |
34 | #include <linux/mutex.h> | |
35 | #include <linux/wait.h> | |
36 | #include <linux/mm.h> | |
37 | #include <linux/init.h> | |
38 | #include <linux/vmalloc.h> | |
ed9eccbe | 39 | #include <linux/dma-mapping.h> |
e0dcef71 GKH |
40 | #include <linux/uaccess.h> |
41 | #include <linux/io.h> | |
c7a5d707 | 42 | #include <linux/timer.h> |
55c03cff | 43 | #include <linux/pci.h> |
ed9eccbe DS |
44 | |
45 | #include "comedi.h" | |
46 | ||
e0dcef71 GKH |
47 | #define DPRINTK(format, args...) do { \ |
48 | if (comedi_debug) \ | |
4f870fe6 | 49 | pr_debug("comedi: " format, ## args); \ |
e0dcef71 | 50 | } while (0) |
ed9eccbe | 51 | |
e0dcef71 | 52 | #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) |
62eeae93 SW |
53 | #define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \ |
54 | COMEDI_MINORVERSION, COMEDI_MICROVERSION) | |
ed9eccbe DS |
55 | #define COMEDI_RELEASE VERSION |
56 | ||
ed9eccbe DS |
57 | #define PCI_VENDOR_ID_ADLINK 0x144a |
58 | #define PCI_VENDOR_ID_ICP 0x104c | |
59 | #define PCI_VENDOR_ID_CONTEC 0x1221 | |
ed9eccbe DS |
60 | |
61 | #define COMEDI_NUM_MINORS 0x100 | |
ed9eccbe DS |
62 | #define COMEDI_NUM_BOARD_MINORS 0x30 |
63 | #define COMEDI_FIRST_SUBDEVICE_MINOR COMEDI_NUM_BOARD_MINORS | |
64 | ||
34c43922 | 65 | struct comedi_subdevice { |
71b5f4f1 | 66 | struct comedi_device *device; |
ed9eccbe DS |
67 | int type; |
68 | int n_chan; | |
baf22b64 | 69 | int subdev_flags; |
ed9eccbe DS |
70 | int len_chanlist; /* maximum length of channel/gain list */ |
71 | ||
72 | void *private; | |
73 | ||
d163679c | 74 | struct comedi_async *async; |
ed9eccbe DS |
75 | |
76 | void *lock; | |
77 | void *busy; | |
78 | unsigned runflags; | |
79 | spinlock_t spin_lock; | |
80 | ||
d4a7dc85 | 81 | unsigned int io_bits; |
ed9eccbe | 82 | |
790c5541 BP |
83 | unsigned int maxdata; /* if maxdata==0, use list */ |
84 | const unsigned int *maxdata_list; /* list is channel specific */ | |
ed9eccbe DS |
85 | |
86 | unsigned int flags; | |
87 | const unsigned int *flaglist; | |
88 | ||
89 | unsigned int settling_time_0; | |
90 | ||
9ced1de6 BP |
91 | const struct comedi_lrange *range_table; |
92 | const struct comedi_lrange *const *range_table_list; | |
ed9eccbe DS |
93 | |
94 | unsigned int *chanlist; /* driver-owned chanlist (not used) */ | |
95 | ||
0a85b6f0 MT |
96 | int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, |
97 | struct comedi_insn *, unsigned int *); | |
98 | int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, | |
99 | struct comedi_insn *, unsigned int *); | |
100 | int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, | |
101 | struct comedi_insn *, unsigned int *); | |
102 | int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, | |
103 | struct comedi_insn *, unsigned int *); | |
ed9eccbe | 104 | |
34c43922 | 105 | int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *); |
0a85b6f0 MT |
106 | int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, |
107 | struct comedi_cmd *); | |
34c43922 BP |
108 | int (*poll) (struct comedi_device *, struct comedi_subdevice *); |
109 | int (*cancel) (struct comedi_device *, struct comedi_subdevice *); | |
62eeae93 SW |
110 | /* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */ |
111 | /* int (*do_unlock)(struct comedi_device *, \ | |
112 | struct comedi_subdevice *); */ | |
ed9eccbe DS |
113 | |
114 | /* called when the buffer changes */ | |
62eeae93 SW |
115 | int (*buf_change) (struct comedi_device *dev, |
116 | struct comedi_subdevice *s, unsigned long new_size); | |
ed9eccbe | 117 | |
62eeae93 | 118 | void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, |
0a85b6f0 MT |
119 | void *data, unsigned int num_bytes, |
120 | unsigned int start_chan_index); | |
ed9eccbe DS |
121 | enum dma_data_direction async_dma_dir; |
122 | ||
123 | unsigned int state; | |
124 | ||
0bfbbe8f | 125 | struct device *class_dev; |
ed9eccbe DS |
126 | int minor; |
127 | }; | |
128 | ||
129 | struct comedi_buf_page { | |
130 | void *virt_addr; | |
131 | dma_addr_t dma_addr; | |
132 | }; | |
133 | ||
d163679c | 134 | struct comedi_async { |
34c43922 | 135 | struct comedi_subdevice *subdevice; |
ed9eccbe DS |
136 | |
137 | void *prealloc_buf; /* pre-allocated buffer */ | |
138 | unsigned int prealloc_bufsz; /* buffer size, in bytes */ | |
62eeae93 SW |
139 | /* virtual and dma address of each page */ |
140 | struct comedi_buf_page *buf_page_list; | |
ed9eccbe DS |
141 | unsigned n_buf_pages; /* num elements in buf_page_list */ |
142 | ||
143 | unsigned int max_bufsize; /* maximum buffer size, bytes */ | |
62eeae93 SW |
144 | /* current number of mmaps of prealloc_buf */ |
145 | unsigned int mmap_count; | |
146 | ||
147 | /* byte count for writer (write completed) */ | |
148 | unsigned int buf_write_count; | |
149 | /* byte count for writer (allocated for writing) */ | |
150 | unsigned int buf_write_alloc_count; | |
151 | /* byte count for reader (read completed) */ | |
152 | unsigned int buf_read_count; | |
153 | /* byte count for reader (allocated for reading) */ | |
154 | unsigned int buf_read_alloc_count; | |
ed9eccbe DS |
155 | |
156 | unsigned int buf_write_ptr; /* buffer marker for writer */ | |
157 | unsigned int buf_read_ptr; /* buffer marker for reader */ | |
158 | ||
159 | unsigned int cur_chan; /* useless channel marker for interrupt */ | |
160 | /* number of bytes that have been received for current scan */ | |
161 | unsigned int scan_progress; | |
162 | /* keeps track of where we are in chanlist as for munging */ | |
163 | unsigned int munge_chan; | |
164 | /* number of bytes that have been munged */ | |
165 | unsigned int munge_count; | |
166 | /* buffer marker for munging */ | |
167 | unsigned int munge_ptr; | |
168 | ||
169 | unsigned int events; /* events that have occurred */ | |
170 | ||
ea6d0d4c | 171 | struct comedi_cmd cmd; |
ed9eccbe DS |
172 | |
173 | wait_queue_head_t wait_head; | |
174 | ||
e0dcef71 | 175 | /* callback stuff */ |
ed9eccbe DS |
176 | unsigned int cb_mask; |
177 | int (*cb_func) (unsigned int flags, void *); | |
178 | void *cb_arg; | |
179 | ||
62eeae93 | 180 | int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s, |
e0dcef71 | 181 | unsigned int x); |
ed9eccbe DS |
182 | }; |
183 | ||
f4011670 IA |
184 | struct usb_interface; |
185 | ||
139dfbdf BP |
186 | struct comedi_driver { |
187 | struct comedi_driver *next; | |
ed9eccbe DS |
188 | |
189 | const char *driver_name; | |
190 | struct module *module; | |
0707bb04 | 191 | int (*attach) (struct comedi_device *, struct comedi_devconfig *); |
484ecc95 | 192 | void (*detach) (struct comedi_device *); |
f4011670 IA |
193 | int (*attach_pci) (struct comedi_device *, struct pci_dev *); |
194 | int (*attach_usb) (struct comedi_device *, struct usb_interface *); | |
ed9eccbe DS |
195 | |
196 | /* number of elements in board_name and board_id arrays */ | |
197 | unsigned int num_names; | |
198 | const char *const *board_name; | |
199 | /* offset in bytes from one board name pointer to the next */ | |
200 | int offset; | |
201 | }; | |
202 | ||
71b5f4f1 | 203 | struct comedi_device { |
ed9eccbe | 204 | int use_count; |
139dfbdf | 205 | struct comedi_driver *driver; |
ed9eccbe DS |
206 | void *private; |
207 | ||
0bfbbe8f | 208 | struct device *class_dev; |
ed9eccbe | 209 | int minor; |
e0dcef71 GKH |
210 | /* hw_dev is passed to dma_alloc_coherent when allocating async buffers |
211 | * for subdevices that have async_dma_dir set to something other than | |
212 | * DMA_NONE */ | |
ed9eccbe DS |
213 | struct device *hw_dev; |
214 | ||
215 | const char *board_name; | |
216 | const void *board_ptr; | |
217 | int attached; | |
ed9eccbe DS |
218 | spinlock_t spinlock; |
219 | struct mutex mutex; | |
220 | int in_request_module; | |
221 | ||
222 | int n_subdevices; | |
34c43922 | 223 | struct comedi_subdevice *subdevices; |
ed9eccbe DS |
224 | |
225 | /* dumb */ | |
226 | unsigned long iobase; | |
227 | unsigned int irq; | |
228 | ||
34c43922 BP |
229 | struct comedi_subdevice *read_subdev; |
230 | struct comedi_subdevice *write_subdev; | |
ed9eccbe DS |
231 | |
232 | struct fasync_struct *async_queue; | |
233 | ||
3c17ba07 | 234 | int (*open) (struct comedi_device *dev); |
62eeae93 | 235 | void (*close) (struct comedi_device *dev); |
ed9eccbe DS |
236 | }; |
237 | ||
37859f88 HS |
238 | static inline const void *comedi_board(struct comedi_device *dev) |
239 | { | |
240 | return dev->board_ptr; | |
241 | } | |
242 | ||
ed9eccbe | 243 | struct comedi_device_file_info { |
71b5f4f1 | 244 | struct comedi_device *device; |
34c43922 BP |
245 | struct comedi_subdevice *read_subdevice; |
246 | struct comedi_subdevice *write_subdevice; | |
c43435d7 | 247 | struct device *hardware_device; |
ed9eccbe DS |
248 | }; |
249 | ||
250 | #ifdef CONFIG_COMEDI_DEBUG | |
251 | extern int comedi_debug; | |
252 | #else | |
e0dcef71 | 253 | static const int comedi_debug; |
ed9eccbe DS |
254 | #endif |
255 | ||
256 | /* | |
257 | * function prototypes | |
258 | */ | |
259 | ||
34c43922 | 260 | void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s); |
71b5f4f1 | 261 | void comedi_error(const struct comedi_device *dev, const char *s); |
ed9eccbe DS |
262 | |
263 | /* we can expand the number of bits used to encode devices/subdevices into | |
264 | the minor number soon, after more distros support > 8 bit minor numbers | |
265 | (like after Debian Etch gets released) */ | |
266 | enum comedi_minor_bits { | |
267 | COMEDI_DEVICE_MINOR_MASK = 0xf, | |
268 | COMEDI_SUBDEVICE_MINOR_MASK = 0xf0 | |
269 | }; | |
270 | static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4; | |
271 | static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1; | |
272 | ||
e0dcef71 | 273 | struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor); |
ed9eccbe | 274 | |
62eeae93 SW |
275 | static inline struct comedi_subdevice *comedi_get_read_subdevice( |
276 | const struct comedi_device_file_info *info) | |
ed9eccbe | 277 | { |
e0dcef71 GKH |
278 | if (info->read_subdevice) |
279 | return info->read_subdevice; | |
280 | if (info->device == NULL) | |
281 | return NULL; | |
ed9eccbe DS |
282 | return info->device->read_subdev; |
283 | } | |
284 | ||
62eeae93 SW |
285 | static inline struct comedi_subdevice *comedi_get_write_subdevice( |
286 | const struct comedi_device_file_info *info) | |
ed9eccbe | 287 | { |
e0dcef71 GKH |
288 | if (info->write_subdevice) |
289 | return info->write_subdevice; | |
290 | if (info->device == NULL) | |
291 | return NULL; | |
ed9eccbe DS |
292 | return info->device->write_subdev; |
293 | } | |
294 | ||
8b9ba6e5 | 295 | int comedi_alloc_subdevices(struct comedi_device *, int); |
2f0b9d08 | 296 | |
71b5f4f1 | 297 | void comedi_device_detach(struct comedi_device *dev); |
0a85b6f0 MT |
298 | int comedi_device_attach(struct comedi_device *dev, |
299 | struct comedi_devconfig *it); | |
139dfbdf BP |
300 | int comedi_driver_register(struct comedi_driver *); |
301 | int comedi_driver_unregister(struct comedi_driver *); | |
ed9eccbe | 302 | |
20416257 HS |
303 | /** |
304 | * module_comedi_driver() - Helper macro for registering a comedi driver | |
305 | * @__comedi_driver: comedi_driver struct | |
306 | * | |
307 | * Helper macro for comedi drivers which do not do anything special in module | |
308 | * init/exit. This eliminates a lot of boilerplate. Each module may only use | |
309 | * this macro once, and calling it replaces module_init() and module_exit(). | |
310 | */ | |
311 | #define module_comedi_driver(__comedi_driver) \ | |
312 | module_driver(__comedi_driver, comedi_driver_register, \ | |
313 | comedi_driver_unregister) | |
314 | ||
55c03cff HS |
315 | int comedi_pci_enable(struct pci_dev *, const char *); |
316 | void comedi_pci_disable(struct pci_dev *); | |
d4899c6f HS |
317 | |
318 | int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *); | |
319 | void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *); | |
320 | ||
321 | /** | |
322 | * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver | |
323 | * @__comedi_driver: comedi_driver struct | |
324 | * @__pci_driver: pci_driver struct | |
325 | * | |
326 | * Helper macro for comedi PCI drivers which do not do anything special | |
327 | * in module init/exit. This eliminates a lot of boilerplate. Each | |
328 | * module may only use this macro once, and calling it replaces | |
329 | * module_init() and module_exit() | |
330 | */ | |
331 | #define module_comedi_pci_driver(__comedi_driver, __pci_driver) \ | |
332 | module_driver(__comedi_driver, comedi_pci_driver_register, \ | |
333 | comedi_pci_driver_unregister, &(__pci_driver)) | |
334 | ||
64255031 HS |
335 | struct usb_driver; |
336 | ||
337 | int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *); | |
338 | void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *); | |
339 | ||
340 | /** | |
341 | * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver | |
342 | * @__comedi_driver: comedi_driver struct | |
343 | * @__usb_driver: usb_driver struct | |
344 | * | |
345 | * Helper macro for comedi USB drivers which do not do anything special | |
346 | * in module init/exit. This eliminates a lot of boilerplate. Each | |
347 | * module may only use this macro once, and calling it replaces | |
348 | * module_init() and module_exit() | |
349 | */ | |
350 | #define module_comedi_usb_driver(__comedi_driver, __usb_driver) \ | |
351 | module_driver(__comedi_driver, comedi_usb_driver_register, \ | |
352 | comedi_usb_driver_unregister, &(__usb_driver)) | |
353 | ||
ed9eccbe DS |
354 | void init_polling(void); |
355 | void cleanup_polling(void); | |
71b5f4f1 BP |
356 | void start_polling(struct comedi_device *); |
357 | void stop_polling(struct comedi_device *); | |
ed9eccbe | 358 | |
ed9eccbe DS |
359 | #ifdef CONFIG_PROC_FS |
360 | void comedi_proc_init(void); | |
361 | void comedi_proc_cleanup(void); | |
362 | #else | |
363 | static inline void comedi_proc_init(void) | |
364 | { | |
365 | } | |
0a85b6f0 | 366 | |
ed9eccbe DS |
367 | static inline void comedi_proc_cleanup(void) |
368 | { | |
369 | } | |
370 | #endif | |
371 | ||
372 | /* subdevice runflags */ | |
373 | enum subdevice_runflags { | |
374 | SRF_USER = 0x00000001, | |
375 | SRF_RT = 0x00000002, | |
e0dcef71 GKH |
376 | /* indicates an COMEDI_CB_ERROR event has occurred since the last |
377 | * command was started */ | |
ed9eccbe DS |
378 | SRF_ERROR = 0x00000004, |
379 | SRF_RUNNING = 0x08000000 | |
380 | }; | |
381 | ||
5e220112 MR |
382 | int comedi_check_chanlist(struct comedi_subdevice *s, |
383 | int n, | |
384 | unsigned int *chanlist); | |
34c43922 | 385 | unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s); |
ed9eccbe DS |
386 | |
387 | /* range stuff */ | |
388 | ||
e0dcef71 GKH |
389 | #define RANGE(a, b) {(a)*1e6, (b)*1e6, 0} |
390 | #define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL} | |
391 | #define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA} | |
baf22b64 | 392 | #define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0} |
e0dcef71 GKH |
393 | #define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0} |
394 | #define UNI_RANGE(a) {0, (a)*1e6, 0} | |
ed9eccbe | 395 | |
9ced1de6 BP |
396 | extern const struct comedi_lrange range_bipolar10; |
397 | extern const struct comedi_lrange range_bipolar5; | |
398 | extern const struct comedi_lrange range_bipolar2_5; | |
399 | extern const struct comedi_lrange range_unipolar10; | |
400 | extern const struct comedi_lrange range_unipolar5; | |
401 | extern const struct comedi_lrange range_unknown; | |
ed9eccbe DS |
402 | |
403 | #define range_digital range_unipolar5 | |
404 | ||
405 | #if __GNUC__ >= 3 | |
406 | #define GCC_ZERO_LENGTH_ARRAY | |
407 | #else | |
408 | #define GCC_ZERO_LENGTH_ARRAY 0 | |
409 | #endif | |
410 | ||
9ced1de6 | 411 | struct comedi_lrange { |
ed9eccbe | 412 | int length; |
1f6325d6 | 413 | struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY]; |
ed9eccbe DS |
414 | }; |
415 | ||
416 | /* some silly little inline functions */ | |
417 | ||
34c43922 | 418 | static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) |
ed9eccbe DS |
419 | { |
420 | if (subd->subdev_flags & SDF_LSAMPL) | |
790c5541 | 421 | return sizeof(unsigned int); |
ed9eccbe | 422 | else |
790c5541 | 423 | return sizeof(short); |
ed9eccbe DS |
424 | } |
425 | ||
426 | /* must be used in attach to set dev->hw_dev if you wish to dma directly | |
427 | into comedi's buffer */ | |
0a85b6f0 MT |
428 | static inline void comedi_set_hw_dev(struct comedi_device *dev, |
429 | struct device *hw_dev) | |
ed9eccbe | 430 | { |
0a7717df IA |
431 | if (dev->hw_dev == hw_dev) |
432 | return; | |
e0dcef71 | 433 | if (dev->hw_dev) |
ed9eccbe | 434 | put_device(dev->hw_dev); |
ed9eccbe DS |
435 | dev->hw_dev = hw_dev; |
436 | if (dev->hw_dev) { | |
437 | dev->hw_dev = get_device(dev->hw_dev); | |
438 | BUG_ON(dev->hw_dev == NULL); | |
439 | } | |
440 | } | |
441 | ||
ddb01367 HS |
442 | static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) |
443 | { | |
444 | return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL; | |
445 | } | |
446 | ||
d163679c BP |
447 | int comedi_buf_put(struct comedi_async *async, short x); |
448 | int comedi_buf_get(struct comedi_async *async, short *x); | |
ed9eccbe | 449 | |
d163679c | 450 | unsigned int comedi_buf_write_n_available(struct comedi_async *async); |
0a85b6f0 MT |
451 | unsigned int comedi_buf_write_alloc(struct comedi_async *async, |
452 | unsigned int nbytes); | |
d163679c | 453 | unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async, |
0a85b6f0 | 454 | unsigned int nbytes); |
d163679c BP |
455 | unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes); |
456 | unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes); | |
457 | unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes); | |
458 | unsigned int comedi_buf_read_n_available(struct comedi_async *async); | |
459 | void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, | |
0a85b6f0 | 460 | const void *source, unsigned int num_bytes); |
d163679c | 461 | void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, |
0a85b6f0 | 462 | void *destination, unsigned int num_bytes); |
d163679c | 463 | static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async) |
ed9eccbe DS |
464 | { |
465 | return async->buf_write_alloc_count - async->buf_write_count; | |
466 | } | |
0a85b6f0 | 467 | |
d163679c | 468 | static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async) |
ed9eccbe DS |
469 | { |
470 | return async->buf_read_alloc_count - async->buf_read_count; | |
471 | } | |
472 | ||
ed9eccbe DS |
473 | static inline void *comedi_aux_data(int options[], int n) |
474 | { | |
475 | unsigned long address; | |
476 | unsigned long addressLow; | |
477 | int bit_shift; | |
478 | if (sizeof(int) >= sizeof(void *)) | |
479 | address = options[COMEDI_DEVCONF_AUX_DATA_LO]; | |
480 | else { | |
481 | address = options[COMEDI_DEVCONF_AUX_DATA_HI]; | |
482 | bit_shift = sizeof(int) * 8; | |
483 | address <<= bit_shift; | |
484 | addressLow = options[COMEDI_DEVCONF_AUX_DATA_LO]; | |
485 | addressLow &= (1UL << bit_shift) - 1; | |
486 | address |= addressLow; | |
487 | } | |
488 | if (n >= 1) | |
489 | address += options[COMEDI_DEVCONF_AUX_DATA0_LENGTH]; | |
490 | if (n >= 2) | |
491 | address += options[COMEDI_DEVCONF_AUX_DATA1_LENGTH]; | |
492 | if (n >= 3) | |
493 | address += options[COMEDI_DEVCONF_AUX_DATA2_LENGTH]; | |
494 | BUG_ON(n > 3); | |
495 | return (void *)address; | |
496 | } | |
497 | ||
0a85b6f0 MT |
498 | int comedi_alloc_subdevice_minor(struct comedi_device *dev, |
499 | struct comedi_subdevice *s); | |
34c43922 | 500 | void comedi_free_subdevice_minor(struct comedi_subdevice *s); |
4c093a6d IA |
501 | int comedi_pci_auto_config(struct pci_dev *pcidev, |
502 | struct comedi_driver *driver); | |
ed9eccbe | 503 | void comedi_pci_auto_unconfig(struct pci_dev *pcidev); |
d8b6ca08 | 504 | int comedi_usb_auto_config(struct usb_interface *intf, |
4c093a6d | 505 | struct comedi_driver *driver); |
d8b6ca08 | 506 | void comedi_usb_auto_unconfig(struct usb_interface *intf); |
ed9eccbe | 507 | |
ed9eccbe | 508 | #endif /* _COMEDIDEV_H */ |