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