comedidev.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. include/linux/comedidev.h
  3. header file for kernel-only structures, variables, and constants
  4. COMEDI - Linux Control and Measurement Device Interface
  5. Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. #ifndef _COMEDIDEV_H
  16. #define _COMEDIDEV_H
  17. #include <linux/dma-mapping.h>
  18. #include <linux/mutex.h>
  19. #include <linux/spinlock_types.h>
  20. #include <linux/rwsem.h>
  21. #include <linux/kref.h>
  22. #include "comedi.h"
  23. #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
  24. #define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \
  25. COMEDI_MINORVERSION, COMEDI_MICROVERSION)
  26. #define COMEDI_RELEASE VERSION
  27. #define COMEDI_NUM_BOARD_MINORS 0x30
  28. struct comedi_subdevice {
  29. struct comedi_device *device;
  30. int index;
  31. int type;
  32. int n_chan;
  33. int subdev_flags;
  34. int len_chanlist; /* maximum length of channel/gain list */
  35. void *private;
  36. struct comedi_async *async;
  37. void *lock;
  38. void *busy;
  39. unsigned runflags;
  40. spinlock_t spin_lock;
  41. unsigned int io_bits;
  42. unsigned int maxdata; /* if maxdata==0, use list */
  43. const unsigned int *maxdata_list; /* list is channel specific */
  44. const struct comedi_lrange *range_table;
  45. const struct comedi_lrange *const *range_table_list;
  46. unsigned int *chanlist; /* driver-owned chanlist (not used) */
  47. int (*insn_read)(struct comedi_device *, struct comedi_subdevice *,
  48. struct comedi_insn *, unsigned int *);
  49. int (*insn_write)(struct comedi_device *, struct comedi_subdevice *,
  50. struct comedi_insn *, unsigned int *);
  51. int (*insn_bits)(struct comedi_device *, struct comedi_subdevice *,
  52. struct comedi_insn *, unsigned int *);
  53. int (*insn_config)(struct comedi_device *, struct comedi_subdevice *,
  54. struct comedi_insn *, unsigned int *);
  55. int (*do_cmd)(struct comedi_device *, struct comedi_subdevice *);
  56. int (*do_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
  57. struct comedi_cmd *);
  58. int (*poll)(struct comedi_device *, struct comedi_subdevice *);
  59. int (*cancel)(struct comedi_device *, struct comedi_subdevice *);
  60. /* called when the buffer changes */
  61. int (*buf_change)(struct comedi_device *, struct comedi_subdevice *);
  62. void (*munge)(struct comedi_device *dev, struct comedi_subdevice *s,
  63. void *data, unsigned int num_bytes,
  64. unsigned int start_chan_index);
  65. enum dma_data_direction async_dma_dir;
  66. unsigned int state;
  67. struct device *class_dev;
  68. int minor;
  69. unsigned int *readback;
  70. };
  71. struct comedi_buf_page {
  72. void *virt_addr;
  73. dma_addr_t dma_addr;
  74. };
  75. struct comedi_buf_map {
  76. struct device *dma_hw_dev;
  77. struct comedi_buf_page *page_list;
  78. unsigned int n_pages;
  79. enum dma_data_direction dma_dir;
  80. struct kref refcount;
  81. };
  82. /**
  83. * struct comedi_async - control data for asynchronous comedi commands
  84. * @prealloc_buf: preallocated buffer
  85. * @prealloc_bufsz: buffer size (in bytes)
  86. * @buf_map: map of buffer pages
  87. * @max_bufsize: maximum buffer size (in bytes)
  88. * @buf_write_count: "write completed" count (in bytes, modulo 2**32)
  89. * @buf_write_alloc_count: "allocated for writing" count (in bytes,
  90. * modulo 2**32)
  91. * @buf_read_count: "read completed" count (in bytes, modulo 2**32)
  92. * @buf_read_alloc_count: "allocated for reading" count (in bytes,
  93. * modulo 2**32)
  94. * @buf_write_ptr: buffer position for writer
  95. * @buf_read_ptr: buffer position for reader
  96. * @cur_chan: current position in chanlist for scan (for those
  97. * drivers that use it)
  98. * @scan_progress: amount received or sent for current scan (in bytes)
  99. * @munge_chan: current position in chanlist for "munging"
  100. * @munge_count: "munge" count (in bytes, modulo 2**32)
  101. * @munge_ptr: buffer position for "munging"
  102. * @events: bit-vector of events that have occurred
  103. * @cmd: details of comedi command in progress
  104. * @wait_head: task wait queue for file reader or writer
  105. * @cb_mask: bit-vector of events that should wake waiting tasks
  106. * @inttrig: software trigger function for command, or NULL
  107. *
  108. * Note about the ..._count and ..._ptr members:
  109. *
  110. * Think of the _Count values being integers of unlimited size, indexing
  111. * into a buffer of infinite length (though only an advancing portion
  112. * of the buffer of fixed length prealloc_bufsz is accessible at any time).
  113. * Then:
  114. *
  115. * Buf_Read_Count <= Buf_Read_Alloc_Count <= Munge_Count <=
  116. * Buf_Write_Count <= Buf_Write_Alloc_Count <=
  117. * (Buf_Read_Count + prealloc_bufsz)
  118. *
  119. * (Those aren't the actual members, apart from prealloc_bufsz.) When
  120. * the buffer is reset, those _Count values start at 0 and only increase
  121. * in value, maintaining the above inequalities until the next time the
  122. * buffer is reset. The buffer is divided into the following regions by
  123. * the inequalities:
  124. *
  125. * [0, Buf_Read_Count):
  126. * old region no longer accessible
  127. * [Buf_Read_Count, Buf_Read_Alloc_Count):
  128. * filled and munged region allocated for reading but not yet read
  129. * [Buf_Read_Alloc_Count, Munge_Count):
  130. * filled and munged region not yet allocated for reading
  131. * [Munge_Count, Buf_Write_Count):
  132. * filled region not yet munged
  133. * [Buf_Write_Count, Buf_Write_Alloc_Count):
  134. * unfilled region allocated for writing but not yet written
  135. * [Buf_Write_Alloc_Count, Buf_Read_Count + prealloc_bufsz):
  136. * unfilled region not yet allocated for writing
  137. * [Buf_Read_Count + prealloc_bufsz, infinity):
  138. * unfilled region not yet accessible
  139. *
  140. * Data needs to be written into the buffer before it can be read out,
  141. * and may need to be converted (or "munged") between the two
  142. * operations. Extra unfilled buffer space may need to allocated for
  143. * writing (advancing Buf_Write_Alloc_Count) before new data is written.
  144. * After writing new data, the newly filled space needs to be released
  145. * (advancing Buf_Write_Count). This also results in the new data being
  146. * "munged" (advancing Munge_Count). Before data is read out of the
  147. * buffer, extra space may need to be allocated for reading (advancing
  148. * Buf_Read_Alloc_Count). After the data has been read out, the space
  149. * needs to be released (advancing Buf_Read_Count).
  150. *
  151. * The actual members, buf_read_count, buf_read_alloc_count,
  152. * munge_count, buf_write_count, and buf_write_alloc_count take the
  153. * value of the corresponding capitalized _Count values modulo 2^32
  154. * (UINT_MAX+1). Subtracting a "higher" _count value from a "lower"
  155. * _count value gives the same answer as subtracting a "higher" _Count
  156. * value from a lower _Count value because prealloc_bufsz < UINT_MAX+1.
  157. * The modulo operation is done implicitly.
  158. *
  159. * The buf_read_ptr, munge_ptr, and buf_write_ptr members take the value
  160. * of the corresponding capitalized _Count values modulo prealloc_bufsz.
  161. * These correspond to byte indices in the physical buffer. The modulo
  162. * operation is done by subtracting prealloc_bufsz when the value
  163. * exceeds prealloc_bufsz (assuming prealloc_bufsz plus the increment is
  164. * less than or equal to UINT_MAX).
  165. */
  166. struct comedi_async {
  167. void *prealloc_buf;
  168. unsigned int prealloc_bufsz;
  169. struct comedi_buf_map *buf_map;
  170. unsigned int max_bufsize;
  171. unsigned int buf_write_count;
  172. unsigned int buf_write_alloc_count;
  173. unsigned int buf_read_count;
  174. unsigned int buf_read_alloc_count;
  175. unsigned int buf_write_ptr;
  176. unsigned int buf_read_ptr;
  177. unsigned int cur_chan;
  178. unsigned int scan_progress;
  179. unsigned int munge_chan;
  180. unsigned int munge_count;
  181. unsigned int munge_ptr;
  182. unsigned int events;
  183. struct comedi_cmd cmd;
  184. wait_queue_head_t wait_head;
  185. unsigned int cb_mask;
  186. int (*inttrig)(struct comedi_device *dev, struct comedi_subdevice *s,
  187. unsigned int x);
  188. };
  189. struct comedi_driver {
  190. struct comedi_driver *next;
  191. const char *driver_name;
  192. struct module *module;
  193. int (*attach)(struct comedi_device *, struct comedi_devconfig *);
  194. void (*detach)(struct comedi_device *);
  195. int (*auto_attach)(struct comedi_device *, unsigned long);
  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. struct comedi_device {
  203. int use_count;
  204. struct comedi_driver *driver;
  205. void *private;
  206. struct device *class_dev;
  207. int minor;
  208. unsigned int detach_count;
  209. /* hw_dev is passed to dma_alloc_coherent when allocating async buffers
  210. * for subdevices that have async_dma_dir set to something other than
  211. * DMA_NONE */
  212. struct device *hw_dev;
  213. const char *board_name;
  214. const void *board_ptr;
  215. bool attached:1;
  216. bool ioenabled:1;
  217. spinlock_t spinlock;
  218. struct mutex mutex;
  219. struct rw_semaphore attach_lock;
  220. struct kref refcount;
  221. int n_subdevices;
  222. struct comedi_subdevice *subdevices;
  223. /* dumb */
  224. void __iomem *mmio;
  225. unsigned long iobase;
  226. unsigned long iolen;
  227. unsigned int irq;
  228. struct comedi_subdevice *read_subdev;
  229. struct comedi_subdevice *write_subdev;
  230. struct fasync_struct *async_queue;
  231. int (*open)(struct comedi_device *dev);
  232. void (*close)(struct comedi_device *dev);
  233. };
  234. /*
  235. * function prototypes
  236. */
  237. void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
  238. /* we can expand the number of bits used to encode devices/subdevices into
  239. the minor number soon, after more distros support > 8 bit minor numbers
  240. (like after Debian Etch gets released) */
  241. enum comedi_minor_bits {
  242. COMEDI_DEVICE_MINOR_MASK = 0xf,
  243. COMEDI_SUBDEVICE_MINOR_MASK = 0xf0
  244. };
  245. static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4;
  246. static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
  247. struct comedi_device *comedi_dev_get_from_minor(unsigned minor);
  248. int comedi_dev_put(struct comedi_device *dev);
  249. void init_polling(void);
  250. void cleanup_polling(void);
  251. void start_polling(struct comedi_device *);
  252. void stop_polling(struct comedi_device *);
  253. /* subdevice runflags */
  254. enum subdevice_runflags {
  255. SRF_RT = 0x00000002,
  256. /* indicates an COMEDI_CB_ERROR event has occurred since the last
  257. * command was started */
  258. SRF_ERROR = 0x00000004,
  259. SRF_RUNNING = 0x08000000,
  260. SRF_FREE_SPRIV = 0x80000000, /* free s->private on detach */
  261. };
  262. bool comedi_is_subdevice_running(struct comedi_subdevice *s);
  263. void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size);
  264. int comedi_check_chanlist(struct comedi_subdevice *s,
  265. int n,
  266. unsigned int *chanlist);
  267. /* range stuff */
  268. #define RANGE(a, b) {(a)*1e6, (b)*1e6, 0}
  269. #define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL}
  270. #define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA}
  271. #define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0}
  272. #define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0}
  273. #define UNI_RANGE(a) {0, (a)*1e6, 0}
  274. extern const struct comedi_lrange range_bipolar10;
  275. extern const struct comedi_lrange range_bipolar5;
  276. extern const struct comedi_lrange range_bipolar2_5;
  277. extern const struct comedi_lrange range_unipolar10;
  278. extern const struct comedi_lrange range_unipolar5;
  279. extern const struct comedi_lrange range_unipolar2_5;
  280. extern const struct comedi_lrange range_0_20mA;
  281. extern const struct comedi_lrange range_4_20mA;
  282. extern const struct comedi_lrange range_0_32mA;
  283. extern const struct comedi_lrange range_unknown;
  284. #define range_digital range_unipolar5
  285. #if __GNUC__ >= 3
  286. #define GCC_ZERO_LENGTH_ARRAY
  287. #else
  288. #define GCC_ZERO_LENGTH_ARRAY 0
  289. #endif
  290. struct comedi_lrange {
  291. int length;
  292. struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY];
  293. };
  294. static inline bool comedi_range_is_bipolar(struct comedi_subdevice *s,
  295. unsigned int range)
  296. {
  297. return s->range_table->range[range].min < 0;
  298. }
  299. static inline bool comedi_range_is_unipolar(struct comedi_subdevice *s,
  300. unsigned int range)
  301. {
  302. return s->range_table->range[range].min >= 0;
  303. }
  304. static inline bool comedi_range_is_external(struct comedi_subdevice *s,
  305. unsigned int range)
  306. {
  307. return !!(s->range_table->range[range].flags & RF_EXTERNAL);
  308. }
  309. static inline bool comedi_chan_range_is_bipolar(struct comedi_subdevice *s,
  310. unsigned int chan,
  311. unsigned int range)
  312. {
  313. return s->range_table_list[chan]->range[range].min < 0;
  314. }
  315. static inline bool comedi_chan_range_is_unipolar(struct comedi_subdevice *s,
  316. unsigned int chan,
  317. unsigned int range)
  318. {
  319. return s->range_table_list[chan]->range[range].min >= 0;
  320. }
  321. static inline bool comedi_chan_range_is_external(struct comedi_subdevice *s,
  322. unsigned int chan,
  323. unsigned int range)
  324. {
  325. return !!(s->range_table_list[chan]->range[range].flags & RF_EXTERNAL);
  326. }
  327. /* munge between offset binary and two's complement values */
  328. static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
  329. unsigned int val)
  330. {
  331. return val ^ s->maxdata ^ (s->maxdata >> 1);
  332. }
  333. static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
  334. {
  335. if (subd->subdev_flags & SDF_LSAMPL)
  336. return sizeof(unsigned int);
  337. return sizeof(short);
  338. }
  339. /*
  340. * Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
  341. * Also useful for retrieving a previously configured hardware device of
  342. * known bus type. Set automatically for auto-configured devices.
  343. * Automatically set to NULL when detaching hardware device.
  344. */
  345. int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev);
  346. static inline unsigned int comedi_buf_n_bytes_ready(struct comedi_subdevice *s)
  347. {
  348. return s->async->buf_write_count - s->async->buf_read_count;
  349. }
  350. unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n);
  351. unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n);
  352. unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s);
  353. unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n);
  354. unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n);
  355. int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
  356. int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x);
  357. void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
  358. const void *source, unsigned int num_bytes);
  359. void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
  360. void *destination, unsigned int num_bytes);
  361. unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  362. const void *data,
  363. unsigned int num_bytes);
  364. unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
  365. void *data, unsigned int num_bytes);
  366. /* drivers.c - general comedi driver functions */
  367. #define COMEDI_TIMEOUT_MS 1000
  368. int comedi_timeout(struct comedi_device *, struct comedi_subdevice *,
  369. struct comedi_insn *,
  370. int (*cb)(struct comedi_device *, struct comedi_subdevice *,
  371. struct comedi_insn *, unsigned long context),
  372. unsigned long context);
  373. unsigned int comedi_handle_events(struct comedi_device *dev,
  374. struct comedi_subdevice *s);
  375. int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *,
  376. struct comedi_insn *, unsigned int *data,
  377. unsigned int mask);
  378. unsigned int comedi_dio_update_state(struct comedi_subdevice *,
  379. unsigned int *data);
  380. unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s);
  381. void comedi_inc_scan_progress(struct comedi_subdevice *s,
  382. unsigned int num_bytes);
  383. void *comedi_alloc_devpriv(struct comedi_device *, size_t);
  384. int comedi_alloc_subdevices(struct comedi_device *, int);
  385. int comedi_alloc_subdev_readback(struct comedi_subdevice *);
  386. int comedi_readback_insn_read(struct comedi_device *, struct comedi_subdevice *,
  387. struct comedi_insn *, unsigned int *data);
  388. int comedi_load_firmware(struct comedi_device *, struct device *,
  389. const char *name,
  390. int (*cb)(struct comedi_device *,
  391. const u8 *data, size_t size,
  392. unsigned long context),
  393. unsigned long context);
  394. int __comedi_request_region(struct comedi_device *,
  395. unsigned long start, unsigned long len);
  396. int comedi_request_region(struct comedi_device *,
  397. unsigned long start, unsigned long len);
  398. void comedi_legacy_detach(struct comedi_device *);
  399. int comedi_auto_config(struct device *, struct comedi_driver *,
  400. unsigned long context);
  401. void comedi_auto_unconfig(struct device *);
  402. int comedi_driver_register(struct comedi_driver *);
  403. void comedi_driver_unregister(struct comedi_driver *);
  404. /**
  405. * module_comedi_driver() - Helper macro for registering a comedi driver
  406. * @__comedi_driver: comedi_driver struct
  407. *
  408. * Helper macro for comedi drivers which do not do anything special in module
  409. * init/exit. This eliminates a lot of boilerplate. Each module may only use
  410. * this macro once, and calling it replaces module_init() and module_exit().
  411. */
  412. #define module_comedi_driver(__comedi_driver) \
  413. module_driver(__comedi_driver, comedi_driver_register, \
  414. comedi_driver_unregister)
  415. #ifdef CONFIG_COMEDI_PCI_DRIVERS
  416. /* comedi_pci.c - comedi PCI driver specific functions */
  417. /*
  418. * PCI Vendor IDs not in <linux/pci_ids.h>
  419. */
  420. #define PCI_VENDOR_ID_KOLTER 0x1001
  421. #define PCI_VENDOR_ID_ICP 0x104c
  422. #define PCI_VENDOR_ID_DT 0x1116
  423. #define PCI_VENDOR_ID_IOTECH 0x1616
  424. #define PCI_VENDOR_ID_CONTEC 0x1221
  425. #define PCI_VENDOR_ID_RTD 0x1435
  426. #define PCI_VENDOR_ID_HUMUSOFT 0x186c
  427. struct pci_dev;
  428. struct pci_driver;
  429. struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
  430. int comedi_pci_enable(struct comedi_device *);
  431. void comedi_pci_disable(struct comedi_device *);
  432. void comedi_pci_detach(struct comedi_device *);
  433. int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
  434. unsigned long context);
  435. void comedi_pci_auto_unconfig(struct pci_dev *);
  436. int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
  437. void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
  438. /**
  439. * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
  440. * @__comedi_driver: comedi_driver struct
  441. * @__pci_driver: pci_driver struct
  442. *
  443. * Helper macro for comedi PCI drivers which do not do anything special
  444. * in module init/exit. This eliminates a lot of boilerplate. Each
  445. * module may only use this macro once, and calling it replaces
  446. * module_init() and module_exit()
  447. */
  448. #define module_comedi_pci_driver(__comedi_driver, __pci_driver) \
  449. module_driver(__comedi_driver, comedi_pci_driver_register, \
  450. comedi_pci_driver_unregister, &(__pci_driver))
  451. #else
  452. /*
  453. * Some of the comedi mixed ISA/PCI drivers call the PCI specific
  454. * functions. Provide some dummy functions if CONFIG_COMEDI_PCI_DRIVERS
  455. * is not enabled.
  456. */
  457. static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev)
  458. {
  459. return NULL;
  460. }
  461. static inline int comedi_pci_enable(struct comedi_device *dev)
  462. {
  463. return -ENOSYS;
  464. }
  465. static inline void comedi_pci_disable(struct comedi_device *dev)
  466. {
  467. }
  468. static inline void comedi_pci_detach(struct comedi_device *dev)
  469. {
  470. }
  471. #endif /* CONFIG_COMEDI_PCI_DRIVERS */
  472. #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
  473. /* comedi_pcmcia.c - comedi PCMCIA driver specific functions */
  474. struct pcmcia_driver;
  475. struct pcmcia_device;
  476. struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *);
  477. int comedi_pcmcia_enable(struct comedi_device *,
  478. int (*conf_check)(struct pcmcia_device *, void *));
  479. void comedi_pcmcia_disable(struct comedi_device *);
  480. int comedi_pcmcia_auto_config(struct pcmcia_device *, struct comedi_driver *);
  481. void comedi_pcmcia_auto_unconfig(struct pcmcia_device *);
  482. int comedi_pcmcia_driver_register(struct comedi_driver *,
  483. struct pcmcia_driver *);
  484. void comedi_pcmcia_driver_unregister(struct comedi_driver *,
  485. struct pcmcia_driver *);
  486. /**
  487. * module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver
  488. * @__comedi_driver: comedi_driver struct
  489. * @__pcmcia_driver: pcmcia_driver struct
  490. *
  491. * Helper macro for comedi PCMCIA drivers which do not do anything special
  492. * in module init/exit. This eliminates a lot of boilerplate. Each
  493. * module may only use this macro once, and calling it replaces
  494. * module_init() and module_exit()
  495. */
  496. #define module_comedi_pcmcia_driver(__comedi_driver, __pcmcia_driver) \
  497. module_driver(__comedi_driver, comedi_pcmcia_driver_register, \
  498. comedi_pcmcia_driver_unregister, &(__pcmcia_driver))
  499. #endif /* CONFIG_COMEDI_PCMCIA_DRIVERS */
  500. #ifdef CONFIG_COMEDI_USB_DRIVERS
  501. /* comedi_usb.c - comedi USB driver specific functions */
  502. struct usb_driver;
  503. struct usb_interface;
  504. struct usb_interface *comedi_to_usb_interface(struct comedi_device *);
  505. struct usb_device *comedi_to_usb_dev(struct comedi_device *);
  506. int comedi_usb_auto_config(struct usb_interface *, struct comedi_driver *,
  507. unsigned long context);
  508. void comedi_usb_auto_unconfig(struct usb_interface *);
  509. int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *);
  510. void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *);
  511. /**
  512. * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver
  513. * @__comedi_driver: comedi_driver struct
  514. * @__usb_driver: usb_driver struct
  515. *
  516. * Helper macro for comedi USB drivers which do not do anything special
  517. * in module init/exit. This eliminates a lot of boilerplate. Each
  518. * module may only use this macro once, and calling it replaces
  519. * module_init() and module_exit()
  520. */
  521. #define module_comedi_usb_driver(__comedi_driver, __usb_driver) \
  522. module_driver(__comedi_driver, comedi_usb_driver_register, \
  523. comedi_usb_driver_unregister, &(__usb_driver))
  524. #endif /* CONFIG_COMEDI_USB_DRIVERS */
  525. #endif /* _COMEDIDEV_H */