Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ip2: init/deinit cleanup

Cleanup of module_init/exit:
- mostly whitespace
- remove empty functions
- replace c++ comments
- remove useless prints (module loaded, unloaded)
- mark the calls as __exit and __init
- use break; and return; to save some indent levels after it
- note resource leakage

It's still mess, but now it's readable.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jiri Slaby and committed by
Linus Torvalds
f1ddfd95 7ccd7020

+199 -252
-32
drivers/char/ip2/i2ellis.c
··· 69 69 //======================================================= 70 70 71 71 //****************************************************************************** 72 - // Function: iiEllisInit() 73 - // Parameters: None 74 - // 75 - // Returns: Nothing 76 - // 77 - // Description: 78 - // 79 - // This routine performs any required initialization of the iiEllis subsystem. 80 - // 81 - //****************************************************************************** 82 - static void 83 - iiEllisInit(void) 84 - { 85 - } 86 - 87 - //****************************************************************************** 88 - // Function: iiEllisCleanup() 89 - // Parameters: None 90 - // 91 - // Returns: Nothing 92 - // 93 - // Description: 94 - // 95 - // This routine performs any required cleanup of the iiEllis subsystem. 96 - // 97 - //****************************************************************************** 98 - static void 99 - iiEllisCleanup(void) 100 - { 101 - } 102 - 103 - //****************************************************************************** 104 72 // Function: iiSetAddress(pB, address, delay) 105 73 // Parameters: pB - pointer to the board structure 106 74 // address - the purported I/O address of the board
-2
drivers/char/ip2/i2ellis.h
··· 511 511 // 512 512 // Initialization of a board & structure is in four (five!) parts: 513 513 // 514 - // 0) iiEllisInit() - Initialize iiEllis subsystem. 515 514 // 1) iiSetAddress() - Define the board address & delay function for a board. 516 515 // 2) iiReset() - Reset the board (provided it exists) 517 516 // -- Note you may do this to several boards -- ··· 522 523 // loadware. To change loadware, you must begin again with step 2, resetting 523 524 // the board again (step 1 not needed). 524 525 525 - static void iiEllisInit(void); 526 526 static int iiSetAddress(i2eBordStrPtr, int, delayFunc_t ); 527 527 static int iiReset(i2eBordStrPtr); 528 528 static int iiResetDelay(i2eBordStrPtr);
+199 -218
drivers/char/ip2/ip2main.c
··· 314 314 /* for sysfs class support */ 315 315 static struct class *ip2_class; 316 316 317 - // Some functions to keep track of what irq's we have 317 + /* Some functions to keep track of what irqs we have */ 318 318 319 - static int 320 - is_valid_irq(int irq) 319 + static int __init is_valid_irq(int irq) 321 320 { 322 321 int *i = Valid_Irqs; 323 322 324 - while ((*i != 0) && (*i != irq)) { 323 + while (*i != 0 && *i != irq) 325 324 i++; 326 - } 327 - return (*i); 325 + 326 + return *i; 328 327 } 329 328 330 - static void 331 - mark_requested_irq( char irq ) 329 + static void __init mark_requested_irq(char irq) 332 330 { 333 331 rirqs[iindx++] = irq; 334 332 } 335 333 336 - #ifdef MODULE 337 - static int 338 - clear_requested_irq( char irq ) 334 + static int __exit clear_requested_irq(char irq) 339 335 { 340 336 int i; 341 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 337 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 342 338 if (rirqs[i] == irq) { 343 339 rirqs[i] = 0; 344 340 return 1; ··· 342 346 } 343 347 return 0; 344 348 } 345 - #endif 346 349 347 - static int 348 - have_requested_irq( char irq ) 350 + static int have_requested_irq(char irq) 349 351 { 350 - // array init to zeros so 0 irq will not be requested as a side effect 352 + /* array init to zeros so 0 irq will not be requested as a side 353 + * effect */ 351 354 int i; 352 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 355 + for (i = 0; i < IP2_MAX_BOARDS; ++i) 353 356 if (rirqs[i] == irq) 354 357 return 1; 355 - } 356 358 return 0; 357 359 } 358 360 ··· 374 380 int err; 375 381 int i; 376 382 377 - #ifdef IP2DEBUG_INIT 378 - printk (KERN_DEBUG "Unloading %s: version %s\n", pcName, pcVersion ); 379 - #endif 380 383 /* Stop poll timer if we had one. */ 381 - if ( TimerOn ) { 382 - del_timer ( &PollTimer ); 384 + if (TimerOn) { 385 + del_timer(&PollTimer); 383 386 TimerOn = 0; 384 387 } 385 388 386 389 /* Reset the boards we have. */ 387 - for( i = 0; i < IP2_MAX_BOARDS; ++i ) { 388 - if ( i2BoardPtrTable[i] ) { 389 - iiReset( i2BoardPtrTable[i] ); 390 - } 391 - } 390 + for (i = 0; i < IP2_MAX_BOARDS; i++) 391 + if (i2BoardPtrTable[i]) 392 + iiReset(i2BoardPtrTable[i]); 392 393 393 394 /* The following is done at most once, if any boards were installed. */ 394 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 395 - if ( i2BoardPtrTable[i] ) { 396 - iiResetDelay( i2BoardPtrTable[i] ); 395 + for (i = 0; i < IP2_MAX_BOARDS; i++) { 396 + if (i2BoardPtrTable[i]) { 397 + iiResetDelay(i2BoardPtrTable[i]); 397 398 /* free io addresses and Tibet */ 398 - release_region( ip2config.addr[i], 8 ); 399 + release_region(ip2config.addr[i], 8); 399 400 device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i)); 400 - device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1)); 401 + device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 402 + 4 * i + 1)); 401 403 } 402 404 /* Disable and remove interrupt handler. */ 403 - if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) { 404 - free_irq ( ip2config.irq[i], (void *)&pcName); 405 - clear_requested_irq( ip2config.irq[i]); 405 + if (ip2config.irq[i] > 0 && 406 + have_requested_irq(ip2config.irq[i])) { 407 + free_irq(ip2config.irq[i], (void *)&pcName); 408 + clear_requested_irq(ip2config.irq[i]); 406 409 } 407 410 } 408 411 class_destroy(ip2_class); 409 - if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) { 410 - printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err); 411 - } 412 + err = tty_unregister_driver(ip2_tty_driver); 413 + if (err) 414 + printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", 415 + err); 412 416 put_tty_driver(ip2_tty_driver); 413 417 unregister_chrdev(IP2_IPL_MAJOR, pcIpl); 414 418 remove_proc_entry("ip2mem", NULL); 415 419 416 - // free memory 420 + /* free memory */ 417 421 for (i = 0; i < IP2_MAX_BOARDS; i++) { 418 422 void *pB; 419 423 #ifdef CONFIG_PCI ··· 423 431 #endif 424 432 pB = i2BoardPtrTable[i]; 425 433 if (pB != NULL) { 426 - kfree ( pB ); 434 + kfree(pB); 427 435 i2BoardPtrTable[i] = NULL; 428 436 } 429 - if ((DevTableMem[i]) != NULL ) { 430 - kfree ( DevTableMem[i] ); 437 + if (DevTableMem[i] != NULL) { 438 + kfree(DevTableMem[i]); 431 439 DevTableMem[i] = NULL; 432 440 } 433 441 } 434 - 435 - /* Cleanup the iiEllis subsystem. */ 436 - iiEllisCleanup(); 437 - #ifdef IP2DEBUG_INIT 438 - printk (KERN_DEBUG "IP2 Unloaded\n" ); 439 - #endif 440 442 } 441 443 module_exit(ip2_cleanup_module); 442 444 ··· 538 552 __setup("ip2=", ip2_setup); 539 553 #endif /* !MODULE */ 540 554 541 - static int ip2_loadmain(void) 555 + static int __init ip2_loadmain(void) 542 556 { 543 557 int i, j, box; 544 558 int err = 0; 545 - static int loaded; 546 559 i2eBordStrPtr pB = NULL; 547 560 int rc = -1; 548 - static struct pci_dev *pci_dev_i = NULL; 561 + struct pci_dev *pdev = NULL; 549 562 const struct firmware *fw = NULL; 550 563 551 564 if (poll_only) { ··· 552 567 irq[0] = irq[1] = irq[2] = irq[3] = poll_only = 0; 553 568 } 554 569 555 - ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0 ); 570 + ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0); 556 571 557 572 /* process command line arguments to modprobe or 558 573 insmod i.e. iop & irqp */ 559 574 /* irqp and iop should ALWAYS be specified now... But we check 560 575 them individually just to be sure, anyways... */ 561 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 576 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 562 577 ip2config.addr[i] = io[i]; 563 578 if (irq[i] >= 0) 564 579 ip2config.irq[i] = irq[i]; 565 580 else 566 581 ip2config.irq[i] = 0; 567 - // This is a little bit of a hack. If poll_only=1 on command 568 - // line back in ip2.c OR all IRQs on all specified boards are 569 - // explicitly set to 0, then drop to poll only mode and override 570 - // PCI or EISA interrupts. This superceeds the old hack of 571 - // triggering if all interrupts were zero (like da default). 572 - // Still a hack but less prone to random acts of terrorism. 573 - // 574 - // What we really should do, now that the IRQ default is set 575 - // to -1, is to use 0 as a hard coded, do not probe. 576 - // 577 - // /\/\|=mhw=|\/\/ 582 + /* This is a little bit of a hack. If poll_only=1 on command 583 + line back in ip2.c OR all IRQs on all specified boards are 584 + explicitly set to 0, then drop to poll only mode and override 585 + PCI or EISA interrupts. This superceeds the old hack of 586 + triggering if all interrupts were zero (like da default). 587 + Still a hack but less prone to random acts of terrorism. 588 + 589 + What we really should do, now that the IRQ default is set 590 + to -1, is to use 0 as a hard coded, do not probe. 591 + 592 + /\/\|=mhw=|\/\/ 593 + */ 578 594 poll_only |= irq[i]; 579 595 } 580 596 poll_only = !poll_only; 581 597 582 598 /* Announce our presence */ 583 - printk( KERN_INFO "%s version %s\n", pcName, pcVersion ); 584 - 585 - // ip2 can be unloaded and reloaded for no good reason 586 - // we can't let that happen here or bad things happen 587 - // second load hoses board but not system - fixme later 588 - if (loaded) { 589 - printk( KERN_INFO "Still loaded\n" ); 590 - return 0; 591 - } 592 - loaded++; 599 + printk(KERN_INFO "%s version %s\n", pcName, pcVersion); 593 600 594 601 ip2_tty_driver = alloc_tty_driver(IP2_MAX_PORTS); 595 602 if (!ip2_tty_driver) 596 603 return -ENOMEM; 597 604 598 - /* Initialise the iiEllis subsystem. */ 599 - iiEllisInit(); 600 - 601 605 /* Initialise all the boards we can find (up to the maximum). */ 602 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 603 - switch ( ip2config.addr[i] ) { 606 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 607 + switch (ip2config.addr[i]) { 604 608 case 0: /* skip this slot even if card is present */ 605 609 break; 606 610 default: /* ISA */ 607 611 /* ISA address must be specified */ 608 - if ( (ip2config.addr[i] < 0x100) || (ip2config.addr[i] > 0x3f8) ) { 609 - printk ( KERN_ERR "IP2: Bad ISA board %d address %x\n", 610 - i, ip2config.addr[i] ); 612 + if (ip2config.addr[i] < 0x100 || 613 + ip2config.addr[i] > 0x3f8) { 614 + printk(KERN_ERR "IP2: Bad ISA board %d " 615 + "address %x\n", i, 616 + ip2config.addr[i]); 611 617 ip2config.addr[i] = 0; 612 - } else { 613 - ip2config.type[i] = ISA; 618 + break; 619 + } 620 + ip2config.type[i] = ISA; 614 621 615 - /* Check for valid irq argument, set for polling if invalid */ 616 - if (ip2config.irq[i] && !is_valid_irq(ip2config.irq[i])) { 617 - printk(KERN_ERR "IP2: Bad IRQ(%d) specified\n",ip2config.irq[i]); 618 - ip2config.irq[i] = 0;// 0 is polling and is valid in that sense 619 - } 622 + /* Check for valid irq argument, set for polling if 623 + * invalid */ 624 + if (ip2config.irq[i] && 625 + !is_valid_irq(ip2config.irq[i])) { 626 + printk(KERN_ERR "IP2: Bad IRQ(%d) specified\n", 627 + ip2config.irq[i]); 628 + /* 0 is polling and is valid in that sense */ 629 + ip2config.irq[i] = 0; 620 630 } 621 631 break; 622 632 case PCI: 623 633 #ifdef CONFIG_PCI 624 - { 625 - int status; 634 + { 635 + u32 addr; 636 + int status; 626 637 627 - pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE, 628 - PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); 629 - if (pci_dev_i != NULL) { 630 - unsigned int addr; 631 - 632 - if (pci_enable_device(pci_dev_i)) { 633 - printk( KERN_ERR "IP2: can't enable PCI device at %s\n", 634 - pci_name(pci_dev_i)); 635 - break; 636 - } 637 - ip2config.type[i] = PCI; 638 - ip2config.pci_dev[i] = pci_dev_get(pci_dev_i); 639 - status = 640 - pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr); 641 - if ( addr & 1 ) { 642 - ip2config.addr[i]=(USHORT)(addr&0xfffe); 643 - } else { 644 - printk( KERN_ERR "IP2: PCI I/O address error\n"); 645 - } 646 - 647 - // If the PCI BIOS assigned it, lets try and use it. If we 648 - // can't acquire it or it screws up, deal with it then. 649 - 650 - // if (!is_valid_irq(pci_irq)) { 651 - // printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq); 652 - // pci_irq = 0; 653 - // } 654 - ip2config.irq[i] = pci_dev_i->irq; 655 - } else { // ann error 656 - ip2config.addr[i] = 0; 657 - printk(KERN_ERR "IP2: PCI board %d not found\n", i); 658 - } 638 + pdev = pci_get_device(PCI_VENDOR_ID_COMPUTONE, 639 + PCI_DEVICE_ID_COMPUTONE_IP2EX, pdev); 640 + if (pdev == NULL) { 641 + ip2config.addr[i] = 0; 642 + printk(KERN_ERR "IP2: PCI board %d not " 643 + "found\n", i); 644 + break; 659 645 } 646 + 647 + if (pci_enable_device(pdev)) { 648 + dev_err(&pdev->dev, "can't enable device\n"); 649 + break; 650 + } 651 + ip2config.type[i] = PCI; 652 + ip2config.pci_dev[i] = pci_dev_get(pdev); 653 + status = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_1, 654 + &addr); 655 + if (addr & 1) 656 + ip2config.addr[i] = (USHORT)(addr & 0xfffe); 657 + else 658 + dev_err(&pdev->dev, "I/O address error\n"); 659 + 660 + ip2config.irq[i] = pdev->irq; 661 + } 660 662 #else 661 - printk( KERN_ERR "IP2: PCI card specified but PCI support not\n"); 662 - printk( KERN_ERR "IP2: configured in this kernel.\n"); 663 - printk( KERN_ERR "IP2: Recompile kernel with CONFIG_PCI defined!\n"); 663 + printk(KERN_ERR "IP2: PCI card specified but PCI " 664 + "support not enabled.\n"); 665 + printk(KERN_ERR "IP2: Recompile kernel with CONFIG_PCI " 666 + "defined!\n"); 664 667 #endif /* CONFIG_PCI */ 665 668 break; 666 669 case EISA: 667 - if ( (ip2config.addr[i] = find_eisa_board( Eisa_slot + 1 )) != 0) { 670 + ip2config.addr[i] = find_eisa_board(Eisa_slot + 1); 671 + if (ip2config.addr[i] != 0) { 668 672 /* Eisa_irq set as side effect, boo */ 669 673 ip2config.type[i] = EISA; 670 674 } ··· 661 687 break; 662 688 } /* switch */ 663 689 } /* for */ 664 - if (pci_dev_i) 665 - pci_dev_put(pci_dev_i); 690 + pci_dev_put(pdev); 666 691 667 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 668 - if ( ip2config.addr[i] ) { 692 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 693 + if (ip2config.addr[i]) { 669 694 pB = kzalloc(sizeof(i2eBordStr), GFP_KERNEL); 670 695 if (pB) { 671 696 i2BoardPtrTable[i] = pB; 672 - iiSetAddress( pB, ip2config.addr[i], ii2DelayTimer ); 673 - iiReset( pB ); 674 - } else { 675 - printk(KERN_ERR "IP2: board memory allocation error\n"); 676 - } 697 + iiSetAddress(pB, ip2config.addr[i], 698 + ii2DelayTimer); 699 + iiReset(pB); 700 + } else 701 + printk(KERN_ERR "IP2: board memory allocation " 702 + "error\n"); 677 703 } 678 704 } 679 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 680 - if ( ( pB = i2BoardPtrTable[i] ) != NULL ) { 681 - iiResetDelay( pB ); 705 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 706 + pB = i2BoardPtrTable[i]; 707 + if (pB != NULL) { 708 + iiResetDelay(pB); 682 709 break; 683 710 } 684 711 } 685 - for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 712 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 686 713 /* We don't want to request the firmware unless we have at 687 714 least one board */ 688 - if ( i2BoardPtrTable[i] != NULL ) { 715 + if (i2BoardPtrTable[i] != NULL) { 689 716 if (!fw) 690 717 fw = ip2_request_firmware(); 691 718 if (!fw) ··· 697 722 if (fw) 698 723 release_firmware(fw); 699 724 700 - ip2trace (ITRC_NO_PORT, ITRC_INIT, 2, 0 ); 725 + ip2trace(ITRC_NO_PORT, ITRC_INIT, 2, 0); 701 726 702 727 ip2_tty_driver->owner = THIS_MODULE; 703 728 ip2_tty_driver->name = "ttyF"; ··· 708 733 ip2_tty_driver->subtype = SERIAL_TYPE_NORMAL; 709 734 ip2_tty_driver->init_termios = tty_std_termios; 710 735 ip2_tty_driver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; 711 - ip2_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 736 + ip2_tty_driver->flags = TTY_DRIVER_REAL_RAW | 737 + TTY_DRIVER_DYNAMIC_DEV; 712 738 tty_set_operations(ip2_tty_driver, &ip2_ops); 713 739 714 - ip2trace (ITRC_NO_PORT, ITRC_INIT, 3, 0 ); 740 + ip2trace(ITRC_NO_PORT, ITRC_INIT, 3, 0); 715 741 716 - /* Register the tty devices. */ 717 - if ( ( err = tty_register_driver ( ip2_tty_driver ) ) ) { 718 - printk(KERN_ERR "IP2: failed to register tty driver (%d)\n", err); 742 + err = tty_register_driver(ip2_tty_driver); 743 + if (err) { 744 + printk(KERN_ERR "IP2: failed to register tty driver\n"); 719 745 put_tty_driver(ip2_tty_driver); 720 - return -EINVAL; 721 - } else 722 - /* Register the IPL driver. */ 723 - if ( ( err = register_chrdev ( IP2_IPL_MAJOR, pcIpl, &ip2_ipl ) ) ) { 724 - printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err ); 746 + return err; /* leaking resources */ 747 + } 748 + 749 + err = register_chrdev(IP2_IPL_MAJOR, pcIpl, &ip2_ipl); 750 + if (err) { 751 + printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", 752 + err); 725 753 } else { 726 754 /* create the sysfs class */ 727 755 ip2_class = class_create(THIS_MODULE, "ip2"); ··· 736 758 /* Register the read_procmem thing */ 737 759 if (!proc_create("ip2mem",0,NULL,&ip2mem_proc_fops)) { 738 760 printk(KERN_ERR "IP2: failed to register read_procmem\n"); 739 - } else { 761 + return -EIO; /* leaking resources */ 762 + } 740 763 741 - ip2trace (ITRC_NO_PORT, ITRC_INIT, 4, 0 ); 742 - /* Register the interrupt handler or poll handler, depending upon the 743 - * specified interrupt. 744 - */ 764 + ip2trace(ITRC_NO_PORT, ITRC_INIT, 4, 0); 765 + /* Register the interrupt handler or poll handler, depending upon the 766 + * specified interrupt. 767 + */ 745 768 746 - for( i = 0; i < IP2_MAX_BOARDS; ++i ) { 747 - if ( 0 == ip2config.addr[i] ) { 748 - continue; 749 - } 769 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 770 + if (ip2config.addr[i] == 0) 771 + continue; 750 772 751 - if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { 752 - device_create_drvdata(ip2_class, NULL, 753 - MKDEV(IP2_IPL_MAJOR, 4 * i), 754 - NULL, "ipl%d", i); 755 - device_create_drvdata(ip2_class, NULL, 756 - MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 757 - NULL, "stat%d", i); 773 + pB = i2BoardPtrTable[i]; 774 + if (pB != NULL) { 775 + device_create_drvdata(ip2_class, NULL, 776 + MKDEV(IP2_IPL_MAJOR, 4 * i), 777 + NULL, "ipl%d", i); 778 + device_create_drvdata(ip2_class, NULL, 779 + MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 780 + NULL, "stat%d", i); 758 781 759 - for ( box = 0; box < ABS_MAX_BOXES; ++box ) 760 - { 761 - for ( j = 0; j < ABS_BIGGEST_BOX; ++j ) 762 - { 763 - if ( pB->i2eChannelMap[box] & (1 << j) ) 764 - { 765 - tty_register_device(ip2_tty_driver, 766 - j + ABS_BIGGEST_BOX * 767 - (box+i*ABS_MAX_BOXES), NULL); 768 - } 769 - } 770 - } 771 - } 772 - 773 - if (poll_only) { 774 - // Poll only forces driver to only use polling and 775 - // to ignore the probed PCI or EISA interrupts. 776 - ip2config.irq[i] = CIR_POLL; 777 - } 778 - if ( ip2config.irq[i] == CIR_POLL ) { 779 - retry: 780 - if (!TimerOn) { 781 - PollTimer.expires = POLL_TIMEOUT; 782 - add_timer ( &PollTimer ); 783 - TimerOn = 1; 784 - printk( KERN_INFO "IP2: polling\n"); 785 - } 786 - } else { 787 - if (have_requested_irq(ip2config.irq[i])) 788 - continue; 789 - rc = request_irq( ip2config.irq[i], ip2_interrupt, 790 - IP2_SA_FLAGS | (ip2config.type[i] == PCI ? IRQF_SHARED : 0), 791 - pcName, i2BoardPtrTable[i]); 792 - if (rc) { 793 - printk(KERN_ERR "IP2: an request_irq failed: error %d\n",rc); 794 - ip2config.irq[i] = CIR_POLL; 795 - printk( KERN_INFO "IP2: Polling %ld/sec.\n", 796 - (POLL_TIMEOUT - jiffies)); 797 - goto retry; 798 - } 799 - mark_requested_irq(ip2config.irq[i]); 800 - /* Initialise the interrupt handler bottom half (aka slih). */ 801 - } 782 + for (box = 0; box < ABS_MAX_BOXES; box++) 783 + for (j = 0; j < ABS_BIGGEST_BOX; j++) 784 + if (pB->i2eChannelMap[box] & (1 << j)) 785 + tty_register_device( 786 + ip2_tty_driver, 787 + j + ABS_BIGGEST_BOX * 788 + (box+i*ABS_MAX_BOXES), 789 + NULL); 802 790 } 803 - for( i = 0; i < IP2_MAX_BOARDS; ++i ) { 804 - if ( i2BoardPtrTable[i] ) { 805 - set_irq( i, ip2config.irq[i] ); /* set and enable board interrupt */ 791 + 792 + if (poll_only) { 793 + /* Poll only forces driver to only use polling and 794 + to ignore the probed PCI or EISA interrupts. */ 795 + ip2config.irq[i] = CIR_POLL; 796 + } 797 + if (ip2config.irq[i] == CIR_POLL) { 798 + retry: 799 + if (!TimerOn) { 800 + PollTimer.expires = POLL_TIMEOUT; 801 + add_timer(&PollTimer); 802 + TimerOn = 1; 803 + printk(KERN_INFO "IP2: polling\n"); 806 804 } 805 + } else { 806 + if (have_requested_irq(ip2config.irq[i])) 807 + continue; 808 + rc = request_irq(ip2config.irq[i], ip2_interrupt, 809 + IP2_SA_FLAGS | 810 + (ip2config.type[i] == PCI ? IRQF_SHARED : 0), 811 + pcName, i2BoardPtrTable[i]); 812 + if (rc) { 813 + printk(KERN_ERR "IP2: request_irq failed: " 814 + "error %d\n", rc); 815 + ip2config.irq[i] = CIR_POLL; 816 + printk(KERN_INFO "IP2: Polling %ld/sec.\n", 817 + (POLL_TIMEOUT - jiffies)); 818 + goto retry; 819 + } 820 + mark_requested_irq(ip2config.irq[i]); 821 + /* Initialise the interrupt handler bottom half 822 + * (aka slih). */ 807 823 } 808 824 } 809 - ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0 ); 810 - goto out; 825 + 826 + for (i = 0; i < IP2_MAX_BOARDS; ++i) { 827 + if (i2BoardPtrTable[i]) { 828 + /* set and enable board interrupt */ 829 + set_irq(i, ip2config.irq[i]); 830 + } 831 + } 832 + 833 + ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0); 834 + 835 + return 0; 811 836 812 837 out_chrdev: 813 838 unregister_chrdev(IP2_IPL_MAJOR, "ip2"); 814 - out: 839 + /* unregister and put tty here */ 815 840 return err; 816 841 } 817 842 module_init(ip2_loadmain);