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

Char: merge ip2main and ip2base

It's pretty useless to have one setup() function separated along with
module_init() which only calls a function from ip2main anyway. Get rid
of ip2base.

Remove also checks of always-true now.

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
47babd4c 1361b7d3

+77 -125
+1 -1
drivers/char/ip2/Makefile
··· 4 4 5 5 obj-$(CONFIG_COMPUTONE) += ip2.o 6 6 7 - ip2-objs := ip2base.o ip2main.o 7 + ip2-objs := ip2main.o 8 8
-108
drivers/char/ip2/ip2base.c
··· 1 - // ip2.c 2 - // This is a dummy module to make the firmware available when needed 3 - // and allows it to be unloaded when not. Rumor is the __initdata 4 - // macro doesn't always works on all platforms so we use this kludge. 5 - // If not compiled as a module it just makes fip_firm avaliable then 6 - // __initdata should work as advertized 7 - // 8 - 9 - #include <linux/module.h> 10 - #include <linux/init.h> 11 - #include <linux/wait.h> 12 - 13 - #ifndef __init 14 - #define __init 15 - #endif 16 - #ifndef __initfunc 17 - #define __initfunc(a) a 18 - #endif 19 - #ifndef __initdata 20 - #define __initdata 21 - #endif 22 - 23 - #include "ip2types.h" 24 - 25 - int 26 - ip2_loadmain(int *, int *); // ref into ip2main.c 27 - 28 - /* Note: Add compiled in defaults to these arrays, not to the structure 29 - in ip2.h any longer. That structure WILL get overridden 30 - by these values, or command line values, or insmod values!!! =mhw= 31 - */ 32 - static int io[IP2_MAX_BOARDS]= { 0, 0, 0, 0 }; 33 - static int irq[IP2_MAX_BOARDS] = { -1, -1, -1, -1 }; 34 - 35 - static int poll_only = 0; 36 - 37 - MODULE_AUTHOR("Doug McNash"); 38 - MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); 39 - module_param_array(irq, int, NULL, 0); 40 - MODULE_PARM_DESC(irq,"Interrupts for IntelliPort Cards"); 41 - module_param_array(io, int, NULL, 0); 42 - MODULE_PARM_DESC(io,"I/O ports for IntelliPort Cards"); 43 - module_param(poll_only, bool, 0); 44 - MODULE_PARM_DESC(poll_only,"Do not use card interrupts"); 45 - 46 - 47 - static int __init ip2_init(void) 48 - { 49 - if( poll_only ) { 50 - /* Hard lock the interrupts to zero */ 51 - irq[0] = irq[1] = irq[2] = irq[3] = 0; 52 - } 53 - 54 - return ip2_loadmain(io, irq); 55 - } 56 - module_init(ip2_init); 57 - 58 - MODULE_LICENSE("GPL"); 59 - 60 - #ifndef MODULE 61 - /****************************************************************************** 62 - * ip2_setup: 63 - * str: kernel command line string 64 - * 65 - * Can't autoprobe the boards so user must specify configuration on 66 - * kernel command line. Sane people build it modular but the others 67 - * come here. 68 - * 69 - * Alternating pairs of io,irq for up to 4 boards. 70 - * ip2=io0,irq0,io1,irq1,io2,irq2,io3,irq3 71 - * 72 - * io=0 => No board 73 - * io=1 => PCI 74 - * io=2 => EISA 75 - * else => ISA I/O address 76 - * 77 - * irq=0 or invalid for ISA will revert to polling mode 78 - * 79 - * Any value = -1, do not overwrite compiled in value. 80 - * 81 - ******************************************************************************/ 82 - static int __init ip2_setup(char *str) 83 - { 84 - int ints[10]; /* 4 boards, 2 parameters + 2 */ 85 - int i, j; 86 - 87 - str = get_options (str, ARRAY_SIZE(ints), ints); 88 - 89 - for( i = 0, j = 1; i < 4; i++ ) { 90 - if( j > ints[0] ) { 91 - break; 92 - } 93 - if( ints[j] >= 0 ) { 94 - io[i] = ints[j]; 95 - } 96 - j++; 97 - if( j > ints[0] ) { 98 - break; 99 - } 100 - if( ints[j] >= 0 ) { 101 - irq[i] = ints[j]; 102 - } 103 - j++; 104 - } 105 - return 1; 106 - } 107 - __setup("ip2=", ip2_setup); 108 - #endif /* !MODULE */
+76 -16
drivers/char/ip2/ip2main.c
··· 157 157 static char *pcDriver_name = "ip2"; 158 158 static char *pcIpl = "ip2ipl"; 159 159 160 - // cheezy kludge or genius - you decide? 161 - int ip2_loadmain(int *, int *); 162 - 163 160 /***********************/ 164 161 /* Function Prototypes */ 165 162 /***********************/ ··· 284 287 285 288 MODULE_AUTHOR("Doug McNash"); 286 289 MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); 290 + MODULE_LICENSE("GPL"); 287 291 288 292 static int poll_only = 0; 289 293 ··· 294 296 static int iindx; 295 297 static char rirqs[IP2_MAX_BOARDS]; 296 298 static int Valid_Irqs[] = { 3, 4, 5, 7, 10, 11, 12, 15, 0}; 299 + 300 + /* Note: Add compiled in defaults to these arrays, not to the structure 301 + in ip2.h any longer. That structure WILL get overridden 302 + by these values, or command line values, or insmod values!!! =mhw= 303 + */ 304 + static int io[IP2_MAX_BOARDS]; 305 + static int irq[IP2_MAX_BOARDS] = { -1, -1, -1, -1 }; 306 + 307 + MODULE_AUTHOR("Doug McNash"); 308 + MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); 309 + module_param_array(irq, int, NULL, 0); 310 + MODULE_PARM_DESC(irq, "Interrupts for IntelliPort Cards"); 311 + module_param_array(io, int, NULL, 0); 312 + MODULE_PARM_DESC(io, "I/O ports for IntelliPort Cards"); 313 + module_param(poll_only, bool, 0); 314 + MODULE_PARM_DESC(poll_only, "Do not use card interrupts"); 297 315 298 316 /* for sysfs class support */ 299 317 static struct class *ip2_class; ··· 508 494 return fw; 509 495 } 510 496 511 - int 512 - ip2_loadmain(int *iop, int *irqp) 497 + #ifndef MODULE 498 + /****************************************************************************** 499 + * ip2_setup: 500 + * str: kernel command line string 501 + * 502 + * Can't autoprobe the boards so user must specify configuration on 503 + * kernel command line. Sane people build it modular but the others 504 + * come here. 505 + * 506 + * Alternating pairs of io,irq for up to 4 boards. 507 + * ip2=io0,irq0,io1,irq1,io2,irq2,io3,irq3 508 + * 509 + * io=0 => No board 510 + * io=1 => PCI 511 + * io=2 => EISA 512 + * else => ISA I/O address 513 + * 514 + * irq=0 or invalid for ISA will revert to polling mode 515 + * 516 + * Any value = -1, do not overwrite compiled in value. 517 + * 518 + ******************************************************************************/ 519 + static int __init ip2_setup(char *str) 520 + { 521 + int j, ints[10]; /* 4 boards, 2 parameters + 2 */ 522 + unsigned int i; 523 + 524 + str = get_options(str, ARRAY_SIZE(ints), ints); 525 + 526 + for (i = 0, j = 1; i < 4; i++) { 527 + if (j > ints[0]) 528 + break; 529 + if (ints[j] >= 0) 530 + io[i] = ints[j]; 531 + j++; 532 + if (j > ints[0]) 533 + break; 534 + if (ints[j] >= 0) 535 + irq[i] = ints[j]; 536 + j++; 537 + } 538 + return 1; 539 + } 540 + __setup("ip2=", ip2_setup); 541 + #endif /* !MODULE */ 542 + 543 + static int ip2_loadmain(void) 513 544 { 514 545 int i, j, box; 515 546 int err = 0; ··· 564 505 static struct pci_dev *pci_dev_i = NULL; 565 506 const struct firmware *fw = NULL; 566 507 508 + if (poll_only) { 509 + /* Hard lock the interrupts to zero */ 510 + irq[0] = irq[1] = irq[2] = irq[3] = poll_only = 0; 511 + } 512 + 567 513 ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0 ); 568 514 569 515 /* process command line arguments to modprobe or ··· 576 512 /* irqp and iop should ALWAYS be specified now... But we check 577 513 them individually just to be sure, anyways... */ 578 514 for ( i = 0; i < IP2_MAX_BOARDS; ++i ) { 579 - if (iop) { 580 - ip2config.addr[i] = iop[i]; 581 - if (irqp) { 582 - if( irqp[i] >= 0 ) { 583 - ip2config.irq[i] = irqp[i]; 584 - } else { 585 - ip2config.irq[i] = 0; 586 - } 515 + ip2config.addr[i] = io[i]; 516 + if (irq[i] >= 0) 517 + ip2config.irq[i] = irq[i]; 518 + else 519 + ip2config.irq[i] = 0; 587 520 // This is a little bit of a hack. If poll_only=1 on command 588 521 // line back in ip2.c OR all IRQs on all specified boards are 589 522 // explicitly set to 0, then drop to poll only mode and override ··· 592 531 // to -1, is to use 0 as a hard coded, do not probe. 593 532 // 594 533 // /\/\|=mhw=|\/\/ 595 - poll_only |= irqp[i]; 596 - } 597 - } 534 + poll_only |= irq[i]; 598 535 } 599 536 poll_only = !poll_only; 600 537 ··· 842 783 out: 843 784 return err; 844 785 } 786 + module_init(ip2_loadmain); 845 787 846 788 /******************************************************************************/ 847 789 /* Function: ip2_init_board() */