Version:  2.0.40 2.2.26 2.4.37 2.6.39 3.0 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

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

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