David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 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. |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #ifndef _COMEDIDEV_H |
| 20 | #define _COMEDIDEV_H |
| 21 | |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 22 | #include <linux/dma-mapping.h> |
Ian Abbott | ab3cb2e | 2013-11-08 15:03:23 +0000 | [diff] [blame] | 23 | #include <linux/mutex.h> |
| 24 | #include <linux/spinlock_types.h> |
Ian Abbott | 2f3fdcd | 2013-11-08 15:03:24 +0000 | [diff] [blame] | 25 | #include <linux/rwsem.h> |
Ian Abbott | 5b13ed9 | 2013-11-08 15:03:32 +0000 | [diff] [blame] | 26 | #include <linux/kref.h> |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 27 | |
| 28 | #include "comedi.h" |
| 29 | |
Greg Kroah-Hartman | e0dcef7 | 2008-11-13 16:36:22 -0800 | [diff] [blame] | 30 | #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) |
Shane Warden | 62eeae9 | 2009-09-22 16:13:04 -0700 | [diff] [blame] | 31 | #define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \ |
| 32 | COMEDI_MINORVERSION, COMEDI_MICROVERSION) |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 33 | #define COMEDI_RELEASE VERSION |
| 34 | |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 35 | #define COMEDI_NUM_BOARD_MINORS 0x30 |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 36 | |
Bill Pemberton | 34c4392 | 2009-03-16 22:05:14 -0400 | [diff] [blame] | 37 | struct comedi_subdevice { |
Bill Pemberton | 71b5f4f | 2009-03-16 22:05:08 -0400 | [diff] [blame] | 38 | struct comedi_device *device; |
H Hartley Sweeten | 90a35c1 | 2012-12-19 17:27:02 -0700 | [diff] [blame] | 39 | int index; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 40 | int type; |
| 41 | int n_chan; |
Greg Kroah-Hartman | baf22b6 | 2010-04-30 15:26:54 -0700 | [diff] [blame] | 42 | int subdev_flags; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 43 | int len_chanlist; /* maximum length of channel/gain list */ |
| 44 | |
| 45 | void *private; |
| 46 | |
Bill Pemberton | d163679 | 2009-03-16 22:05:20 -0400 | [diff] [blame] | 47 | struct comedi_async *async; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 48 | |
| 49 | void *lock; |
| 50 | void *busy; |
| 51 | unsigned runflags; |
| 52 | spinlock_t spin_lock; |
| 53 | |
H Hartley Sweeten | d4a7dc8 | 2012-06-18 14:45:42 -0700 | [diff] [blame] | 54 | unsigned int io_bits; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 55 | |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 56 | unsigned int maxdata; /* if maxdata==0, use list */ |
| 57 | const unsigned int *maxdata_list; /* list is channel specific */ |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 58 | |
Bill Pemberton | 9ced1de | 2009-03-16 22:05:31 -0400 | [diff] [blame] | 59 | const struct comedi_lrange *range_table; |
| 60 | const struct comedi_lrange *const *range_table_list; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 61 | |
| 62 | unsigned int *chanlist; /* driver-owned chanlist (not used) */ |
| 63 | |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 64 | int (*insn_read)(struct comedi_device *, struct comedi_subdevice *, |
| 65 | struct comedi_insn *, unsigned int *); |
| 66 | int (*insn_write)(struct comedi_device *, struct comedi_subdevice *, |
Mithlesh Thukral | 0a85b6f | 2009-06-08 21:04:41 +0530 | [diff] [blame] | 67 | struct comedi_insn *, unsigned int *); |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 68 | int (*insn_bits)(struct comedi_device *, struct comedi_subdevice *, |
| 69 | struct comedi_insn *, unsigned int *); |
| 70 | int (*insn_config)(struct comedi_device *, struct comedi_subdevice *, |
Mithlesh Thukral | 0a85b6f | 2009-06-08 21:04:41 +0530 | [diff] [blame] | 71 | struct comedi_insn *, unsigned int *); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 72 | |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 73 | int (*do_cmd)(struct comedi_device *, struct comedi_subdevice *); |
| 74 | int (*do_cmdtest)(struct comedi_device *, struct comedi_subdevice *, |
| 75 | struct comedi_cmd *); |
| 76 | int (*poll)(struct comedi_device *, struct comedi_subdevice *); |
| 77 | int (*cancel)(struct comedi_device *, struct comedi_subdevice *); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 78 | |
| 79 | /* called when the buffer changes */ |
H Hartley Sweeten | d546b89 | 2014-07-21 11:48:32 -0700 | [diff] [blame] | 80 | int (*buf_change)(struct comedi_device *, struct comedi_subdevice *); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 81 | |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 82 | void (*munge)(struct comedi_device *dev, struct comedi_subdevice *s, |
| 83 | void *data, unsigned int num_bytes, |
| 84 | unsigned int start_chan_index); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 85 | enum dma_data_direction async_dma_dir; |
| 86 | |
| 87 | unsigned int state; |
| 88 | |
Bill Pemberton | 0bfbbe8 | 2009-03-16 22:05:36 -0400 | [diff] [blame] | 89 | struct device *class_dev; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 90 | int minor; |
H Hartley Sweeten | d276206 | 2014-08-25 16:03:54 -0700 | [diff] [blame] | 91 | |
| 92 | unsigned int *readback; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct comedi_buf_page { |
| 96 | void *virt_addr; |
| 97 | dma_addr_t dma_addr; |
| 98 | }; |
| 99 | |
Ian Abbott | af93da3 | 2013-11-08 15:03:43 +0000 | [diff] [blame] | 100 | struct comedi_buf_map { |
| 101 | struct device *dma_hw_dev; |
| 102 | struct comedi_buf_page *page_list; |
| 103 | unsigned int n_pages; |
| 104 | enum dma_data_direction dma_dir; |
| 105 | struct kref refcount; |
| 106 | }; |
| 107 | |
Ian Abbott | 55d128b | 2014-06-20 14:15:04 +0100 | [diff] [blame] | 108 | /** |
| 109 | * struct comedi_async - control data for asynchronous comedi commands |
| 110 | * @prealloc_buf: preallocated buffer |
| 111 | * @prealloc_bufsz: buffer size (in bytes) |
| 112 | * @buf_map: map of buffer pages |
| 113 | * @max_bufsize: maximum buffer size (in bytes) |
| 114 | * @buf_write_count: "write completed" count (in bytes, modulo 2**32) |
| 115 | * @buf_write_alloc_count: "allocated for writing" count (in bytes, |
| 116 | * modulo 2**32) |
| 117 | * @buf_read_count: "read completed" count (in bytes, modulo 2**32) |
| 118 | * @buf_read_alloc_count: "allocated for reading" count (in bytes, |
| 119 | * modulo 2**32) |
| 120 | * @buf_write_ptr: buffer position for writer |
| 121 | * @buf_read_ptr: buffer position for reader |
| 122 | * @cur_chan: current position in chanlist for scan (for those |
| 123 | * drivers that use it) |
H Hartley Sweeten | 1dacbe5 | 2014-11-05 10:20:52 -0700 | [diff] [blame] | 124 | * @scans_done: the number of scans completed (COMEDI_CB_EOS) |
Ian Abbott | 55d128b | 2014-06-20 14:15:04 +0100 | [diff] [blame] | 125 | * @scan_progress: amount received or sent for current scan (in bytes) |
| 126 | * @munge_chan: current position in chanlist for "munging" |
| 127 | * @munge_count: "munge" count (in bytes, modulo 2**32) |
| 128 | * @munge_ptr: buffer position for "munging" |
| 129 | * @events: bit-vector of events that have occurred |
| 130 | * @cmd: details of comedi command in progress |
| 131 | * @wait_head: task wait queue for file reader or writer |
| 132 | * @cb_mask: bit-vector of events that should wake waiting tasks |
| 133 | * @inttrig: software trigger function for command, or NULL |
| 134 | * |
| 135 | * Note about the ..._count and ..._ptr members: |
| 136 | * |
| 137 | * Think of the _Count values being integers of unlimited size, indexing |
| 138 | * into a buffer of infinite length (though only an advancing portion |
| 139 | * of the buffer of fixed length prealloc_bufsz is accessible at any time). |
| 140 | * Then: |
| 141 | * |
| 142 | * Buf_Read_Count <= Buf_Read_Alloc_Count <= Munge_Count <= |
| 143 | * Buf_Write_Count <= Buf_Write_Alloc_Count <= |
| 144 | * (Buf_Read_Count + prealloc_bufsz) |
| 145 | * |
| 146 | * (Those aren't the actual members, apart from prealloc_bufsz.) When |
| 147 | * the buffer is reset, those _Count values start at 0 and only increase |
| 148 | * in value, maintaining the above inequalities until the next time the |
| 149 | * buffer is reset. The buffer is divided into the following regions by |
| 150 | * the inequalities: |
| 151 | * |
| 152 | * [0, Buf_Read_Count): |
| 153 | * old region no longer accessible |
| 154 | * [Buf_Read_Count, Buf_Read_Alloc_Count): |
| 155 | * filled and munged region allocated for reading but not yet read |
| 156 | * [Buf_Read_Alloc_Count, Munge_Count): |
| 157 | * filled and munged region not yet allocated for reading |
| 158 | * [Munge_Count, Buf_Write_Count): |
| 159 | * filled region not yet munged |
| 160 | * [Buf_Write_Count, Buf_Write_Alloc_Count): |
| 161 | * unfilled region allocated for writing but not yet written |
| 162 | * [Buf_Write_Alloc_Count, Buf_Read_Count + prealloc_bufsz): |
| 163 | * unfilled region not yet allocated for writing |
| 164 | * [Buf_Read_Count + prealloc_bufsz, infinity): |
| 165 | * unfilled region not yet accessible |
| 166 | * |
| 167 | * Data needs to be written into the buffer before it can be read out, |
| 168 | * and may need to be converted (or "munged") between the two |
| 169 | * operations. Extra unfilled buffer space may need to allocated for |
| 170 | * writing (advancing Buf_Write_Alloc_Count) before new data is written. |
| 171 | * After writing new data, the newly filled space needs to be released |
| 172 | * (advancing Buf_Write_Count). This also results in the new data being |
| 173 | * "munged" (advancing Munge_Count). Before data is read out of the |
| 174 | * buffer, extra space may need to be allocated for reading (advancing |
| 175 | * Buf_Read_Alloc_Count). After the data has been read out, the space |
| 176 | * needs to be released (advancing Buf_Read_Count). |
| 177 | * |
| 178 | * The actual members, buf_read_count, buf_read_alloc_count, |
| 179 | * munge_count, buf_write_count, and buf_write_alloc_count take the |
| 180 | * value of the corresponding capitalized _Count values modulo 2^32 |
| 181 | * (UINT_MAX+1). Subtracting a "higher" _count value from a "lower" |
| 182 | * _count value gives the same answer as subtracting a "higher" _Count |
| 183 | * value from a lower _Count value because prealloc_bufsz < UINT_MAX+1. |
| 184 | * The modulo operation is done implicitly. |
| 185 | * |
| 186 | * The buf_read_ptr, munge_ptr, and buf_write_ptr members take the value |
| 187 | * of the corresponding capitalized _Count values modulo prealloc_bufsz. |
| 188 | * These correspond to byte indices in the physical buffer. The modulo |
| 189 | * operation is done by subtracting prealloc_bufsz when the value |
| 190 | * exceeds prealloc_bufsz (assuming prealloc_bufsz plus the increment is |
| 191 | * less than or equal to UINT_MAX). |
| 192 | */ |
Bill Pemberton | d163679 | 2009-03-16 22:05:20 -0400 | [diff] [blame] | 193 | struct comedi_async { |
Ian Abbott | 55d128b | 2014-06-20 14:15:04 +0100 | [diff] [blame] | 194 | void *prealloc_buf; |
| 195 | unsigned int prealloc_bufsz; |
| 196 | struct comedi_buf_map *buf_map; |
| 197 | unsigned int max_bufsize; |
Shane Warden | 62eeae9 | 2009-09-22 16:13:04 -0700 | [diff] [blame] | 198 | unsigned int buf_write_count; |
Shane Warden | 62eeae9 | 2009-09-22 16:13:04 -0700 | [diff] [blame] | 199 | unsigned int buf_write_alloc_count; |
Shane Warden | 62eeae9 | 2009-09-22 16:13:04 -0700 | [diff] [blame] | 200 | unsigned int buf_read_count; |
Shane Warden | 62eeae9 | 2009-09-22 16:13:04 -0700 | [diff] [blame] | 201 | unsigned int buf_read_alloc_count; |
Ian Abbott | 55d128b | 2014-06-20 14:15:04 +0100 | [diff] [blame] | 202 | unsigned int buf_write_ptr; |
| 203 | unsigned int buf_read_ptr; |
| 204 | unsigned int cur_chan; |
H Hartley Sweeten | 1dacbe5 | 2014-11-05 10:20:52 -0700 | [diff] [blame] | 205 | unsigned int scans_done; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 206 | unsigned int scan_progress; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 207 | unsigned int munge_chan; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 208 | unsigned int munge_count; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 209 | unsigned int munge_ptr; |
Ian Abbott | 55d128b | 2014-06-20 14:15:04 +0100 | [diff] [blame] | 210 | unsigned int events; |
Bill Pemberton | ea6d0d4 | 2009-03-16 22:05:47 -0400 | [diff] [blame] | 211 | struct comedi_cmd cmd; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 212 | wait_queue_head_t wait_head; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 213 | unsigned int cb_mask; |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 214 | int (*inttrig)(struct comedi_device *dev, struct comedi_subdevice *s, |
| 215 | unsigned int x); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 216 | }; |
| 217 | |
H Hartley Sweeten | bb856b6 | 2014-10-13 09:56:07 -0700 | [diff] [blame] | 218 | /** |
| 219 | * comedi_async callback "events" |
| 220 | * @COMEDI_CB_EOS: end-of-scan |
| 221 | * @COMEDI_CB_EOA: end-of-acquisition/output |
| 222 | * @COMEDI_CB_BLOCK: data has arrived, wakes up read() / write() |
| 223 | * @COMEDI_CB_EOBUF: DEPRECATED: end of buffer |
| 224 | * @COMEDI_CB_ERROR: card error during acquisition |
| 225 | * @COMEDI_CB_OVERFLOW: buffer overflow/underflow |
H Hartley Sweeten | 781f933 | 2014-10-13 09:56:08 -0700 | [diff] [blame] | 226 | * |
| 227 | * @COMEDI_CB_ERROR_MASK: events that indicate an error has occurred |
| 228 | * @COMEDI_CB_CANCEL_MASK: events that will cancel an async command |
H Hartley Sweeten | bb856b6 | 2014-10-13 09:56:07 -0700 | [diff] [blame] | 229 | */ |
| 230 | #define COMEDI_CB_EOS (1 << 0) |
| 231 | #define COMEDI_CB_EOA (1 << 1) |
| 232 | #define COMEDI_CB_BLOCK (1 << 2) |
| 233 | #define COMEDI_CB_EOBUF (1 << 3) |
| 234 | #define COMEDI_CB_ERROR (1 << 4) |
| 235 | #define COMEDI_CB_OVERFLOW (1 << 5) |
| 236 | |
H Hartley Sweeten | 781f933 | 2014-10-13 09:56:08 -0700 | [diff] [blame] | 237 | #define COMEDI_CB_ERROR_MASK (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW) |
| 238 | #define COMEDI_CB_CANCEL_MASK (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK) |
| 239 | |
Bill Pemberton | 139dfbd | 2009-03-16 22:05:25 -0400 | [diff] [blame] | 240 | struct comedi_driver { |
| 241 | struct comedi_driver *next; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 242 | |
| 243 | const char *driver_name; |
| 244 | struct module *module; |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 245 | int (*attach)(struct comedi_device *, struct comedi_devconfig *); |
| 246 | void (*detach)(struct comedi_device *); |
| 247 | int (*auto_attach)(struct comedi_device *, unsigned long); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 248 | |
| 249 | /* number of elements in board_name and board_id arrays */ |
| 250 | unsigned int num_names; |
| 251 | const char *const *board_name; |
| 252 | /* offset in bytes from one board name pointer to the next */ |
| 253 | int offset; |
| 254 | }; |
| 255 | |
Bill Pemberton | 71b5f4f | 2009-03-16 22:05:08 -0400 | [diff] [blame] | 256 | struct comedi_device { |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 257 | int use_count; |
Bill Pemberton | 139dfbd | 2009-03-16 22:05:25 -0400 | [diff] [blame] | 258 | struct comedi_driver *driver; |
H Hartley Sweeten | 43db062 | 2015-02-23 14:57:29 -0700 | [diff] [blame] | 259 | struct comedi_8254 *pacer; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 260 | void *private; |
| 261 | |
Bill Pemberton | 0bfbbe8 | 2009-03-16 22:05:36 -0400 | [diff] [blame] | 262 | struct device *class_dev; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 263 | int minor; |
Ian Abbott | ef77c0b | 2013-11-08 15:03:29 +0000 | [diff] [blame] | 264 | unsigned int detach_count; |
Greg Kroah-Hartman | e0dcef7 | 2008-11-13 16:36:22 -0800 | [diff] [blame] | 265 | /* hw_dev is passed to dma_alloc_coherent when allocating async buffers |
| 266 | * for subdevices that have async_dma_dir set to something other than |
| 267 | * DMA_NONE */ |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 268 | struct device *hw_dev; |
| 269 | |
| 270 | const char *board_name; |
| 271 | const void *board_ptr; |
Ian Abbott | a7401cd | 2013-03-15 13:15:33 +0000 | [diff] [blame] | 272 | bool attached:1; |
Ian Abbott | 00ca6884 | 2013-03-15 13:15:35 +0000 | [diff] [blame] | 273 | bool ioenabled:1; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 274 | spinlock_t spinlock; |
| 275 | struct mutex mutex; |
Ian Abbott | 2f3fdcd | 2013-11-08 15:03:24 +0000 | [diff] [blame] | 276 | struct rw_semaphore attach_lock; |
Ian Abbott | 5b13ed9 | 2013-11-08 15:03:32 +0000 | [diff] [blame] | 277 | struct kref refcount; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 278 | |
| 279 | int n_subdevices; |
Bill Pemberton | 34c4392 | 2009-03-16 22:05:14 -0400 | [diff] [blame] | 280 | struct comedi_subdevice *subdevices; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 281 | |
| 282 | /* dumb */ |
H Hartley Sweeten | d7e6dc1 | 2014-07-29 15:01:20 -0700 | [diff] [blame] | 283 | void __iomem *mmio; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 284 | unsigned long iobase; |
H Hartley Sweeten | 316f97f | 2013-04-18 14:31:29 -0700 | [diff] [blame] | 285 | unsigned long iolen; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 286 | unsigned int irq; |
| 287 | |
Bill Pemberton | 34c4392 | 2009-03-16 22:05:14 -0400 | [diff] [blame] | 288 | struct comedi_subdevice *read_subdev; |
| 289 | struct comedi_subdevice *write_subdev; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 290 | |
| 291 | struct fasync_struct *async_queue; |
| 292 | |
Monam Agarwal | 0cb4c151 | 2014-02-25 14:51:26 +0530 | [diff] [blame] | 293 | int (*open)(struct comedi_device *dev); |
| 294 | void (*close)(struct comedi_device *dev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 295 | }; |
| 296 | |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 297 | /* |
| 298 | * function prototypes |
| 299 | */ |
| 300 | |
Bill Pemberton | 34c4392 | 2009-03-16 22:05:14 -0400 | [diff] [blame] | 301 | void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 302 | |
Ian Abbott | b449c1c | 2013-11-08 15:03:33 +0000 | [diff] [blame] | 303 | struct comedi_device *comedi_dev_get_from_minor(unsigned minor); |
| 304 | int comedi_dev_put(struct comedi_device *dev); |
H Hartley Sweeten | 85104e9 | 2012-12-19 15:34:40 -0700 | [diff] [blame] | 305 | |
H Hartley Sweeten | 84bb0bc | 2015-01-20 12:06:00 -0700 | [diff] [blame] | 306 | /** |
| 307 | * comedi_subdevice "runflags" |
| 308 | * @COMEDI_SRF_RT: DEPRECATED: command is running real-time |
| 309 | * @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred |
| 310 | * since the last command was started |
| 311 | * @COMEDI_SRF_RUNNING: command is running |
| 312 | * @COMEDI_SRF_FREE_SPRIV: free s->private on detach |
| 313 | * |
| 314 | * @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy" |
| 315 | */ |
| 316 | #define COMEDI_SRF_RT BIT(1) |
| 317 | #define COMEDI_SRF_ERROR BIT(2) |
| 318 | #define COMEDI_SRF_RUNNING BIT(27) |
| 319 | #define COMEDI_SRF_FREE_SPRIV BIT(31) |
| 320 | |
| 321 | #define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING) |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 322 | |
H Hartley Sweeten | e0dac31 | 2012-12-19 15:42:47 -0700 | [diff] [blame] | 323 | bool comedi_is_subdevice_running(struct comedi_subdevice *s); |
H Hartley Sweeten | 0480bcb | 2013-06-19 15:24:36 -0700 | [diff] [blame] | 324 | |
| 325 | void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size); |
Ian Abbott | 8fc369a | 2015-04-21 13:18:10 +0100 | [diff] [blame^] | 326 | void comedi_set_spriv_auto_free(struct comedi_subdevice *s); |
H Hartley Sweeten | e0dac31 | 2012-12-19 15:42:47 -0700 | [diff] [blame] | 327 | |
Mark Rankilor | 5e22011 | 2010-05-06 17:49:37 +0800 | [diff] [blame] | 328 | int comedi_check_chanlist(struct comedi_subdevice *s, |
| 329 | int n, |
| 330 | unsigned int *chanlist); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 331 | |
| 332 | /* range stuff */ |
| 333 | |
Greg Kroah-Hartman | e0dcef7 | 2008-11-13 16:36:22 -0800 | [diff] [blame] | 334 | #define RANGE(a, b) {(a)*1e6, (b)*1e6, 0} |
| 335 | #define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL} |
| 336 | #define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA} |
Greg Kroah-Hartman | baf22b6 | 2010-04-30 15:26:54 -0700 | [diff] [blame] | 337 | #define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0} |
Greg Kroah-Hartman | e0dcef7 | 2008-11-13 16:36:22 -0800 | [diff] [blame] | 338 | #define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0} |
| 339 | #define UNI_RANGE(a) {0, (a)*1e6, 0} |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 340 | |
Bill Pemberton | 9ced1de | 2009-03-16 22:05:31 -0400 | [diff] [blame] | 341 | extern const struct comedi_lrange range_bipolar10; |
| 342 | extern const struct comedi_lrange range_bipolar5; |
| 343 | extern const struct comedi_lrange range_bipolar2_5; |
| 344 | extern const struct comedi_lrange range_unipolar10; |
| 345 | extern const struct comedi_lrange range_unipolar5; |
H Hartley Sweeten | 5f8eb72 | 2013-04-03 13:38:26 -0700 | [diff] [blame] | 346 | extern const struct comedi_lrange range_unipolar2_5; |
H Hartley Sweeten | 2c71c4f | 2013-04-03 13:40:13 -0700 | [diff] [blame] | 347 | extern const struct comedi_lrange range_0_20mA; |
| 348 | extern const struct comedi_lrange range_4_20mA; |
| 349 | extern const struct comedi_lrange range_0_32mA; |
Bill Pemberton | 9ced1de | 2009-03-16 22:05:31 -0400 | [diff] [blame] | 350 | extern const struct comedi_lrange range_unknown; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 351 | |
| 352 | #define range_digital range_unipolar5 |
| 353 | |
| 354 | #if __GNUC__ >= 3 |
| 355 | #define GCC_ZERO_LENGTH_ARRAY |
| 356 | #else |
| 357 | #define GCC_ZERO_LENGTH_ARRAY 0 |
| 358 | #endif |
| 359 | |
Bill Pemberton | 9ced1de | 2009-03-16 22:05:31 -0400 | [diff] [blame] | 360 | struct comedi_lrange { |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 361 | int length; |
Bill Pemberton | 1f6325d | 2009-03-16 22:06:31 -0400 | [diff] [blame] | 362 | struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY]; |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 363 | }; |
| 364 | |
H Hartley Sweeten | e3693fd | 2013-06-05 15:52:31 -0700 | [diff] [blame] | 365 | static inline bool comedi_range_is_bipolar(struct comedi_subdevice *s, |
| 366 | unsigned int range) |
| 367 | { |
| 368 | return s->range_table->range[range].min < 0; |
| 369 | } |
| 370 | |
| 371 | static inline bool comedi_range_is_unipolar(struct comedi_subdevice *s, |
| 372 | unsigned int range) |
| 373 | { |
| 374 | return s->range_table->range[range].min >= 0; |
| 375 | } |
| 376 | |
H Hartley Sweeten | a8b677c | 2014-07-14 12:23:39 -0700 | [diff] [blame] | 377 | static inline bool comedi_range_is_external(struct comedi_subdevice *s, |
| 378 | unsigned int range) |
| 379 | { |
| 380 | return !!(s->range_table->range[range].flags & RF_EXTERNAL); |
| 381 | } |
| 382 | |
H Hartley Sweeten | 4916211 | 2013-09-25 15:35:06 -0700 | [diff] [blame] | 383 | static inline bool comedi_chan_range_is_bipolar(struct comedi_subdevice *s, |
| 384 | unsigned int chan, |
| 385 | unsigned int range) |
| 386 | { |
| 387 | return s->range_table_list[chan]->range[range].min < 0; |
| 388 | } |
| 389 | |
| 390 | static inline bool comedi_chan_range_is_unipolar(struct comedi_subdevice *s, |
| 391 | unsigned int chan, |
| 392 | unsigned int range) |
| 393 | { |
| 394 | return s->range_table_list[chan]->range[range].min >= 0; |
| 395 | } |
| 396 | |
H Hartley Sweeten | a8b677c | 2014-07-14 12:23:39 -0700 | [diff] [blame] | 397 | static inline bool comedi_chan_range_is_external(struct comedi_subdevice *s, |
| 398 | unsigned int chan, |
| 399 | unsigned int range) |
| 400 | { |
| 401 | return !!(s->range_table_list[chan]->range[range].flags & RF_EXTERNAL); |
| 402 | } |
| 403 | |
H Hartley Sweeten | f0b215d | 2013-09-18 11:49:33 -0700 | [diff] [blame] | 404 | /* munge between offset binary and two's complement values */ |
| 405 | static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s, |
| 406 | unsigned int val) |
| 407 | { |
| 408 | return val ^ s->maxdata ^ (s->maxdata >> 1); |
| 409 | } |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 410 | |
Ian Abbott | bf33eb4 | 2014-10-23 13:47:51 +0100 | [diff] [blame] | 411 | /** |
| 412 | * comedi_bytes_per_sample - determine subdevice sample size |
| 413 | * @s: comedi_subdevice struct |
| 414 | * |
| 415 | * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on |
| 416 | * whether the SDF_LSAMPL subdevice flag is set or not. |
| 417 | * |
| 418 | * Returns the subdevice sample size. |
| 419 | */ |
| 420 | static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s) |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 421 | { |
Ian Abbott | bf33eb4 | 2014-10-23 13:47:51 +0100 | [diff] [blame] | 422 | return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short); |
| 423 | } |
Kinka Huang | cb3aada | 2014-07-15 23:11:02 +0800 | [diff] [blame] | 424 | |
Ian Abbott | bf33eb4 | 2014-10-23 13:47:51 +0100 | [diff] [blame] | 425 | /** |
| 426 | * comedi_sample_shift - determine log2 of subdevice sample size |
| 427 | * @s: comedi_subdevice struct |
| 428 | * |
| 429 | * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on |
| 430 | * whether the SDF_LSAMPL subdevice flag is set or not. The log2 of the |
| 431 | * sample size will be 2 or 1 and can be used as the right operand of a |
| 432 | * bit-shift operator to multiply or divide something by the sample size. |
| 433 | * |
| 434 | * Returns log2 of the subdevice sample size. |
| 435 | */ |
| 436 | static inline unsigned int comedi_sample_shift(struct comedi_subdevice *s) |
| 437 | { |
| 438 | return s->subdev_flags & SDF_LSAMPL ? 2 : 1; |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * comedi_bytes_to_samples - converts a number of bytes to a number of samples |
| 443 | * @s: comedi_subdevice struct |
| 444 | * @nbytes: number of bytes |
| 445 | * |
| 446 | * Returns the number of bytes divided by the subdevice sample size. |
| 447 | */ |
| 448 | static inline unsigned int comedi_bytes_to_samples(struct comedi_subdevice *s, |
| 449 | unsigned int nbytes) |
| 450 | { |
| 451 | return nbytes >> comedi_sample_shift(s); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * comedi_samples_to_bytes - converts a number of samples to a number of bytes |
| 456 | * @s: comedi_subdevice struct |
| 457 | * @nsamples: number of samples |
| 458 | * |
| 459 | * Returns the number of samples multiplied by the subdevice sample size. |
| 460 | * Does not check for arithmetic overflow. |
| 461 | */ |
| 462 | static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s, |
| 463 | unsigned int nsamples) |
| 464 | { |
| 465 | return nsamples << comedi_sample_shift(s); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 466 | } |
| 467 | |
Ian Abbott | 5e1a619 | 2015-03-27 19:13:41 +0000 | [diff] [blame] | 468 | /** |
| 469 | * comedi_check_trigger_src() - trivially validate a comedi_cmd trigger source |
| 470 | * @src: pointer to the trigger source to validate |
| 471 | * @flags: bitmask of valid TRIG_* for the trigger |
| 472 | * |
| 473 | * This is used in "step 1" of the do_cmdtest functions of comedi drivers |
| 474 | * to vaildate the comedi_cmd triggers. The mask of the @src against the |
| 475 | * @flags allows the userspace comedilib to pass all the comedi_cmd |
| 476 | * triggers as TRIG_ANY and get back a bitmask of the valid trigger sources. |
| 477 | */ |
| 478 | static inline int comedi_check_trigger_src(unsigned int *src, |
| 479 | unsigned int flags) |
| 480 | { |
| 481 | unsigned int orig_src = *src; |
| 482 | |
| 483 | *src = orig_src & flags; |
| 484 | if (*src == TRIG_INVALID || *src != orig_src) |
| 485 | return -EINVAL; |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * comedi_check_trigger_is_unique() - make sure a trigger source is unique |
| 491 | * @src: the trigger source to check |
| 492 | */ |
| 493 | static inline int comedi_check_trigger_is_unique(unsigned int src) |
| 494 | { |
| 495 | /* this test is true if more than one _src bit is set */ |
| 496 | if ((src & (src - 1)) != 0) |
| 497 | return -EINVAL; |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * comedi_check_trigger_arg_is() - trivially validate a trigger argument |
| 503 | * @arg: pointer to the trigger arg to validate |
| 504 | * @val: the value the argument should be |
| 505 | */ |
| 506 | static inline int comedi_check_trigger_arg_is(unsigned int *arg, |
| 507 | unsigned int val) |
| 508 | { |
| 509 | if (*arg != val) { |
| 510 | *arg = val; |
| 511 | return -EINVAL; |
| 512 | } |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * comedi_check_trigger_arg_min() - trivially validate a trigger argument |
| 518 | * @arg: pointer to the trigger arg to validate |
| 519 | * @val: the minimum value the argument should be |
| 520 | */ |
| 521 | static inline int comedi_check_trigger_arg_min(unsigned int *arg, |
| 522 | unsigned int val) |
| 523 | { |
| 524 | if (*arg < val) { |
| 525 | *arg = val; |
| 526 | return -EINVAL; |
| 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * comedi_check_trigger_arg_max() - trivially validate a trigger argument |
| 533 | * @arg: pointer to the trigger arg to validate |
| 534 | * @val: the maximum value the argument should be |
| 535 | */ |
| 536 | static inline int comedi_check_trigger_arg_max(unsigned int *arg, |
| 537 | unsigned int val) |
| 538 | { |
| 539 | if (*arg > val) { |
| 540 | *arg = val; |
| 541 | return -EINVAL; |
| 542 | } |
| 543 | return 0; |
| 544 | } |
| 545 | |
Ian Abbott | bc3954b | 2013-01-29 16:20:17 +0000 | [diff] [blame] | 546 | /* |
| 547 | * Must set dev->hw_dev if you wish to dma directly into comedi's buffer. |
| 548 | * Also useful for retrieving a previously configured hardware device of |
| 549 | * known bus type. Set automatically for auto-configured devices. |
| 550 | * Automatically set to NULL when detaching hardware device. |
| 551 | */ |
Ian Abbott | da71751 | 2013-02-01 13:23:19 +0000 | [diff] [blame] | 552 | int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 553 | |
H Hartley Sweeten | f4f3f7c | 2014-06-20 10:58:28 -0700 | [diff] [blame] | 554 | static inline unsigned int comedi_buf_n_bytes_ready(struct comedi_subdevice *s) |
| 555 | { |
| 556 | return s->async->buf_write_count - s->async->buf_read_count; |
| 557 | } |
| 558 | |
Ian Abbott | 24e894b | 2014-05-06 13:12:04 +0100 | [diff] [blame] | 559 | unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); |
Ian Abbott | 940dd35 | 2014-05-06 13:12:05 +0100 | [diff] [blame] | 560 | unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 561 | |
Ian Abbott | e9edef3 | 2014-05-06 13:12:09 +0100 | [diff] [blame] | 562 | unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s); |
Ian Abbott | d13be55 | 2014-05-06 13:12:07 +0100 | [diff] [blame] | 563 | unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); |
Ian Abbott | f1df866 | 2014-05-06 13:12:08 +0100 | [diff] [blame] | 564 | unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); |
H Hartley Sweeten | 8ae560a | 2013-01-09 13:32:56 -0700 | [diff] [blame] | 565 | |
H Hartley Sweeten | 5438da8 | 2014-10-22 15:36:24 -0700 | [diff] [blame] | 566 | unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, |
| 567 | const void *data, unsigned int nsamples); |
H Hartley Sweeten | 4455d7c | 2014-10-22 14:36:34 -0700 | [diff] [blame] | 568 | unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, |
| 569 | void *data, unsigned int nsamples); |
Mithlesh Thukral | 0a85b6f | 2009-06-08 21:04:41 +0530 | [diff] [blame] | 570 | |
H Hartley Sweeten | 1ae6b20 | 2013-01-30 15:24:38 -0700 | [diff] [blame] | 571 | /* drivers.c - general comedi driver functions */ |
| 572 | |
H Hartley Sweeten | 9150640 | 2014-02-10 11:49:00 -0700 | [diff] [blame] | 573 | #define COMEDI_TIMEOUT_MS 1000 |
| 574 | |
| 575 | int comedi_timeout(struct comedi_device *, struct comedi_subdevice *, |
| 576 | struct comedi_insn *, |
| 577 | int (*cb)(struct comedi_device *, struct comedi_subdevice *, |
| 578 | struct comedi_insn *, unsigned long context), |
| 579 | unsigned long context); |
| 580 | |
Ian Abbott | 5a78035 | 2014-09-15 13:46:01 +0100 | [diff] [blame] | 581 | unsigned int comedi_handle_events(struct comedi_device *dev, |
| 582 | struct comedi_subdevice *s); |
| 583 | |
H Hartley Sweeten | e523c6c | 2013-08-06 09:31:35 -0700 | [diff] [blame] | 584 | int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, |
| 585 | struct comedi_insn *, unsigned int *data, |
| 586 | unsigned int mask); |
H Hartley Sweeten | 05e60b1 | 2013-08-30 11:04:56 -0700 | [diff] [blame] | 587 | unsigned int comedi_dio_update_state(struct comedi_subdevice *, |
| 588 | unsigned int *data); |
Ian Abbott | f146fe6 | 2014-09-15 13:45:57 +0100 | [diff] [blame] | 589 | unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s); |
H Hartley Sweeten | 2ee3775 | 2014-11-05 10:31:29 -0700 | [diff] [blame] | 590 | unsigned int comedi_nscans_left(struct comedi_subdevice *s, |
| 591 | unsigned int nscans); |
H Hartley Sweeten | f615915 | 2014-11-05 10:31:33 -0700 | [diff] [blame] | 592 | unsigned int comedi_nsamples_left(struct comedi_subdevice *s, |
| 593 | unsigned int nsamples); |
Ian Abbott | 2b4e1f6 | 2014-09-15 13:45:59 +0100 | [diff] [blame] | 594 | void comedi_inc_scan_progress(struct comedi_subdevice *s, |
| 595 | unsigned int num_bytes); |
H Hartley Sweeten | e523c6c | 2013-08-06 09:31:35 -0700 | [diff] [blame] | 596 | |
H Hartley Sweeten | 54db996 | 2013-06-24 16:55:14 -0700 | [diff] [blame] | 597 | void *comedi_alloc_devpriv(struct comedi_device *, size_t); |
H Hartley Sweeten | 1ae6b20 | 2013-01-30 15:24:38 -0700 | [diff] [blame] | 598 | int comedi_alloc_subdevices(struct comedi_device *, int); |
H Hartley Sweeten | d276206 | 2014-08-25 16:03:54 -0700 | [diff] [blame] | 599 | int comedi_alloc_subdev_readback(struct comedi_subdevice *); |
| 600 | |
| 601 | int comedi_readback_insn_read(struct comedi_device *, struct comedi_subdevice *, |
| 602 | struct comedi_insn *, unsigned int *data); |
H Hartley Sweeten | 1ae6b20 | 2013-01-30 15:24:38 -0700 | [diff] [blame] | 603 | |
H Hartley Sweeten | 9ff8b15 | 2013-05-17 11:17:00 -0700 | [diff] [blame] | 604 | int comedi_load_firmware(struct comedi_device *, struct device *, |
| 605 | const char *name, |
| 606 | int (*cb)(struct comedi_device *, |
H Hartley Sweeten | d569541 | 2013-05-17 11:18:01 -0700 | [diff] [blame] | 607 | const u8 *data, size_t size, |
| 608 | unsigned long context), |
| 609 | unsigned long context); |
H Hartley Sweeten | 9ff8b15 | 2013-05-17 11:17:00 -0700 | [diff] [blame] | 610 | |
H Hartley Sweeten | ca8b296 | 2013-04-09 16:30:11 -0700 | [diff] [blame] | 611 | int __comedi_request_region(struct comedi_device *, |
| 612 | unsigned long start, unsigned long len); |
H Hartley Sweeten | f375ac5 | 2013-04-09 16:05:54 -0700 | [diff] [blame] | 613 | int comedi_request_region(struct comedi_device *, |
| 614 | unsigned long start, unsigned long len); |
H Hartley Sweeten | 316f97f | 2013-04-18 14:31:29 -0700 | [diff] [blame] | 615 | void comedi_legacy_detach(struct comedi_device *); |
H Hartley Sweeten | f375ac5 | 2013-04-09 16:05:54 -0700 | [diff] [blame] | 616 | |
H Hartley Sweeten | 1ae6b20 | 2013-01-30 15:24:38 -0700 | [diff] [blame] | 617 | int comedi_auto_config(struct device *, struct comedi_driver *, |
| 618 | unsigned long context); |
| 619 | void comedi_auto_unconfig(struct device *); |
| 620 | |
| 621 | int comedi_driver_register(struct comedi_driver *); |
Ian Abbott | 99c0e26 | 2013-06-27 14:50:57 +0100 | [diff] [blame] | 622 | void comedi_driver_unregister(struct comedi_driver *); |
H Hartley Sweeten | 1ae6b20 | 2013-01-30 15:24:38 -0700 | [diff] [blame] | 623 | |
| 624 | /** |
| 625 | * module_comedi_driver() - Helper macro for registering a comedi driver |
| 626 | * @__comedi_driver: comedi_driver struct |
| 627 | * |
| 628 | * Helper macro for comedi drivers which do not do anything special in module |
| 629 | * init/exit. This eliminates a lot of boilerplate. Each module may only use |
| 630 | * this macro once, and calling it replaces module_init() and module_exit(). |
| 631 | */ |
| 632 | #define module_comedi_driver(__comedi_driver) \ |
| 633 | module_driver(__comedi_driver, comedi_driver_register, \ |
| 634 | comedi_driver_unregister) |
Ian Abbott | 581a7dd | 2012-11-14 13:10:40 +0000 | [diff] [blame] | 635 | |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 636 | #endif /* _COMEDIDEV_H */ |