Version:  2.0.40 2.2.26 2.4.37 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17

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

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us