comedidev.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. /*
  2. * 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. #ifndef _COMEDIDEV_H
  19. #define _COMEDIDEV_H
  20. #include <linux/dma-mapping.h>
  21. #include <linux/mutex.h>
  22. #include <linux/spinlock_types.h>
  23. #include <linux/rwsem.h>
  24. #include <linux/kref.h>
  25. #include "comedi.h"
  26. #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
  27. #define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \
  28. COMEDI_MINORVERSION, COMEDI_MICROVERSION)
  29. #define COMEDI_RELEASE VERSION
  30. #define COMEDI_NUM_BOARD_MINORS 0x30
  31. /**
  32. * struct comedi_subdevice - Working data for a COMEDI subdevice
  33. * @device: COMEDI device to which this subdevice belongs. (Initialized by
  34. * comedi_alloc_subdevices().)
  35. * @index: Index of this subdevice within device's array of subdevices.
  36. * (Initialized by comedi_alloc_subdevices().)
  37. * @type: Type of subdevice from &enum comedi_subdevice_type. (Initialized by
  38. * the low-level driver.)
  39. * @n_chan: Number of channels the subdevice supports. (Initialized by the
  40. * low-level driver.)
  41. * @subdev_flags: Various "SDF" flags indicating aspects of the subdevice to
  42. * the COMEDI core and user application. (Initialized by the low-level
  43. * driver.)
  44. * @len_chanlist: Maximum length of a channel list if the subdevice supports
  45. * asynchronous acquisition commands. (Optionally initialized by the
  46. * low-level driver, or changed from 0 to 1 during post-configuration.)
  47. * @private: Private data pointer which is either set by the low-level driver
  48. * itself, or by a call to comedi_alloc_spriv() which allocates storage.
  49. * In the latter case, the storage is automatically freed after the
  50. * low-level driver's "detach" handler is called for the device.
  51. * (Initialized by the low-level driver.)
  52. * @async: Pointer to &struct comedi_async id the subdevice supports
  53. * asynchronous acquisition commands. (Allocated and initialized during
  54. * post-configuration if needed.)
  55. * @lock: Pointer to a file object that performed a %COMEDI_LOCK ioctl on the
  56. * subdevice. (Initially NULL.)
  57. * @busy: Pointer to a file object that is performing an asynchronous
  58. * acquisition command on the subdevice. (Initially NULL.)
  59. * @runflags: Internal flags for use by COMEDI core, mostly indicating whether
  60. * an asynchronous acquisition command is running.
  61. * @spin_lock: Generic spin-lock for use by the COMEDI core and the low-level
  62. * driver. (Initialized by comedi_alloc_subdevices().)
  63. * @io_bits: Bit-mask indicating the channel directions for a DIO subdevice
  64. * with no more than 32 channels. A '1' at a bit position indicates the
  65. * corresponding channel is configured as an output. (Initialized by the
  66. * low-level driver for a DIO subdevice. Forced to all-outputs during
  67. * post-configuration for a digital output subdevice.)
  68. * @maxdata: If non-zero, this is the maximum raw data value of each channel.
  69. * If zero, the maximum data value is channel-specific. (Initialized by
  70. * the low-level driver.)
  71. * @maxdata_list: If the maximum data value is channel-specific, this points
  72. * to an array of maximum data values indexed by channel index.
  73. * (Initialized by the low-level driver.)
  74. * @range_table: If non-NULL, this points to a COMEDI range table for the
  75. * subdevice. If NULL, the range table is channel-specific. (Initialized
  76. * by the low-level driver, will be set to an "invalid" range table during
  77. * post-configuration if @range_table and @range_table_list are both
  78. * NULL.)
  79. * @range_table_list: If the COMEDI range table is channel-specific, this
  80. * points to an array of pointers to COMEDI range tables indexed by
  81. * channel number. (Initialized by the low-level driver.)
  82. * @chanlist: Not used.
  83. * @insn_read: Optional pointer to a handler for the %INSN_READ instruction.
  84. * (Initialized by the low-level driver, or set to a default handler
  85. * during post-configuration.)
  86. * @insn_write: Optional pointer to a handler for the %INSN_WRITE instruction.
  87. * (Initialized by the low-level driver, or set to a default handler
  88. * during post-configuration.)
  89. * @insn_bits: Optional pointer to a handler for the %INSN_BITS instruction
  90. * for a digital input, digital output or digital input/output subdevice.
  91. * (Initialized by the low-level driver, or set to a default handler
  92. * during post-configuration.)
  93. * @insn_config: Optional pointer to a handler for the %INSN_CONFIG
  94. * instruction. (Initialized by the low-level driver, or set to a default
  95. * handler during post-configuration.)
  96. * @do_cmd: If the subdevice supports asynchronous acquisition commands, this
  97. * points to a handler to set it up in hardware. (Initialized by the
  98. * low-level driver.)
  99. * @do_cmdtest: If the subdevice supports asynchronous acquisition commands,
  100. * this points to a handler used to check and possibly tweak a prospective
  101. * acquisition command without setting it up in hardware. (Initialized by
  102. * the low-level driver.)
  103. * @poll: If the subdevice supports asynchronous acquisition commands, this
  104. * is an optional pointer to a handler for the %COMEDI_POLL ioctl which
  105. * instructs the low-level driver to synchronize buffers. (Initialized by
  106. * the low-level driver if needed.)
  107. * @cancel: If the subdevice supports asynchronous acquisition commands, this
  108. * points to a handler used to terminate a running command. (Initialized
  109. * by the low-level driver.)
  110. * @buf_change: If the subdevice supports asynchronous acquisition commands,
  111. * this is an optional pointer to a handler that is called when the data
  112. * buffer for handling asynchronous commands is allocated or reallocated.
  113. * (Initialized by the low-level driver if needed.)
  114. * @munge: If the subdevice supports asynchronous acquisition commands and
  115. * uses DMA to transfer data from the hardware to the acquisition buffer,
  116. * this points to a function used to "munge" the data values from the
  117. * hardware into the format expected by COMEDI. (Initialized by the
  118. * low-level driver if needed.)
  119. * @async_dma_dir: If the subdevice supports asynchronous acquisition commands
  120. * and uses DMA to transfer data from the hardware to the acquisition
  121. * buffer, this sets the DMA direction for the buffer. (initialized to
  122. * %DMA_NONE by comedi_alloc_subdevices() and changed by the low-level
  123. * driver if necessary.)
  124. * @state: Handy bit-mask indicating the output states for a DIO or digital
  125. * output subdevice with no more than 32 channels. (Initialized by the
  126. * low-level driver.)
  127. * @class_dev: If the subdevice supports asynchronous acquisition commands,
  128. * this points to a sysfs comediX_subdY device where X is the minor device
  129. * number of the COMEDI device and Y is the subdevice number. The minor
  130. * device number for the sysfs device is allocated dynamically in the
  131. * range 48 to 255. This is used to allow the COMEDI device to be opened
  132. * with a different default read or write subdevice. (Allocated during
  133. * post-configuration if needed.)
  134. * @minor: If @class_dev is set, this is its dynamically allocated minor
  135. * device number. (Set during post-configuration if necessary.)
  136. * @readback: Optional pointer to memory allocated by
  137. * comedi_alloc_subdev_readback() used to hold the values written to
  138. * analog output channels so they can be read back. The storage is
  139. * automatically freed after the low-level driver's "detach" handler is
  140. * called for the device. (Initialized by the low-level driver.)
  141. *
  142. * This is the main control structure for a COMEDI subdevice. If the subdevice
  143. * supports asynchronous acquisition commands, additional information is stored
  144. * in the &struct comedi_async pointed to by @async.
  145. *
  146. * Most of the subdevice is initialized by the low-level driver's "attach" or
  147. * "auto_attach" handlers but parts of it are initialized by
  148. * comedi_alloc_subdevices(), and other parts are initialized during
  149. * post-configuration on return from that handler.
  150. *
  151. * A low-level driver that sets @insn_bits for a digital input, digital output,
  152. * or DIO subdevice may leave @insn_read and @insn_write uninitialized, in
  153. * which case they will be set to a default handler during post-configuration
  154. * that uses @insn_bits to emulate the %INSN_READ and %INSN_WRITE instructions.
  155. */
  156. struct comedi_subdevice {
  157. struct comedi_device *device;
  158. int index;
  159. int type;
  160. int n_chan;
  161. int subdev_flags;
  162. int len_chanlist; /* maximum length of channel/gain list */
  163. void *private;
  164. struct comedi_async *async;
  165. void *lock;
  166. void *busy;
  167. unsigned int runflags;
  168. spinlock_t spin_lock; /* generic spin-lock for COMEDI and drivers */
  169. unsigned int io_bits;
  170. unsigned int maxdata; /* if maxdata==0, use list */
  171. const unsigned int *maxdata_list; /* list is channel specific */
  172. const struct comedi_lrange *range_table;
  173. const struct comedi_lrange *const *range_table_list;
  174. unsigned int *chanlist; /* driver-owned chanlist (not used) */
  175. int (*insn_read)(struct comedi_device *, struct comedi_subdevice *,
  176. struct comedi_insn *, unsigned int *);
  177. int (*insn_write)(struct comedi_device *, struct comedi_subdevice *,
  178. struct comedi_insn *, unsigned int *);
  179. int (*insn_bits)(struct comedi_device *, struct comedi_subdevice *,
  180. struct comedi_insn *, unsigned int *);
  181. int (*insn_config)(struct comedi_device *, struct comedi_subdevice *,
  182. struct comedi_insn *, unsigned int *);
  183. int (*do_cmd)(struct comedi_device *, struct comedi_subdevice *);
  184. int (*do_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
  185. struct comedi_cmd *);
  186. int (*poll)(struct comedi_device *, struct comedi_subdevice *);
  187. int (*cancel)(struct comedi_device *, struct comedi_subdevice *);
  188. /* called when the buffer changes */
  189. int (*buf_change)(struct comedi_device *, struct comedi_subdevice *);
  190. void (*munge)(struct comedi_device *dev, struct comedi_subdevice *s,
  191. void *data, unsigned int num_bytes,
  192. unsigned int start_chan_index);
  193. enum dma_data_direction async_dma_dir;
  194. unsigned int state;
  195. struct device *class_dev;
  196. int minor;
  197. unsigned int *readback;
  198. };
  199. /**
  200. * struct comedi_buf_page - Describe a page of a COMEDI buffer
  201. * @virt_addr: Kernel address of page.
  202. * @dma_addr: DMA address of page if in DMA coherent memory.
  203. */
  204. struct comedi_buf_page {
  205. void *virt_addr;
  206. dma_addr_t dma_addr;
  207. };
  208. /**
  209. * struct comedi_buf_map - Describe pages in a COMEDI buffer
  210. * @dma_hw_dev: Low-level hardware &struct device pointer copied from the
  211. * COMEDI device's hw_dev member.
  212. * @page_list: Pointer to array of &struct comedi_buf_page, one for each
  213. * page in the buffer.
  214. * @n_pages: Number of pages in the buffer.
  215. * @dma_dir: DMA direction used to allocate pages of DMA coherent memory,
  216. * or %DMA_NONE if pages allocated from regular memory.
  217. * @refcount: &struct kref reference counter used to free the buffer.
  218. *
  219. * A COMEDI data buffer is allocated as individual pages, either in
  220. * conventional memory or DMA coherent memory, depending on the attached,
  221. * low-level hardware device. (The buffer pages also get mapped into the
  222. * kernel's contiguous virtual address space pointed to by the 'prealloc_buf'
  223. * member of &struct comedi_async.)
  224. *
  225. * The buffer is normally freed when the COMEDI device is detached from the
  226. * low-level driver (which may happen due to device removal), but if it happens
  227. * to be mmapped at the time, the pages cannot be freed until the buffer has
  228. * been munmapped. That is what the reference counter is for. (The virtual
  229. * address space pointed by 'prealloc_buf' is freed when the COMEDI device is
  230. * detached.)
  231. */
  232. struct comedi_buf_map {
  233. struct device *dma_hw_dev;
  234. struct comedi_buf_page *page_list;
  235. unsigned int n_pages;
  236. enum dma_data_direction dma_dir;
  237. struct kref refcount;
  238. };
  239. /**
  240. * struct comedi_async - Control data for asynchronous COMEDI commands
  241. * @prealloc_buf: Kernel virtual address of allocated acquisition buffer.
  242. * @prealloc_bufsz: Buffer size (in bytes).
  243. * @buf_map: Map of buffer pages.
  244. * @max_bufsize: Maximum allowed buffer size (in bytes).
  245. * @buf_write_count: "Write completed" count (in bytes, modulo 2**32).
  246. * @buf_write_alloc_count: "Allocated for writing" count (in bytes,
  247. * modulo 2**32).
  248. * @buf_read_count: "Read completed" count (in bytes, modulo 2**32).
  249. * @buf_read_alloc_count: "Allocated for reading" count (in bytes,
  250. * modulo 2**32).
  251. * @buf_write_ptr: Buffer position for writer.
  252. * @buf_read_ptr: Buffer position for reader.
  253. * @cur_chan: Current position in chanlist for scan (for those drivers that
  254. * use it).
  255. * @scans_done: The number of scans completed.
  256. * @scan_progress: Amount received or sent for current scan (in bytes).
  257. * @munge_chan: Current position in chanlist for "munging".
  258. * @munge_count: "Munge" count (in bytes, modulo 2**32).
  259. * @munge_ptr: Buffer position for "munging".
  260. * @events: Bit-vector of events that have occurred.
  261. * @cmd: Details of comedi command in progress.
  262. * @wait_head: Task wait queue for file reader or writer.
  263. * @cb_mask: Bit-vector of events that should wake waiting tasks.
  264. * @inttrig: Software trigger function for command, or NULL.
  265. *
  266. * Note about the ..._count and ..._ptr members:
  267. *
  268. * Think of the _Count values being integers of unlimited size, indexing
  269. * into a buffer of infinite length (though only an advancing portion
  270. * of the buffer of fixed length prealloc_bufsz is accessible at any
  271. * time). Then:
  272. *
  273. * Buf_Read_Count <= Buf_Read_Alloc_Count <= Munge_Count <=
  274. * Buf_Write_Count <= Buf_Write_Alloc_Count <=
  275. * (Buf_Read_Count + prealloc_bufsz)
  276. *
  277. * (Those aren't the actual members, apart from prealloc_bufsz.) When the
  278. * buffer is reset, those _Count values start at 0 and only increase in value,
  279. * maintaining the above inequalities until the next time the buffer is
  280. * reset. The buffer is divided into the following regions by the inequalities:
  281. *
  282. * [0, Buf_Read_Count):
  283. * old region no longer accessible
  284. *
  285. * [Buf_Read_Count, Buf_Read_Alloc_Count):
  286. * filled and munged region allocated for reading but not yet read
  287. *
  288. * [Buf_Read_Alloc_Count, Munge_Count):
  289. * filled and munged region not yet allocated for reading
  290. *
  291. * [Munge_Count, Buf_Write_Count):
  292. * filled region not yet munged
  293. *
  294. * [Buf_Write_Count, Buf_Write_Alloc_Count):
  295. * unfilled region allocated for writing but not yet written
  296. *
  297. * [Buf_Write_Alloc_Count, Buf_Read_Count + prealloc_bufsz):
  298. * unfilled region not yet allocated for writing
  299. *
  300. * [Buf_Read_Count + prealloc_bufsz, infinity):
  301. * unfilled region not yet accessible
  302. *
  303. * Data needs to be written into the buffer before it can be read out,
  304. * and may need to be converted (or "munged") between the two
  305. * operations. Extra unfilled buffer space may need to allocated for
  306. * writing (advancing Buf_Write_Alloc_Count) before new data is written.
  307. * After writing new data, the newly filled space needs to be released
  308. * (advancing Buf_Write_Count). This also results in the new data being
  309. * "munged" (advancing Munge_Count). Before data is read out of the
  310. * buffer, extra space may need to be allocated for reading (advancing
  311. * Buf_Read_Alloc_Count). After the data has been read out, the space
  312. * needs to be released (advancing Buf_Read_Count).
  313. *
  314. * The actual members, buf_read_count, buf_read_alloc_count,
  315. * munge_count, buf_write_count, and buf_write_alloc_count take the
  316. * value of the corresponding capitalized _Count values modulo 2^32
  317. * (UINT_MAX+1). Subtracting a "higher" _count value from a "lower"
  318. * _count value gives the same answer as subtracting a "higher" _Count
  319. * value from a lower _Count value because prealloc_bufsz < UINT_MAX+1.
  320. * The modulo operation is done implicitly.
  321. *
  322. * The buf_read_ptr, munge_ptr, and buf_write_ptr members take the value
  323. * of the corresponding capitalized _Count values modulo prealloc_bufsz.
  324. * These correspond to byte indices in the physical buffer. The modulo
  325. * operation is done by subtracting prealloc_bufsz when the value
  326. * exceeds prealloc_bufsz (assuming prealloc_bufsz plus the increment is
  327. * less than or equal to UINT_MAX).
  328. */
  329. struct comedi_async {
  330. void *prealloc_buf;
  331. unsigned int prealloc_bufsz;
  332. struct comedi_buf_map *buf_map;
  333. unsigned int max_bufsize;
  334. unsigned int buf_write_count;
  335. unsigned int buf_write_alloc_count;
  336. unsigned int buf_read_count;
  337. unsigned int buf_read_alloc_count;
  338. unsigned int buf_write_ptr;
  339. unsigned int buf_read_ptr;
  340. unsigned int cur_chan;
  341. unsigned int scans_done;
  342. unsigned int scan_progress;
  343. unsigned int munge_chan;
  344. unsigned int munge_count;
  345. unsigned int munge_ptr;
  346. unsigned int events;
  347. struct comedi_cmd cmd;
  348. wait_queue_head_t wait_head;
  349. unsigned int cb_mask;
  350. int (*inttrig)(struct comedi_device *dev, struct comedi_subdevice *s,
  351. unsigned int x);
  352. };
  353. /**
  354. * enum comedi_cb - &struct comedi_async callback "events"
  355. * @COMEDI_CB_EOS: end-of-scan
  356. * @COMEDI_CB_EOA: end-of-acquisition/output
  357. * @COMEDI_CB_BLOCK: data has arrived, wakes up read() / write()
  358. * @COMEDI_CB_EOBUF: DEPRECATED: end of buffer
  359. * @COMEDI_CB_ERROR: card error during acquisition
  360. * @COMEDI_CB_OVERFLOW: buffer overflow/underflow
  361. * @COMEDI_CB_ERROR_MASK: events that indicate an error has occurred
  362. * @COMEDI_CB_CANCEL_MASK: events that will cancel an async command
  363. */
  364. enum comedi_cb {
  365. COMEDI_CB_EOS = BIT(0),
  366. COMEDI_CB_EOA = BIT(1),
  367. COMEDI_CB_BLOCK = BIT(2),
  368. COMEDI_CB_EOBUF = BIT(3),
  369. COMEDI_CB_ERROR = BIT(4),
  370. COMEDI_CB_OVERFLOW = BIT(5),
  371. /* masks */
  372. COMEDI_CB_ERROR_MASK = (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW),
  373. COMEDI_CB_CANCEL_MASK = (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK)
  374. };
  375. /**
  376. * struct comedi_driver - COMEDI driver registration
  377. * @driver_name: Name of driver.
  378. * @module: Owning module.
  379. * @attach: The optional "attach" handler for manually configured COMEDI
  380. * devices.
  381. * @detach: The "detach" handler for deconfiguring COMEDI devices.
  382. * @auto_attach: The optional "auto_attach" handler for automatically
  383. * configured COMEDI devices.
  384. * @num_names: Optional number of "board names" supported.
  385. * @board_name: Optional pointer to a pointer to a board name. The pointer
  386. * to a board name is embedded in an element of a driver-defined array
  387. * of static, read-only board type information.
  388. * @offset: Optional size of each element of the driver-defined array of
  389. * static, read-only board type information, i.e. the offset between each
  390. * pointer to a board name.
  391. *
  392. * This is used with comedi_driver_register() and comedi_driver_unregister() to
  393. * register and unregister a low-level COMEDI driver with the COMEDI core.
  394. *
  395. * If @num_names is non-zero, @board_name should be non-NULL, and @offset
  396. * should be at least sizeof(*board_name). These are used by the handler for
  397. * the %COMEDI_DEVCONFIG ioctl to match a hardware device and its driver by
  398. * board name. If @num_names is zero, the %COMEDI_DEVCONFIG ioctl matches a
  399. * hardware device and its driver by driver name. This is only useful if the
  400. * @attach handler is set. If @num_names is non-zero, the driver's @attach
  401. * handler will be called with the COMEDI device structure's board_ptr member
  402. * pointing to the matched pointer to a board name within the driver's private
  403. * array of static, read-only board type information.
  404. *
  405. * The @detach handler has two roles. If a COMEDI device was successfully
  406. * configured by the @attach or @auto_attach handler, it is called when the
  407. * device is being deconfigured (by the %COMEDI_DEVCONFIG ioctl, or due to
  408. * unloading of the driver, or due to device removal). It is also called when
  409. * the @attach or @auto_attach handler returns an error. Therefore, the
  410. * @attach or @auto_attach handlers can defer clean-up on error until the
  411. * @detach handler is called. If the @attach or @auto_attach handlers free
  412. * any resources themselves, they must prevent the @detach handler from
  413. * freeing the same resources. The @detach handler must not assume that all
  414. * resources requested by the @attach or @auto_attach handler were
  415. * successfully allocated.
  416. */
  417. struct comedi_driver {
  418. /* private: */
  419. struct comedi_driver *next; /* Next in list of COMEDI drivers. */
  420. /* public: */
  421. const char *driver_name;
  422. struct module *module;
  423. int (*attach)(struct comedi_device *, struct comedi_devconfig *);
  424. void (*detach)(struct comedi_device *);
  425. int (*auto_attach)(struct comedi_device *, unsigned long);
  426. unsigned int num_names;
  427. const char *const *board_name;
  428. int offset;
  429. };
  430. /**
  431. * struct comedi_device - Working data for a COMEDI device
  432. * @use_count: Number of open file objects.
  433. * @driver: Low-level COMEDI driver attached to this COMEDI device.
  434. * @pacer: Optional pointer to a dynamically allocated acquisition pacer
  435. * control. It is freed automatically after the COMEDI device is
  436. * detached from the low-level driver.
  437. * @private: Optional pointer to private data allocated by the low-level
  438. * driver. It is freed automatically after the COMEDI device is
  439. * detached from the low-level driver.
  440. * @class_dev: Sysfs comediX device.
  441. * @minor: Minor device number of COMEDI char device (0-47).
  442. * @detach_count: Counter incremented every time the COMEDI device is detached.
  443. * Used for checking a previous attachment is still valid.
  444. * @hw_dev: Optional pointer to the low-level hardware &struct device. It is
  445. * required for automatically configured COMEDI devices and optional for
  446. * COMEDI devices configured by the %COMEDI_DEVCONFIG ioctl, although
  447. * the bus-specific COMEDI functions only work if it is set correctly.
  448. * It is also passed to dma_alloc_coherent() for COMEDI subdevices that
  449. * have their 'async_dma_dir' member set to something other than
  450. * %DMA_NONE.
  451. * @board_name: Pointer to a COMEDI board name or a COMEDI driver name. When
  452. * the low-level driver's "attach" handler is called by the handler for
  453. * the %COMEDI_DEVCONFIG ioctl, it either points to a matched board name
  454. * string if the 'num_names' member of the &struct comedi_driver is
  455. * non-zero, otherwise it points to the low-level driver name string.
  456. * When the low-lever driver's "auto_attach" handler is called for an
  457. * automatically configured COMEDI device, it points to the low-level
  458. * driver name string. The low-level driver is free to change it in its
  459. * "attach" or "auto_attach" handler if it wishes.
  460. * @board_ptr: Optional pointer to private, read-only board type information in
  461. * the low-level driver. If the 'num_names' member of the &struct
  462. * comedi_driver is non-zero, the handler for the %COMEDI_DEVCONFIG ioctl
  463. * will point it to a pointer to a matched board name string within the
  464. * driver's private array of static, read-only board type information when
  465. * calling the driver's "attach" handler. The low-level driver is free to
  466. * change it.
  467. * @attached: Flag indicating that the COMEDI device is attached to a low-level
  468. * driver.
  469. * @ioenabled: Flag used to indicate that a PCI device has been enabled and
  470. * its regions requested.
  471. * @spinlock: Generic spin-lock for use by the low-level driver.
  472. * @mutex: Generic mutex for use by the COMEDI core module.
  473. * @attach_lock: &struct rw_semaphore used to guard against the COMEDI device
  474. * being detached while an operation is in progress. The down_write()
  475. * operation is only allowed while @mutex is held and is used when
  476. * changing @attached and @detach_count and calling the low-level driver's
  477. * "detach" handler. The down_read() operation is generally used without
  478. * holding @mutex.
  479. * @refcount: &struct kref reference counter for freeing COMEDI device.
  480. * @n_subdevices: Number of COMEDI subdevices allocated by the low-level
  481. * driver for this device.
  482. * @subdevices: Dynamically allocated array of COMEDI subdevices.
  483. * @mmio: Optional pointer to a remapped MMIO region set by the low-level
  484. * driver.
  485. * @iobase: Optional base of an I/O port region requested by the low-level
  486. * driver.
  487. * @iolen: Length of I/O port region requested at @iobase.
  488. * @irq: Optional IRQ number requested by the low-level driver.
  489. * @read_subdev: Optional pointer to a default COMEDI subdevice operated on by
  490. * the read() file operation. Set by the low-level driver.
  491. * @write_subdev: Optional pointer to a default COMEDI subdevice operated on by
  492. * the write() file operation. Set by the low-level driver.
  493. * @async_queue: Storage for fasync_helper().
  494. * @open: Optional pointer to a function set by the low-level driver to be
  495. * called when @use_count changes from 0 to 1.
  496. * @close: Optional pointer to a function set by the low-level driver to be
  497. * called when @use_count changed from 1 to 0.
  498. *
  499. * This is the main control data structure for a COMEDI device (as far as the
  500. * COMEDI core is concerned). There are two groups of COMEDI devices -
  501. * "legacy" devices that are configured by the handler for the
  502. * %COMEDI_DEVCONFIG ioctl, and automatically configured devices resulting
  503. * from a call to comedi_auto_config() as a result of a bus driver probe in
  504. * a low-level COMEDI driver. The "legacy" COMEDI devices are allocated
  505. * during module initialization if the "comedi_num_legacy_minors" module
  506. * parameter is non-zero and use minor device numbers from 0 to
  507. * comedi_num_legacy_minors minus one. The automatically configured COMEDI
  508. * devices are allocated on demand and use minor device numbers from
  509. * comedi_num_legacy_minors to 47.
  510. */
  511. struct comedi_device {
  512. int use_count;
  513. struct comedi_driver *driver;
  514. struct comedi_8254 *pacer;
  515. void *private;
  516. struct device *class_dev;
  517. int minor;
  518. unsigned int detach_count;
  519. struct device *hw_dev;
  520. const char *board_name;
  521. const void *board_ptr;
  522. bool attached:1;
  523. bool ioenabled:1;
  524. spinlock_t spinlock; /* generic spin-lock for low-level driver */
  525. struct mutex mutex; /* generic mutex for COMEDI core */
  526. struct rw_semaphore attach_lock;
  527. struct kref refcount;
  528. int n_subdevices;
  529. struct comedi_subdevice *subdevices;
  530. /* dumb */
  531. void __iomem *mmio;
  532. unsigned long iobase;
  533. unsigned long iolen;
  534. unsigned int irq;
  535. struct comedi_subdevice *read_subdev;
  536. struct comedi_subdevice *write_subdev;
  537. struct fasync_struct *async_queue;
  538. int (*open)(struct comedi_device *dev);
  539. void (*close)(struct comedi_device *dev);
  540. };
  541. /*
  542. * function prototypes
  543. */
  544. void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
  545. struct comedi_device *comedi_dev_get_from_minor(unsigned int minor);
  546. int comedi_dev_put(struct comedi_device *dev);
  547. bool comedi_is_subdevice_running(struct comedi_subdevice *s);
  548. void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size);
  549. void comedi_set_spriv_auto_free(struct comedi_subdevice *s);
  550. int comedi_check_chanlist(struct comedi_subdevice *s,
  551. int n,
  552. unsigned int *chanlist);
  553. /* range stuff */
  554. #define RANGE(a, b) {(a) * 1e6, (b) * 1e6, 0}
  555. #define RANGE_ext(a, b) {(a) * 1e6, (b) * 1e6, RF_EXTERNAL}
  556. #define RANGE_mA(a, b) {(a) * 1e6, (b) * 1e6, UNIT_mA}
  557. #define RANGE_unitless(a, b) {(a) * 1e6, (b) * 1e6, 0}
  558. #define BIP_RANGE(a) {-(a) * 1e6, (a) * 1e6, 0}
  559. #define UNI_RANGE(a) {0, (a) * 1e6, 0}
  560. extern const struct comedi_lrange range_bipolar10;
  561. extern const struct comedi_lrange range_bipolar5;
  562. extern const struct comedi_lrange range_bipolar2_5;
  563. extern const struct comedi_lrange range_unipolar10;
  564. extern const struct comedi_lrange range_unipolar5;
  565. extern const struct comedi_lrange range_unipolar2_5;
  566. extern const struct comedi_lrange range_0_20mA;
  567. extern const struct comedi_lrange range_4_20mA;
  568. extern const struct comedi_lrange range_0_32mA;
  569. extern const struct comedi_lrange range_unknown;
  570. #define range_digital range_unipolar5
  571. #if __GNUC__ >= 3
  572. #define GCC_ZERO_LENGTH_ARRAY
  573. #else
  574. #define GCC_ZERO_LENGTH_ARRAY 0
  575. #endif
  576. /**
  577. * struct comedi_lrange - Describes a COMEDI range table
  578. * @length: Number of entries in the range table.
  579. * @range: Array of &struct comedi_krange, one for each range.
  580. *
  581. * Each element of @range[] describes the minimum and maximum physical range
  582. * range and the type of units. Typically, the type of unit is %UNIT_volt
  583. * (i.e. volts) and the minimum and maximum are in millionths of a volt.
  584. * There may also be a flag that indicates the minimum and maximum are merely
  585. * scale factors for an unknown, external reference.
  586. */
  587. struct comedi_lrange {
  588. int length;
  589. struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY];
  590. };
  591. /**
  592. * comedi_range_is_bipolar() - Test if subdevice range is bipolar
  593. * @s: COMEDI subdevice.
  594. * @range: Index of range within a range table.
  595. *
  596. * Tests whether a range is bipolar by checking whether its minimum value
  597. * is negative.
  598. *
  599. * Assumes @range is valid. Does not work for subdevices using a
  600. * channel-specific range table list.
  601. *
  602. * Return:
  603. * %true if the range is bipolar.
  604. * %false if the range is unipolar.
  605. */
  606. static inline bool comedi_range_is_bipolar(struct comedi_subdevice *s,
  607. unsigned int range)
  608. {
  609. return s->range_table->range[range].min < 0;
  610. }
  611. /**
  612. * comedi_range_is_unipolar() - Test if subdevice range is unipolar
  613. * @s: COMEDI subdevice.
  614. * @range: Index of range within a range table.
  615. *
  616. * Tests whether a range is unipolar by checking whether its minimum value
  617. * is at least 0.
  618. *
  619. * Assumes @range is valid. Does not work for subdevices using a
  620. * channel-specific range table list.
  621. *
  622. * Return:
  623. * %true if the range is unipolar.
  624. * %false if the range is bipolar.
  625. */
  626. static inline bool comedi_range_is_unipolar(struct comedi_subdevice *s,
  627. unsigned int range)
  628. {
  629. return s->range_table->range[range].min >= 0;
  630. }
  631. /**
  632. * comedi_range_is_external() - Test if subdevice range is external
  633. * @s: COMEDI subdevice.
  634. * @range: Index of range within a range table.
  635. *
  636. * Tests whether a range is externally reference by checking whether its
  637. * %RF_EXTERNAL flag is set.
  638. *
  639. * Assumes @range is valid. Does not work for subdevices using a
  640. * channel-specific range table list.
  641. *
  642. * Return:
  643. * %true if the range is external.
  644. * %false if the range is internal.
  645. */
  646. static inline bool comedi_range_is_external(struct comedi_subdevice *s,
  647. unsigned int range)
  648. {
  649. return !!(s->range_table->range[range].flags & RF_EXTERNAL);
  650. }
  651. /**
  652. * comedi_chan_range_is_bipolar() - Test if channel-specific range is bipolar
  653. * @s: COMEDI subdevice.
  654. * @chan: The channel number.
  655. * @range: Index of range within a range table.
  656. *
  657. * Tests whether a range is bipolar by checking whether its minimum value
  658. * is negative.
  659. *
  660. * Assumes @chan and @range are valid. Only works for subdevices with a
  661. * channel-specific range table list.
  662. *
  663. * Return:
  664. * %true if the range is bipolar.
  665. * %false if the range is unipolar.
  666. */
  667. static inline bool comedi_chan_range_is_bipolar(struct comedi_subdevice *s,
  668. unsigned int chan,
  669. unsigned int range)
  670. {
  671. return s->range_table_list[chan]->range[range].min < 0;
  672. }
  673. /**
  674. * comedi_chan_range_is_unipolar() - Test if channel-specific range is unipolar
  675. * @s: COMEDI subdevice.
  676. * @chan: The channel number.
  677. * @range: Index of range within a range table.
  678. *
  679. * Tests whether a range is unipolar by checking whether its minimum value
  680. * is at least 0.
  681. *
  682. * Assumes @chan and @range are valid. Only works for subdevices with a
  683. * channel-specific range table list.
  684. *
  685. * Return:
  686. * %true if the range is unipolar.
  687. * %false if the range is bipolar.
  688. */
  689. static inline bool comedi_chan_range_is_unipolar(struct comedi_subdevice *s,
  690. unsigned int chan,
  691. unsigned int range)
  692. {
  693. return s->range_table_list[chan]->range[range].min >= 0;
  694. }
  695. /**
  696. * comedi_chan_range_is_external() - Test if channel-specific range is external
  697. * @s: COMEDI subdevice.
  698. * @chan: The channel number.
  699. * @range: Index of range within a range table.
  700. *
  701. * Tests whether a range is externally reference by checking whether its
  702. * %RF_EXTERNAL flag is set.
  703. *
  704. * Assumes @chan and @range are valid. Only works for subdevices with a
  705. * channel-specific range table list.
  706. *
  707. * Return:
  708. * %true if the range is bipolar.
  709. * %false if the range is unipolar.
  710. */
  711. static inline bool comedi_chan_range_is_external(struct comedi_subdevice *s,
  712. unsigned int chan,
  713. unsigned int range)
  714. {
  715. return !!(s->range_table_list[chan]->range[range].flags & RF_EXTERNAL);
  716. }
  717. /**
  718. * comedi_offset_munge() - Convert between offset binary and 2's complement
  719. * @s: COMEDI subdevice.
  720. * @val: Value to be converted.
  721. *
  722. * Toggles the highest bit of a sample value to toggle between offset binary
  723. * and 2's complement. Assumes that @s->maxdata is a power of 2 minus 1.
  724. *
  725. * Return: The converted value.
  726. */
  727. static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
  728. unsigned int val)
  729. {
  730. return val ^ s->maxdata ^ (s->maxdata >> 1);
  731. }
  732. /**
  733. * comedi_bytes_per_sample() - Determine subdevice sample size
  734. * @s: COMEDI subdevice.
  735. *
  736. * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on
  737. * whether the %SDF_LSAMPL subdevice flag is set or not.
  738. *
  739. * Return: The subdevice sample size.
  740. */
  741. static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s)
  742. {
  743. return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short);
  744. }
  745. /**
  746. * comedi_sample_shift() - Determine log2 of subdevice sample size
  747. * @s: COMEDI subdevice.
  748. *
  749. * The sample size will be 4 (sizeof int) or 2 (sizeof short) depending on
  750. * whether the %SDF_LSAMPL subdevice flag is set or not. The log2 of the
  751. * sample size will be 2 or 1 and can be used as the right operand of a
  752. * bit-shift operator to multiply or divide something by the sample size.
  753. *
  754. * Return: log2 of the subdevice sample size.
  755. */
  756. static inline unsigned int comedi_sample_shift(struct comedi_subdevice *s)
  757. {
  758. return s->subdev_flags & SDF_LSAMPL ? 2 : 1;
  759. }
  760. /**
  761. * comedi_bytes_to_samples() - Convert a number of bytes to a number of samples
  762. * @s: COMEDI subdevice.
  763. * @nbytes: Number of bytes
  764. *
  765. * Return: The number of bytes divided by the subdevice sample size.
  766. */
  767. static inline unsigned int comedi_bytes_to_samples(struct comedi_subdevice *s,
  768. unsigned int nbytes)
  769. {
  770. return nbytes >> comedi_sample_shift(s);
  771. }
  772. /**
  773. * comedi_samples_to_bytes() - Convert a number of samples to a number of bytes
  774. * @s: COMEDI subdevice.
  775. * @nsamples: Number of samples.
  776. *
  777. * Return: The number of samples multiplied by the subdevice sample size.
  778. * (Does not check for arithmetic overflow.)
  779. */
  780. static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s,
  781. unsigned int nsamples)
  782. {
  783. return nsamples << comedi_sample_shift(s);
  784. }
  785. /**
  786. * comedi_check_trigger_src() - Trivially validate a comedi_cmd trigger source
  787. * @src: Pointer to the trigger source to validate.
  788. * @flags: Bitmask of valid %TRIG_* for the trigger.
  789. *
  790. * This is used in "step 1" of the do_cmdtest functions of comedi drivers
  791. * to validate the comedi_cmd triggers. The mask of the @src against the
  792. * @flags allows the userspace comedilib to pass all the comedi_cmd
  793. * triggers as %TRIG_ANY and get back a bitmask of the valid trigger sources.
  794. *
  795. * Return:
  796. * 0 if trigger sources in *@src are all supported.
  797. * -EINVAL if any trigger source in *@src is unsupported.
  798. */
  799. static inline int comedi_check_trigger_src(unsigned int *src,
  800. unsigned int flags)
  801. {
  802. unsigned int orig_src = *src;
  803. *src = orig_src & flags;
  804. if (*src == TRIG_INVALID || *src != orig_src)
  805. return -EINVAL;
  806. return 0;
  807. }
  808. /**
  809. * comedi_check_trigger_is_unique() - Make sure a trigger source is unique
  810. * @src: The trigger source to check.
  811. *
  812. * Return:
  813. * 0 if no more than one trigger source is set.
  814. * -EINVAL if more than one trigger source is set.
  815. */
  816. static inline int comedi_check_trigger_is_unique(unsigned int src)
  817. {
  818. /* this test is true if more than one _src bit is set */
  819. if ((src & (src - 1)) != 0)
  820. return -EINVAL;
  821. return 0;
  822. }
  823. /**
  824. * comedi_check_trigger_arg_is() - Trivially validate a trigger argument
  825. * @arg: Pointer to the trigger arg to validate.
  826. * @val: The value the argument should be.
  827. *
  828. * Forces *@arg to be @val.
  829. *
  830. * Return:
  831. * 0 if *@arg was already @val.
  832. * -EINVAL if *@arg differed from @val.
  833. */
  834. static inline int comedi_check_trigger_arg_is(unsigned int *arg,
  835. unsigned int val)
  836. {
  837. if (*arg != val) {
  838. *arg = val;
  839. return -EINVAL;
  840. }
  841. return 0;
  842. }
  843. /**
  844. * comedi_check_trigger_arg_min() - Trivially validate a trigger argument min
  845. * @arg: Pointer to the trigger arg to validate.
  846. * @val: The minimum value the argument should be.
  847. *
  848. * Forces *@arg to be at least @val, setting it to @val if necessary.
  849. *
  850. * Return:
  851. * 0 if *@arg was already at least @val.
  852. * -EINVAL if *@arg was less than @val.
  853. */
  854. static inline int comedi_check_trigger_arg_min(unsigned int *arg,
  855. unsigned int val)
  856. {
  857. if (*arg < val) {
  858. *arg = val;
  859. return -EINVAL;
  860. }
  861. return 0;
  862. }
  863. /**
  864. * comedi_check_trigger_arg_max() - Trivially validate a trigger argument max
  865. * @arg: Pointer to the trigger arg to validate.
  866. * @val: The maximum value the argument should be.
  867. *
  868. * Forces *@arg to be no more than @val, setting it to @val if necessary.
  869. *
  870. * Return:
  871. * 0 if*@arg was already no more than @val.
  872. * -EINVAL if *@arg was greater than @val.
  873. */
  874. static inline int comedi_check_trigger_arg_max(unsigned int *arg,
  875. unsigned int val)
  876. {
  877. if (*arg > val) {
  878. *arg = val;
  879. return -EINVAL;
  880. }
  881. return 0;
  882. }
  883. /*
  884. * Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
  885. * Also useful for retrieving a previously configured hardware device of
  886. * known bus type. Set automatically for auto-configured devices.
  887. * Automatically set to NULL when detaching hardware device.
  888. */
  889. int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev);
  890. /**
  891. * comedi_buf_n_bytes_ready - Determine amount of unread data in buffer
  892. * @s: COMEDI subdevice.
  893. *
  894. * Determines the number of bytes of unread data in the asynchronous
  895. * acquisition data buffer for a subdevice. The data in question might not
  896. * have been fully "munged" yet.
  897. *
  898. * Returns: The amount of unread data in bytes.
  899. */
  900. static inline unsigned int comedi_buf_n_bytes_ready(struct comedi_subdevice *s)
  901. {
  902. return s->async->buf_write_count - s->async->buf_read_count;
  903. }
  904. unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n);
  905. unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n);
  906. unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s);
  907. unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n);
  908. unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n);
  909. unsigned int comedi_buf_write_samples(struct comedi_subdevice *s,
  910. const void *data, unsigned int nsamples);
  911. unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
  912. void *data, unsigned int nsamples);
  913. /* drivers.c - general comedi driver functions */
  914. #define COMEDI_TIMEOUT_MS 1000
  915. int comedi_timeout(struct comedi_device *, struct comedi_subdevice *,
  916. struct comedi_insn *,
  917. int (*cb)(struct comedi_device *, struct comedi_subdevice *,
  918. struct comedi_insn *, unsigned long context),
  919. unsigned long context);
  920. unsigned int comedi_handle_events(struct comedi_device *dev,
  921. struct comedi_subdevice *s);
  922. int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *,
  923. struct comedi_insn *, unsigned int *data,
  924. unsigned int mask);
  925. unsigned int comedi_dio_update_state(struct comedi_subdevice *,
  926. unsigned int *data);
  927. unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s);
  928. unsigned int comedi_nscans_left(struct comedi_subdevice *s,
  929. unsigned int nscans);
  930. unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
  931. unsigned int nsamples);
  932. void comedi_inc_scan_progress(struct comedi_subdevice *s,
  933. unsigned int num_bytes);
  934. void *comedi_alloc_devpriv(struct comedi_device *, size_t);
  935. int comedi_alloc_subdevices(struct comedi_device *, int);
  936. int comedi_alloc_subdev_readback(struct comedi_subdevice *);
  937. int comedi_readback_insn_read(struct comedi_device *, struct comedi_subdevice *,
  938. struct comedi_insn *, unsigned int *data);
  939. int comedi_load_firmware(struct comedi_device *, struct device *,
  940. const char *name,
  941. int (*cb)(struct comedi_device *,
  942. const u8 *data, size_t size,
  943. unsigned long context),
  944. unsigned long context);
  945. int __comedi_request_region(struct comedi_device *,
  946. unsigned long start, unsigned long len);
  947. int comedi_request_region(struct comedi_device *,
  948. unsigned long start, unsigned long len);
  949. void comedi_legacy_detach(struct comedi_device *);
  950. int comedi_auto_config(struct device *, struct comedi_driver *,
  951. unsigned long context);
  952. void comedi_auto_unconfig(struct device *);
  953. int comedi_driver_register(struct comedi_driver *);
  954. void comedi_driver_unregister(struct comedi_driver *);
  955. /**
  956. * module_comedi_driver() - Helper macro for registering a comedi driver
  957. * @__comedi_driver: comedi_driver struct
  958. *
  959. * Helper macro for comedi drivers which do not do anything special in module
  960. * init/exit. This eliminates a lot of boilerplate. Each module may only use
  961. * this macro once, and calling it replaces module_init() and module_exit().
  962. */
  963. #define module_comedi_driver(__comedi_driver) \
  964. module_driver(__comedi_driver, comedi_driver_register, \
  965. comedi_driver_unregister)
  966. #endif /* _COMEDIDEV_H */