Version:  2.0.40 2.2.26 2.4.37 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2

Linux/drivers/staging/dgnc/dgnc_driver.c

  1 /*
  2  * Copyright 2003 Digi International (www.digi.com)
  3  *      Scott H Kilau <Scott_Kilau at digi dot com>
  4  *
  5  * This program is free software; you can redistribute it and/or modify
  6  * it under the terms of the GNU General Public License as published by
  7  * the Free Software Foundation; either version 2, or (at your option)
  8  * any later version.
  9  *
 10  * This program is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
 12  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 13  * PURPOSE.  See the GNU General Public License for more details.
 14  */
 15 
 16 
 17 #include <linux/kernel.h>
 18 #include <linux/module.h>
 19 #include <linux/pci.h>
 20 #include <linux/slab.h>
 21 #include <linux/sched.h>
 22 #include "dgnc_driver.h"
 23 #include "dgnc_pci.h"
 24 #include "dgnc_mgmt.h"
 25 #include "dgnc_tty.h"
 26 #include "dgnc_cls.h"
 27 #include "dgnc_neo.h"
 28 #include "dgnc_sysfs.h"
 29 
 30 MODULE_LICENSE("GPL");
 31 MODULE_AUTHOR("Digi International, http://www.digi.com");
 32 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line");
 33 MODULE_SUPPORTED_DEVICE("dgnc");
 34 
 35 /**************************************************************************
 36  *
 37  * protos for this file
 38  *
 39  */
 40 static int              dgnc_start(void);
 41 static int              dgnc_finalize_board_init(struct dgnc_board *brd);
 42 static void             dgnc_init_globals(void);
 43 static int              dgnc_found_board(struct pci_dev *pdev, int id);
 44 static void             dgnc_cleanup_board(struct dgnc_board *brd);
 45 static void             dgnc_poll_handler(ulong dummy);
 46 static int              dgnc_init_one(struct pci_dev *pdev,
 47                                       const struct pci_device_id *ent);
 48 static void             dgnc_do_remap(struct dgnc_board *brd);
 49 
 50 /*
 51  * File operations permitted on Control/Management major.
 52  */
 53 static const struct file_operations dgnc_BoardFops = {
 54         .owner          =       THIS_MODULE,
 55         .unlocked_ioctl =       dgnc_mgmt_ioctl,
 56         .open           =       dgnc_mgmt_open,
 57         .release        =       dgnc_mgmt_close
 58 };
 59 
 60 
 61 /*
 62  * Globals
 63  */
 64 uint                    dgnc_NumBoards;
 65 struct dgnc_board               *dgnc_Board[MAXBOARDS];
 66 DEFINE_SPINLOCK(dgnc_global_lock);
 67 uint                    dgnc_Major;
 68 int                     dgnc_poll_tick = 20;    /* Poll interval - 20 ms */
 69 
 70 /*
 71  * Static vars.
 72  */
 73 static struct class *dgnc_class;
 74 
 75 /*
 76  * Poller stuff
 77  */
 78 static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
 79 static ulong            dgnc_poll_time; /* Time of next poll */
 80 static uint             dgnc_poll_stop; /* Used to tell poller to stop */
 81 static struct timer_list dgnc_poll_timer;
 82 
 83 
 84 static const struct pci_device_id dgnc_pci_tbl[] = {
 85         {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_DID),     .driver_data = 0},
 86         {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID), .driver_data = 1},
 87         {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_8_DID),     .driver_data = 2},
 88         {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID), .driver_data = 3},
 89         {0,}
 90 };
 91 MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl);
 92 
 93 struct board_id {
 94         unsigned char *name;
 95         uint maxports;
 96         unsigned int is_pci_express;
 97 };
 98 
 99 static struct board_id dgnc_Ids[] = {
100         {       PCI_DEVICE_CLASSIC_4_PCI_NAME,          4,      0       },
101         {       PCI_DEVICE_CLASSIC_4_422_PCI_NAME,      4,      0       },
102         {       PCI_DEVICE_CLASSIC_8_PCI_NAME,          8,      0       },
103         {       PCI_DEVICE_CLASSIC_8_422_PCI_NAME,      8,      0       },
104         {       PCI_DEVICE_NEO_4_PCI_NAME,              4,      0       },
105         {       PCI_DEVICE_NEO_8_PCI_NAME,              8,      0       },
106         {       PCI_DEVICE_NEO_2DB9_PCI_NAME,           2,      0       },
107         {       PCI_DEVICE_NEO_2DB9PRI_PCI_NAME,        2,      0       },
108         {       PCI_DEVICE_NEO_2RJ45_PCI_NAME,          2,      0       },
109         {       PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME,       2,      0       },
110         {       PCI_DEVICE_NEO_1_422_PCI_NAME,          1,      0       },
111         {       PCI_DEVICE_NEO_1_422_485_PCI_NAME,      1,      0       },
112         {       PCI_DEVICE_NEO_2_422_485_PCI_NAME,      2,      0       },
113         {       PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME,      8,      1       },
114         {       PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME,      4,      1       },
115         {       PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME,  4,      1       },
116         {       PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME,  8,      1       },
117         {       NULL,                                   0,      0       }
118 };
119 
120 static struct pci_driver dgnc_driver = {
121         .name           = "dgnc",
122         .probe          = dgnc_init_one,
123         .id_table       = dgnc_pci_tbl,
124 };
125 
126 /************************************************************************
127  *
128  * Driver load/unload functions
129  *
130  ************************************************************************/
131 
132 /*
133  * dgnc_cleanup_module()
134  *
135  * Module unload.  This is where it all ends.
136  */
137 static void dgnc_cleanup_module(void)
138 {
139         int i;
140         unsigned long flags;
141 
142         spin_lock_irqsave(&dgnc_poll_lock, flags);
143         dgnc_poll_stop = 1;
144         spin_unlock_irqrestore(&dgnc_poll_lock, flags);
145 
146         /* Turn off poller right away. */
147         del_timer_sync(&dgnc_poll_timer);
148 
149         dgnc_remove_driver_sysfiles(&dgnc_driver);
150 
151         device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
152         class_destroy(dgnc_class);
153         unregister_chrdev(dgnc_Major, "dgnc");
154 
155         for (i = 0; i < dgnc_NumBoards; ++i) {
156                 dgnc_remove_ports_sysfiles(dgnc_Board[i]);
157                 dgnc_tty_uninit(dgnc_Board[i]);
158                 dgnc_cleanup_board(dgnc_Board[i]);
159         }
160 
161         dgnc_tty_post_uninit();
162 
163         if (dgnc_NumBoards)
164                 pci_unregister_driver(&dgnc_driver);
165 }
166 
167 /*
168  * init_module()
169  *
170  * Module load.  This is where it all starts.
171  */
172 static int __init dgnc_init_module(void)
173 {
174         int rc = 0;
175 
176         /*
177          * Initialize global stuff
178          */
179         rc = dgnc_start();
180 
181         if (rc < 0)
182                 return rc;
183 
184         /*
185          * Find and configure all the cards
186          */
187         rc = pci_register_driver(&dgnc_driver);
188 
189         /*
190          * If something went wrong in the scan, bail out of driver.
191          */
192         if (rc < 0) {
193                 /* Only unregister if it was actually registered. */
194                 if (dgnc_NumBoards)
195                         pci_unregister_driver(&dgnc_driver);
196                 else
197                         pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or Classic boards found.\n");
198 
199                 dgnc_cleanup_module();
200         } else {
201                 dgnc_create_driver_sysfiles(&dgnc_driver);
202         }
203 
204         return rc;
205 }
206 
207 module_init(dgnc_init_module);
208 module_exit(dgnc_cleanup_module);
209 
210 /*
211  * Start of driver.
212  */
213 static int dgnc_start(void)
214 {
215         int rc = 0;
216         unsigned long flags;
217         struct device *dev;
218 
219         /* make sure that the globals are init'd before we do anything else */
220         dgnc_init_globals();
221 
222         /*
223          * Register our base character device into the kernel.
224          * This allows the download daemon to connect to the downld device
225          * before any of the boards are init'ed.
226          *
227          * Register management/dpa devices
228          */
229         rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
230         if (rc < 0) {
231                 pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
232                 return rc;
233         }
234         dgnc_Major = rc;
235 
236         dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
237         if (IS_ERR(dgnc_class)) {
238                 rc = PTR_ERR(dgnc_class);
239                 pr_err(DRVSTR ": Can't create dgnc_mgmt class (%d)\n", rc);
240                 goto failed_class;
241         }
242 
243         dev = device_create(dgnc_class, NULL,
244                         MKDEV(dgnc_Major, 0),
245                         NULL, "dgnc_mgmt");
246         if (IS_ERR(dev)) {
247                 rc = PTR_ERR(dev);
248                 pr_err(DRVSTR ": Can't create device (%d)\n", rc);
249                 goto failed_device;
250         }
251 
252         /*
253          * Init any global tty stuff.
254          */
255         rc = dgnc_tty_preinit();
256 
257         if (rc < 0) {
258                 pr_err(DRVSTR ": tty preinit - not enough memory (%d)\n", rc);
259                 goto failed_tty;
260         }
261 
262         /* Start the poller */
263         spin_lock_irqsave(&dgnc_poll_lock, flags);
264         setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
265         dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
266         dgnc_poll_timer.expires = dgnc_poll_time;
267         spin_unlock_irqrestore(&dgnc_poll_lock, flags);
268 
269         add_timer(&dgnc_poll_timer);
270 
271         return 0;
272 
273 failed_tty:
274         device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
275 failed_device:
276         class_destroy(dgnc_class);
277 failed_class:
278         unregister_chrdev(dgnc_Major, "dgnc");
279         return rc;
280 }
281 
282 /* returns count (>= 0), or negative on error */
283 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
284 {
285         int rc;
286 
287         /* wake up and enable device */
288         rc = pci_enable_device(pdev);
289 
290         if (rc < 0) {
291                 rc = -EIO;
292         } else {
293                 rc = dgnc_found_board(pdev, ent->driver_data);
294                 if (rc == 0)
295                         dgnc_NumBoards++;
296         }
297         return rc;
298 }
299 
300 /*
301  * dgnc_cleanup_board()
302  *
303  * Free all the memory associated with a board
304  */
305 static void dgnc_cleanup_board(struct dgnc_board *brd)
306 {
307         int i = 0;
308 
309         if (!brd || brd->magic != DGNC_BOARD_MAGIC)
310                 return;
311 
312         switch (brd->device) {
313         case PCI_DEVICE_CLASSIC_4_DID:
314         case PCI_DEVICE_CLASSIC_8_DID:
315         case PCI_DEVICE_CLASSIC_4_422_DID:
316         case PCI_DEVICE_CLASSIC_8_422_DID:
317 
318                 /* Tell card not to interrupt anymore. */
319                 outb(0, brd->iobase + 0x4c);
320                 break;
321 
322         default:
323                 break;
324         }
325 
326         if (brd->irq)
327                 free_irq(brd->irq, brd);
328 
329         tasklet_kill(&brd->helper_tasklet);
330 
331         if (brd->re_map_membase) {
332                 iounmap(brd->re_map_membase);
333                 brd->re_map_membase = NULL;
334         }
335 
336         if (brd->msgbuf_head) {
337                 unsigned long flags;
338 
339                 spin_lock_irqsave(&dgnc_global_lock, flags);
340                 brd->msgbuf = NULL;
341                 dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
342                 kfree(brd->msgbuf_head);
343                 brd->msgbuf_head = NULL;
344                 spin_unlock_irqrestore(&dgnc_global_lock, flags);
345         }
346 
347         /* Free all allocated channels structs */
348         for (i = 0; i < MAXPORTS ; i++) {
349                 if (brd->channels[i]) {
350                         kfree(brd->channels[i]->ch_rqueue);
351                         kfree(brd->channels[i]->ch_equeue);
352                         kfree(brd->channels[i]->ch_wqueue);
353                         kfree(brd->channels[i]);
354                         brd->channels[i] = NULL;
355                 }
356         }
357 
358 
359         dgnc_Board[brd->boardnum] = NULL;
360 
361         kfree(brd);
362 }
363 
364 
365 /*
366  * dgnc_found_board()
367  *
368  * A board has been found, init it.
369  */
370 static int dgnc_found_board(struct pci_dev *pdev, int id)
371 {
372         struct dgnc_board *brd;
373         unsigned int pci_irq;
374         int i = 0;
375         int rc = 0;
376         unsigned long flags;
377 
378         /* get the board structure and prep it */
379         dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(*brd), GFP_KERNEL);
380         brd = dgnc_Board[dgnc_NumBoards];
381 
382         if (!brd)
383                 return -ENOMEM;
384 
385         /* make a temporary message buffer for the boot messages */
386         brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
387         brd->msgbuf = brd->msgbuf_head;
388 
389         if (!brd->msgbuf) {
390                 kfree(brd);
391                 return -ENOMEM;
392         }
393 
394         /* store the info for the board we've found */
395         brd->magic = DGNC_BOARD_MAGIC;
396         brd->boardnum = dgnc_NumBoards;
397         brd->vendor = dgnc_pci_tbl[id].vendor;
398         brd->device = dgnc_pci_tbl[id].device;
399         brd->pdev = pdev;
400         brd->pci_bus = pdev->bus->number;
401         brd->pci_slot = PCI_SLOT(pdev->devfn);
402         brd->name = dgnc_Ids[id].name;
403         brd->maxports = dgnc_Ids[id].maxports;
404         if (dgnc_Ids[i].is_pci_express)
405                 brd->bd_flags |= BD_IS_PCI_EXPRESS;
406         brd->dpastatus = BD_NOFEP;
407         init_waitqueue_head(&brd->state_wait);
408 
409         spin_lock_init(&brd->bd_lock);
410         spin_lock_init(&brd->bd_intr_lock);
411 
412         brd->state              = BOARD_FOUND;
413 
414         for (i = 0; i < MAXPORTS; i++)
415                 brd->channels[i] = NULL;
416 
417         /* store which card & revision we have */
418         pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
419         pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice);
420         pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev);
421 
422         pci_irq = pdev->irq;
423         brd->irq = pci_irq;
424 
425 
426         switch (brd->device) {
427 
428         case PCI_DEVICE_CLASSIC_4_DID:
429         case PCI_DEVICE_CLASSIC_8_DID:
430         case PCI_DEVICE_CLASSIC_4_422_DID:
431         case PCI_DEVICE_CLASSIC_8_422_DID:
432 
433                 brd->dpatype = T_CLASSIC | T_PCIBUS;
434 
435                 /*
436                  * For PCI ClassicBoards
437                  * PCI Local Address (i.e. "resource" number) space
438                  * 0    PLX Memory Mapped Config
439                  * 1    PLX I/O Mapped Config
440                  * 2    I/O Mapped UARTs and Status
441                  * 3    Memory Mapped VPD
442                  * 4    Memory Mapped UARTs and Status
443                  */
444 
445 
446                 /* get the PCI Base Address Registers */
447                 brd->membase = pci_resource_start(pdev, 4);
448 
449                 if (!brd->membase) {
450                         dev_err(&brd->pdev->dev,
451                                 "Card has no PCI IO resources, failing.\n");
452                         return -ENODEV;
453                 }
454 
455                 brd->membase_end = pci_resource_end(pdev, 4);
456 
457                 if (brd->membase & 1)
458                         brd->membase &= ~3;
459                 else
460                         brd->membase &= ~15;
461 
462                 brd->iobase     = pci_resource_start(pdev, 1);
463                 brd->iobase_end = pci_resource_end(pdev, 1);
464                 brd->iobase     = ((unsigned int) (brd->iobase)) & 0xFFFE;
465 
466                 /* Assign the board_ops struct */
467                 brd->bd_ops = &dgnc_cls_ops;
468 
469                 brd->bd_uart_offset = 0x8;
470                 brd->bd_dividend = 921600;
471 
472                 dgnc_do_remap(brd);
473 
474                 /* Get and store the board VPD, if it exists */
475                 brd->bd_ops->vpd(brd);
476 
477                 /*
478                  * Enable Local Interrupt 1               (0x1),
479                  * Local Interrupt 1 Polarity Active high (0x2),
480                  * Enable PCI interrupt                   (0x40)
481                  */
482                 outb(0x43, brd->iobase + 0x4c);
483 
484                 break;
485 
486 
487         case PCI_DEVICE_NEO_4_DID:
488         case PCI_DEVICE_NEO_8_DID:
489         case PCI_DEVICE_NEO_2DB9_DID:
490         case PCI_DEVICE_NEO_2DB9PRI_DID:
491         case PCI_DEVICE_NEO_2RJ45_DID:
492         case PCI_DEVICE_NEO_2RJ45PRI_DID:
493         case PCI_DEVICE_NEO_1_422_DID:
494         case PCI_DEVICE_NEO_1_422_485_DID:
495         case PCI_DEVICE_NEO_2_422_485_DID:
496         case PCI_DEVICE_NEO_EXPRESS_8_DID:
497         case PCI_DEVICE_NEO_EXPRESS_4_DID:
498         case PCI_DEVICE_NEO_EXPRESS_4RJ45_DID:
499         case PCI_DEVICE_NEO_EXPRESS_8RJ45_DID:
500 
501                 /*
502                  * This chip is set up 100% when we get to it.
503                  * No need to enable global interrupts or anything.
504                  */
505                 if (brd->bd_flags & BD_IS_PCI_EXPRESS)
506                         brd->dpatype = T_NEO_EXPRESS | T_PCIBUS;
507                 else
508                         brd->dpatype = T_NEO | T_PCIBUS;
509 
510                 /* get the PCI Base Address Registers */
511                 brd->membase     = pci_resource_start(pdev, 0);
512                 brd->membase_end = pci_resource_end(pdev, 0);
513 
514                 if (brd->membase & 1)
515                         brd->membase &= ~3;
516                 else
517                         brd->membase &= ~15;
518 
519                 /* Assign the board_ops struct */
520                 brd->bd_ops = &dgnc_neo_ops;
521 
522                 brd->bd_uart_offset = 0x200;
523                 brd->bd_dividend = 921600;
524 
525                 dgnc_do_remap(brd);
526 
527                 if (brd->re_map_membase) {
528 
529                         /* Read and store the dvid after remapping */
530                         brd->dvid = readb(brd->re_map_membase + 0x8D);
531 
532                         /* Get and store the board VPD, if it exists */
533                         brd->bd_ops->vpd(brd);
534                 }
535                 break;
536 
537         default:
538                 dev_err(&brd->pdev->dev,
539                         "Didn't find any compatible Neo/Classic PCI boards.\n");
540                 return -ENXIO;
541 
542         }
543 
544         /*
545          * Do tty device initialization.
546          */
547 
548         rc = dgnc_tty_register(brd);
549         if (rc < 0) {
550                 pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
551                 goto failed;
552         }
553 
554         rc = dgnc_finalize_board_init(brd);
555         if (rc < 0) {
556                 pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
557                 goto failed;
558         }
559 
560         rc = dgnc_tty_init(brd);
561         if (rc < 0) {
562                 pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
563                 goto failed;
564         }
565 
566         brd->state = BOARD_READY;
567         brd->dpastatus = BD_RUNNING;
568 
569         dgnc_create_ports_sysfiles(brd);
570 
571         /* init our poll helper tasklet */
572         tasklet_init(&brd->helper_tasklet,
573                      brd->bd_ops->tasklet,
574                      (unsigned long) brd);
575 
576         spin_lock_irqsave(&dgnc_global_lock, flags);
577         brd->msgbuf = NULL;
578         dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
579         kfree(brd->msgbuf_head);
580         brd->msgbuf_head = NULL;
581         spin_unlock_irqrestore(&dgnc_global_lock, flags);
582 
583         wake_up_interruptible(&brd->state_wait);
584 
585         return 0;
586 
587 failed:
588         dgnc_tty_uninit(brd);
589         brd->state = BOARD_FAILED;
590         brd->dpastatus = BD_NOFEP;
591 
592         return -ENXIO;
593 
594 }
595 
596 
597 static int dgnc_finalize_board_init(struct dgnc_board *brd)
598 {
599         int rc = 0;
600 
601         if (!brd || brd->magic != DGNC_BOARD_MAGIC)
602                 return -ENODEV;
603 
604         if (brd->irq) {
605                 rc = request_irq(brd->irq, brd->bd_ops->intr,
606                                  IRQF_SHARED, "DGNC", brd);
607 
608                 if (rc) {
609                         dev_err(&brd->pdev->dev,
610                                 "Failed to hook IRQ %d\n", brd->irq);
611                         brd->state = BOARD_FAILED;
612                         brd->dpastatus = BD_NOFEP;
613                         rc = -ENODEV;
614                 }
615         }
616         return rc;
617 }
618 
619 /*
620  * Remap PCI memory.
621  */
622 static void dgnc_do_remap(struct dgnc_board *brd)
623 {
624 
625         if (!brd || brd->magic != DGNC_BOARD_MAGIC)
626                 return;
627 
628         brd->re_map_membase = ioremap(brd->membase, 0x1000);
629 }
630 
631 
632 /*****************************************************************************
633 *
634 * Function:
635 *
636 *    dgnc_poll_handler
637 *
638 * Author:
639 *
640 *    Scott H Kilau
641 *
642 * Parameters:
643 *
644 *    dummy -- ignored
645 *
646 * Return Values:
647 *
648 *    none
649 *
650 * Description:
651 *
652 *    As each timer expires, it determines (a) whether the "transmit"
653 *    waiter needs to be woken up, and (b) whether the poller needs to
654 *    be rescheduled.
655 *
656 ******************************************************************************/
657 
658 static void dgnc_poll_handler(ulong dummy)
659 {
660         struct dgnc_board *brd;
661         unsigned long flags;
662         int i;
663         unsigned long new_time;
664 
665         /* Go thru each board, kicking off a tasklet for each if needed */
666         for (i = 0; i < dgnc_NumBoards; i++) {
667                 brd = dgnc_Board[i];
668 
669                 spin_lock_irqsave(&brd->bd_lock, flags);
670 
671                 /* If board is in a failed state don't schedule a tasklet */
672                 if (brd->state == BOARD_FAILED) {
673                         spin_unlock_irqrestore(&brd->bd_lock, flags);
674                         continue;
675                 }
676 
677                 /* Schedule a poll helper task */
678                 tasklet_schedule(&brd->helper_tasklet);
679 
680                 spin_unlock_irqrestore(&brd->bd_lock, flags);
681         }
682 
683         /*
684          * Schedule ourself back at the nominal wakeup interval.
685          */
686         spin_lock_irqsave(&dgnc_poll_lock, flags);
687         dgnc_poll_time += dgnc_jiffies_from_ms(dgnc_poll_tick);
688 
689         new_time = dgnc_poll_time - jiffies;
690 
691         if ((ulong) new_time >= 2 * dgnc_poll_tick)
692                 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
693 
694         setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
695         dgnc_poll_timer.expires = dgnc_poll_time;
696         spin_unlock_irqrestore(&dgnc_poll_lock, flags);
697 
698         if (!dgnc_poll_stop)
699                 add_timer(&dgnc_poll_timer);
700 }
701 
702 /*
703  * dgnc_init_globals()
704  *
705  * This is where we initialize the globals from the static insmod
706  * configuration variables.  These are declared near the head of
707  * this file.
708  */
709 static void dgnc_init_globals(void)
710 {
711         int i = 0;
712 
713         dgnc_NumBoards          = 0;
714 
715         for (i = 0; i < MAXBOARDS; i++)
716                 dgnc_Board[i] = NULL;
717 
718         init_timer(&dgnc_poll_timer);
719 }
720 
721 

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