Merge tag 'arc-v3.9-rc1-late' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
[firefly-linux-kernel-4.4.55.git] / drivers / staging / comedi / drivers / skel.c
1 /*
2     comedi/drivers/skel.c
3     Skeleton code for a Comedi driver
4
5     COMEDI - Linux Control and Measurement Device Interface
6     Copyright (C) 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     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 */
23 /*
24 Driver: skel
25 Description: Skeleton driver, an example for driver writers
26 Devices:
27 Author: ds
28 Updated: Mon, 18 Mar 2002 15:34:01 -0800
29 Status: works
30
31 This driver is a documented example on how Comedi drivers are
32 written.
33
34 Configuration Options:
35   none
36 */
37
38 /*
39  * The previous block comment is used to automatically generate
40  * documentation in Comedi and Comedilib.  The fields:
41  *
42  *  Driver: the name of the driver
43  *  Description: a short phrase describing the driver.  Don't list boards.
44  *  Devices: a full list of the boards that attempt to be supported by
45  *    the driver.  Format is "(manufacturer) board name [comedi name]",
46  *    where comedi_name is the name that is used to configure the board.
47  *    See the comment near board_name: in the struct comedi_driver structure
48  *    below.  If (manufacturer) or [comedi name] is missing, the previous
49  *    value is used.
50  *  Author: you
51  *  Updated: date when the _documentation_ was last updated.  Use 'date -R'
52  *    to get a value for this.
53  *  Status: a one-word description of the status.  Valid values are:
54  *    works - driver works correctly on most boards supported, and
55  *      passes comedi_test.
56  *    unknown - unknown.  Usually put there by ds.
57  *    experimental - may not work in any particular release.  Author
58  *      probably wants assistance testing it.
59  *    bitrotten - driver has not been update in a long time, probably
60  *      doesn't work, and probably is missing support for significant
61  *      Comedi interface features.
62  *    untested - author probably wrote it "blind", and is believed to
63  *      work, but no confirmation.
64  *
65  * These headers should be followed by a blank line, and any comments
66  * you wish to say about the driver.  The comment area is the place
67  * to put any known bugs, limitations, unsupported features, supported
68  * command triggers, whether or not commands are supported on particular
69  * subdevices, etc.
70  *
71  * Somewhere in the comment should be information about configuration
72  * options that are used with comedi_config.
73  */
74
75 #include <linux/pci.h>
76
77 #include "../comedidev.h"
78
79 #include "comedi_fc.h"
80
81 /* Imaginary registers for the imaginary board */
82
83 #define SKEL_SIZE 0
84
85 #define SKEL_START_AI_CONV      0
86 #define SKEL_AI_READ            0
87
88 /*
89  * Board descriptions for two imaginary boards.  Describing the
90  * boards in this way is optional, and completely driver-dependent.
91  * Some drivers use arrays such as this, other do not.
92  */
93 struct skel_board {
94         const char *name;
95         unsigned int devid;
96         int ai_chans;
97         int ai_bits;
98         int have_dio;
99 };
100
101 static const struct skel_board skel_boards[] = {
102         {
103          .name = "skel-100",
104          .devid = 0x100,
105          .ai_chans = 16,
106          .ai_bits = 12,
107          .have_dio = 1,
108          },
109         {
110          .name = "skel-200",
111          .devid = 0x200,
112          .ai_chans = 8,
113          .ai_bits = 16,
114          .have_dio = 0,
115          },
116 };
117
118 /* this structure is for data unique to this hardware driver.  If
119    several hardware drivers keep similar information in this structure,
120    feel free to suggest moving the variable to the struct comedi_device struct.
121  */
122 struct skel_private {
123
124         int data;
125
126         /* Used for AO readback */
127         unsigned int ao_readback[2];
128 };
129
130 /* This function doesn't require a particular form, this is just
131  * what happens to be used in some of the drivers.  It should
132  * convert ns nanoseconds to a counter value suitable for programming
133  * the device.  Also, it should adjust ns so that it cooresponds to
134  * the actual time that the device will use. */
135 static int skel_ns_to_timer(unsigned int *ns, int round)
136 {
137         /* trivial timer */
138         /* if your timing is done through two cascaded timers, the
139          * i8253_cascade_ns_to_timer() function in 8253.h can be
140          * very helpful.  There are also i8254_load() and i8254_mm_load()
141          * which can be used to load values into the ubiquitous 8254 counters
142          */
143
144         return *ns;
145 }
146
147 /*
148  * "instructions" read/write data in "one-shot" or "software-triggered"
149  * mode.
150  */
151 static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
152                          struct comedi_insn *insn, unsigned int *data)
153 {
154         const struct skel_board *thisboard = comedi_board(dev);
155         int n, i;
156         unsigned int d;
157         unsigned int status;
158
159         /* a typical programming sequence */
160
161         /* write channel to multiplexer */
162         /* outw(chan,dev->iobase + SKEL_MUX); */
163
164         /* don't wait for mux to settle */
165
166         /* convert n samples */
167         for (n = 0; n < insn->n; n++) {
168                 /* trigger conversion */
169                 /* outw(0,dev->iobase + SKEL_CONVERT); */
170
171 #define TIMEOUT 100
172                 /* wait for conversion to end */
173                 for (i = 0; i < TIMEOUT; i++) {
174                         status = 1;
175                         /* status = inb(dev->iobase + SKEL_STATUS); */
176                         if (status)
177                                 break;
178                 }
179                 if (i == TIMEOUT) {
180                         dev_warn(dev->class_dev, "ai timeout\n");
181                         return -ETIMEDOUT;
182                 }
183
184                 /* read data */
185                 /* d = inw(dev->iobase + SKEL_AI_DATA); */
186                 d = 0;
187
188                 /* mangle the data as necessary */
189                 d ^= 1 << (thisboard->ai_bits - 1);
190
191                 data[n] = d;
192         }
193
194         /* return the number of samples read/written */
195         return n;
196 }
197
198 /*
199  * cmdtest tests a particular command to see if it is valid.
200  * Using the cmdtest ioctl, a user can create a valid cmd
201  * and then have it executes by the cmd ioctl.
202  *
203  * cmdtest returns 1,2,3,4 or 0, depending on which tests
204  * the command passes.
205  */
206 static int skel_ai_cmdtest(struct comedi_device *dev,
207                            struct comedi_subdevice *s,
208                            struct comedi_cmd *cmd)
209 {
210         int err = 0;
211         int tmp;
212
213         /* Step 1 : check if triggers are trivially valid */
214
215         err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
216         err |= cfc_check_trigger_src(&cmd->scan_begin_src,
217                                         TRIG_TIMER | TRIG_EXT);
218         err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
219         err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
220         err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
221
222         if (err)
223                 return 1;
224
225         /* Step 2a : make sure trigger sources are unique */
226
227         err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
228         err |= cfc_check_trigger_is_unique(cmd->convert_src);
229         err |= cfc_check_trigger_is_unique(cmd->stop_src);
230
231         /* Step 2b : and mutually compatible */
232
233         if (err)
234                 return 2;
235
236         /* Step 3: check if arguments are trivially valid */
237
238         err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
239
240 #define MAX_SPEED       10000   /* in nanoseconds */
241 #define MIN_SPEED       1000000000      /* in nanoseconds */
242
243         if (cmd->scan_begin_src == TRIG_TIMER) {
244                 err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
245                                                  MAX_SPEED);
246                 err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
247                                                  MIN_SPEED);
248         } else {
249                 /* external trigger */
250                 /* should be level/edge, hi/lo specification here */
251                 /* should specify multiple external triggers */
252                 err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
253         }
254
255         if (cmd->convert_src == TRIG_TIMER) {
256                 err |= cfc_check_trigger_arg_min(&cmd->convert_arg, MAX_SPEED);
257                 err |= cfc_check_trigger_arg_max(&cmd->convert_arg, MIN_SPEED);
258         } else {
259                 /* external trigger */
260                 /* see above */
261                 err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
262         }
263
264         err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
265
266         if (cmd->stop_src == TRIG_COUNT)
267                 err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
268         else    /* TRIG_NONE */
269                 err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
270
271         if (err)
272                 return 3;
273
274         /* step 4: fix up any arguments */
275
276         if (cmd->scan_begin_src == TRIG_TIMER) {
277                 tmp = cmd->scan_begin_arg;
278                 skel_ns_to_timer(&cmd->scan_begin_arg,
279                                  cmd->flags & TRIG_ROUND_MASK);
280                 if (tmp != cmd->scan_begin_arg)
281                         err++;
282         }
283         if (cmd->convert_src == TRIG_TIMER) {
284                 tmp = cmd->convert_arg;
285                 skel_ns_to_timer(&cmd->convert_arg,
286                                  cmd->flags & TRIG_ROUND_MASK);
287                 if (tmp != cmd->convert_arg)
288                         err++;
289                 if (cmd->scan_begin_src == TRIG_TIMER &&
290                     cmd->scan_begin_arg <
291                     cmd->convert_arg * cmd->scan_end_arg) {
292                         cmd->scan_begin_arg =
293                             cmd->convert_arg * cmd->scan_end_arg;
294                         err++;
295                 }
296         }
297
298         if (err)
299                 return 4;
300
301         return 0;
302 }
303
304 static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
305                          struct comedi_insn *insn, unsigned int *data)
306 {
307         struct skel_private *devpriv = dev->private;
308         int i;
309         int chan = CR_CHAN(insn->chanspec);
310
311         /* Writing a list of values to an AO channel is probably not
312          * very useful, but that's how the interface is defined. */
313         for (i = 0; i < insn->n; i++) {
314                 /* a typical programming sequence */
315                 /* outw(data[i],dev->iobase + SKEL_DA0 + chan); */
316                 devpriv->ao_readback[chan] = data[i];
317         }
318
319         /* return the number of samples read/written */
320         return i;
321 }
322
323 /* AO subdevices should have a read insn as well as a write insn.
324  * Usually this means copying a value stored in devpriv. */
325 static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
326                          struct comedi_insn *insn, unsigned int *data)
327 {
328         struct skel_private *devpriv = dev->private;
329         int i;
330         int chan = CR_CHAN(insn->chanspec);
331
332         for (i = 0; i < insn->n; i++)
333                 data[i] = devpriv->ao_readback[chan];
334
335         return i;
336 }
337
338 /* DIO devices are slightly special.  Although it is possible to
339  * implement the insn_read/insn_write interface, it is much more
340  * useful to applications if you implement the insn_bits interface.
341  * This allows packed reading/writing of the DIO channels.  The
342  * comedi core can convert between insn_bits and insn_read/write */
343 static int skel_dio_insn_bits(struct comedi_device *dev,
344                               struct comedi_subdevice *s,
345                               struct comedi_insn *insn, unsigned int *data)
346 {
347         /* The insn data is a mask in data[0] and the new data
348          * in data[1], each channel cooresponding to a bit. */
349         if (data[0]) {
350                 s->state &= ~data[0];
351                 s->state |= data[0] & data[1];
352                 /* Write out the new digital output lines */
353                 /* outw(s->state,dev->iobase + SKEL_DIO); */
354         }
355
356         /* on return, data[1] contains the value of the digital
357          * input and output lines. */
358         /* data[1]=inw(dev->iobase + SKEL_DIO); */
359         /* or we could just return the software copy of the output values if
360          * it was a purely digital output subdevice */
361         /* data[1]=s->state; */
362
363         return insn->n;
364 }
365
366 static int skel_dio_insn_config(struct comedi_device *dev,
367                                 struct comedi_subdevice *s,
368                                 struct comedi_insn *insn, unsigned int *data)
369 {
370         int chan = CR_CHAN(insn->chanspec);
371
372         /* The input or output configuration of each digital line is
373          * configured by a special insn_config instruction.  chanspec
374          * contains the channel to be changed, and data[0] contains the
375          * value COMEDI_INPUT or COMEDI_OUTPUT. */
376         switch (data[0]) {
377         case INSN_CONFIG_DIO_OUTPUT:
378                 s->io_bits |= 1 << chan;
379                 break;
380         case INSN_CONFIG_DIO_INPUT:
381                 s->io_bits &= ~(1 << chan);
382                 break;
383         case INSN_CONFIG_DIO_QUERY:
384                 data[1] =
385                     (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
386                 return insn->n;
387                 break;
388         default:
389                 return -EINVAL;
390                 break;
391         }
392         /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
393
394         return insn->n;
395 }
396
397 static const struct skel_board *skel_find_pci_board(struct pci_dev *pcidev)
398 {
399         unsigned int i;
400
401 /*
402  * This example code assumes all the entries in skel_boards[] are PCI boards
403  * and all use the same PCI vendor ID.  If skel_boards[] contains a mixture
404  * of PCI and non-PCI boards, this loop should skip over the non-PCI boards.
405  */
406         for (i = 0; i < ARRAY_SIZE(skel_boards); i++)
407                 if (/* skel_boards[i].bustype == pci_bustype && */
408                     pcidev->device == skel_boards[i].devid)
409                         return &skel_boards[i];
410         return NULL;
411 }
412
413 /*
414  * Handle common part of skel_attach() and skel_auto_attach().
415  */
416 static int skel_common_attach(struct comedi_device *dev)
417 {
418         const struct skel_board *thisboard = comedi_board(dev);
419         struct comedi_subdevice *s;
420         int ret;
421
422         ret = comedi_alloc_subdevices(dev, 3);
423         if (ret)
424                 return ret;
425
426         s = &dev->subdevices[0];
427         /* dev->read_subdev=s; */
428         /* analog input subdevice */
429         s->type = COMEDI_SUBD_AI;
430         /* we support single-ended (ground) and differential */
431         s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
432         s->n_chan = thisboard->ai_chans;
433         s->maxdata = (1 << thisboard->ai_bits) - 1;
434         s->range_table = &range_bipolar10;
435         s->len_chanlist = 16;   /* This is the maximum chanlist length that
436                                    the board can handle */
437         s->insn_read = skel_ai_rinsn;
438 /*
439 *       s->subdev_flags |= SDF_CMD_READ;
440 *       s->do_cmd = skel_ai_cmd;
441 */
442         s->do_cmdtest = skel_ai_cmdtest;
443
444         s = &dev->subdevices[1];
445         /* analog output subdevice */
446         s->type = COMEDI_SUBD_AO;
447         s->subdev_flags = SDF_WRITABLE;
448         s->n_chan = 1;
449         s->maxdata = 0xffff;
450         s->range_table = &range_bipolar5;
451         s->insn_write = skel_ao_winsn;
452         s->insn_read = skel_ao_rinsn;
453
454         s = &dev->subdevices[2];
455         /* digital i/o subdevice */
456         if (thisboard->have_dio) {
457                 s->type = COMEDI_SUBD_DIO;
458                 s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
459                 s->n_chan = 16;
460                 s->maxdata = 1;
461                 s->range_table = &range_digital;
462                 s->insn_bits = skel_dio_insn_bits;
463                 s->insn_config = skel_dio_insn_config;
464         } else {
465                 s->type = COMEDI_SUBD_UNUSED;
466         }
467
468         dev_info(dev->class_dev, "skel: attached\n");
469
470         return 0;
471 }
472
473 /*
474  * _attach is called by the Comedi core to configure the driver
475  * for a particular board in response to the COMEDI_DEVCONFIG ioctl for
476  * a matching board or driver name.  If you specified a board_name array
477  * in the driver structure, dev->board_ptr contains that address.
478  *
479  * Drivers that handle only PCI or USB devices do not usually support
480  * manual attachment of those devices via the COMEDI_DEVCONFIG ioctl, so
481  * those drivers do not have an _attach function; they just have an
482  * _auto_attach function instead.  (See skel_auto_attach() for an example
483  * of such a function.)
484  */
485 static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
486 {
487         const struct skel_board *thisboard;
488         struct skel_private *devpriv;
489
490 /*
491  * If you can probe the device to determine what device in a series
492  * it is, this is the place to do it.  Otherwise, dev->board_ptr
493  * should already be initialized.
494  */
495         /* dev->board_ptr = skel_probe(dev, it); */
496
497         thisboard = comedi_board(dev);
498
499 /*
500  * Initialize dev->board_name.
501  */
502         dev->board_name = thisboard->name;
503
504         /* Allocate the private data */
505         devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
506         if (!devpriv)
507                 return -ENOMEM;
508         dev->private = devpriv;
509
510 /*
511  * Supported boards are usually either auto-attached via the
512  * Comedi driver's _auto_attach routine, or manually attached via the
513  * Comedi driver's _attach routine.  In most cases, attempts to
514  * manual attach boards that are usually auto-attached should be
515  * rejected by this function.
516  */
517 /*
518  *      if (thisboard->bustype == pci_bustype) {
519  *              dev_err(dev->class_dev,
520  *                      "Manual attachment of PCI board '%s' not supported\n",
521  *                      thisboard->name);
522  *      }
523  */
524
525 /*
526  * For ISA boards, get the i/o base address from it->options[],
527  * request the i/o region and set dev->iobase * from it->options[].
528  * If using interrupts, get the IRQ number from it->options[].
529  */
530
531         /*
532          * Call a common function to handle the remaining things to do for
533          * attaching ISA or PCI boards.  (Extra parameters could be added
534          * to pass additional information such as IRQ number.)
535          */
536         return skel_common_attach(dev);
537 }
538
539 /*
540  * _auto_attach is called via comedi_pci_auto_config() (or
541  * comedi_usb_auto_config(), etc.) to handle devices that can be attached
542  * to the Comedi core automatically without the COMEDI_DEVCONFIG ioctl.
543  *
544  * The context parameter is usually unused, but if the driver called
545  * comedi_auto_config() directly instead of the comedi_pci_auto_config()
546  * wrapper function, this will be a copy of the context passed to
547  * comedi_auto_config().
548  */
549 static int skel_auto_attach(struct comedi_device *dev,
550                                       unsigned long context)
551 {
552         struct pci_dev *pcidev = comedi_to_pci_dev(dev);
553         const struct skel_board *thisboard;
554         struct skel_private *devpriv;
555         int ret;
556
557         /* Hack to allow unused code to be optimized out. */
558         if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS))
559                 return -EINVAL;
560
561         /* Find a matching board in skel_boards[]. */
562         thisboard = skel_find_pci_board(pcidev);
563         if (!thisboard) {
564                 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
565                 return -EINVAL;
566         }
567
568         /*
569          * Point the struct comedi_device to the matching board info
570          * and set the board name.
571          */
572         dev->board_ptr = thisboard;
573         dev->board_name = thisboard->name;
574
575         /* Allocate the private data */
576         devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
577         if (!devpriv)
578                 return -ENOMEM;
579         dev->private = devpriv;
580
581         /* Enable the PCI device. */
582         ret = comedi_pci_enable(pcidev, dev->board_name);
583         if (ret)
584                 return ret;
585
586         /*
587          * Record the fact that the PCI device is enabled so that it can
588          * be disabled during _detach().
589          *
590          * For this example driver, we assume PCI BAR 0 is the main I/O
591          * region for the board registers and use dev->iobase to hold the
592          * I/O base address and to indicate that the PCI device has been
593          * enabled.
594          *
595          * (For boards with memory-mapped registers, dev->iobase is not
596          * usually needed for register access, so can just be set to 1
597          * to indicate that the PCI device has been enabled.)
598          */
599         dev->iobase = pci_resource_start(pcidev, 0);
600
601         /*
602          * Call a common function to handle the remaining things to do for
603          * attaching ISA or PCI boards.  (Extra parameters could be added
604          * to pass additional information such as IRQ number.)
605          */
606         return skel_common_attach(dev);
607 }
608
609 /*
610  * _detach is called to deconfigure a device.  It should deallocate
611  * resources.
612  * This function is also called when _attach() fails, so it should be
613  * careful not to release resources that were not necessarily
614  * allocated by _attach().  dev->private and dev->subdevices are
615  * deallocated automatically by the core.
616  */
617 static void skel_detach(struct comedi_device *dev)
618 {
619         const struct skel_board *thisboard = comedi_board(dev);
620         struct skel_private *devpriv = dev->private;
621         struct pci_dev *pcidev = comedi_to_pci_dev(dev);
622
623         if (!thisboard || !devpriv)
624                 return;
625
626 /*
627  * Do common stuff such as freeing IRQ, unmapping remapped memory
628  * regions, etc., being careful to check that the stuff is valid given
629  * that _detach() is called even when _attach() or _auto_attach() return
630  * an error.
631  */
632
633         if (IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS) /* &&
634             thisboard->bustype == pci_bustype */) {
635                 /*
636                  * PCI board
637                  *
638                  * If PCI device enabled by _auto_attach() (or _attach()),
639                  * disable it here.
640                  */
641                 if (pcidev && dev->iobase)
642                         comedi_pci_disable(pcidev);
643         } else {
644                 /*
645                  * ISA board
646                  *
647                  * If I/O regions successfully requested by _attach(),
648                  * release them here.
649                  */
650                 if (dev->iobase)
651                         release_region(dev->iobase, SKEL_SIZE);
652         }
653 }
654
655 /*
656  * The struct comedi_driver structure tells the Comedi core module
657  * which functions to call to configure/deconfigure (attach/detach)
658  * the board, and also about the kernel module that contains
659  * the device code.
660  */
661 static struct comedi_driver skel_driver = {
662         .driver_name = "dummy",
663         .module = THIS_MODULE,
664         .attach = skel_attach,
665         .auto_attach = skel_auto_attach,
666         .detach = skel_detach,
667 /* It is not necessary to implement the following members if you are
668  * writing a driver for a ISA PnP or PCI card */
669         /* Most drivers will support multiple types of boards by
670          * having an array of board structures.  These were defined
671          * in skel_boards[] above.  Note that the element 'name'
672          * was first in the structure -- Comedi uses this fact to
673          * extract the name of the board without knowing any details
674          * about the structure except for its length.
675          * When a device is attached (by comedi_config), the name
676          * of the device is given to Comedi, and Comedi tries to
677          * match it by going through the list of board names.  If
678          * there is a match, the address of the pointer is put
679          * into dev->board_ptr and driver->attach() is called.
680          *
681          * Note that these are not necessary if you can determine
682          * the type of board in software.  ISA PnP, PCI, and PCMCIA
683          * devices are such boards.
684          */
685         .board_name = &skel_boards[0].name,
686         .offset = sizeof(struct skel_board),
687         .num_names = ARRAY_SIZE(skel_boards),
688 };
689
690 #ifdef CONFIG_COMEDI_PCI_DRIVERS
691
692 /* This is used by modprobe to translate PCI IDs to drivers.  Should
693  * only be used for PCI and ISA-PnP devices */
694 /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
695  * upstream. */
696 #define PCI_VENDOR_ID_SKEL 0xdafe
697 static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
698         { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0100) },
699         { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0200) },
700         { 0 }
701 };
702 MODULE_DEVICE_TABLE(pci, skel_pci_table);
703
704 static int skel_pci_probe(struct pci_dev *dev,
705                                            const struct pci_device_id *ent)
706 {
707         return comedi_pci_auto_config(dev, &skel_driver);
708 }
709
710 static struct pci_driver skel_pci_driver = {
711         .name = "dummy",
712         .id_table = skel_pci_table,
713         .probe = &skel_pci_probe,
714         .remove         = comedi_pci_auto_unconfig,
715 };
716 module_comedi_pci_driver(skel_driver, skel_pci_driver);
717 #else
718 module_comedi_driver(skel_driver);
719 #endif
720
721 MODULE_AUTHOR("Comedi http://www.comedi.org");
722 MODULE_DESCRIPTION("Comedi low-level driver");
723 MODULE_LICENSE("GPL");