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