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