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