Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1ddfd95 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds
Browse files

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: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7ccd7020
Loading
Loading
Loading
Loading
+0 −32
Original line number Original line Diff line number Diff line
@@ -68,38 +68,6 @@ static DEFINE_RWLOCK(Dl_spinlock);
// iiInitialize
// iiInitialize
//=======================================================
//=======================================================


//******************************************************************************
// Function:   iiEllisInit()
// Parameters: None
//
// Returns:    Nothing
//
// Description:
//
// This routine performs any required initialization of the iiEllis subsystem.
//
//******************************************************************************
static void
iiEllisInit(void)
{
}

//******************************************************************************
// Function:   iiEllisCleanup()
// Parameters: None
//
// Returns:    Nothing
//
// Description:
//
// This routine performs any required cleanup of the iiEllis subsystem.
//
//******************************************************************************
static void
iiEllisCleanup(void)
{
}

//******************************************************************************
//******************************************************************************
// Function:   iiSetAddress(pB, address, delay)
// Function:   iiSetAddress(pB, address, delay)
// Parameters: pB      - pointer to the board structure
// Parameters: pB      - pointer to the board structure
+0 −2
Original line number Original line Diff line number Diff line
@@ -511,7 +511,6 @@ typedef void (*delayFunc_t)(unsigned int);
//
//
// Initialization of a board & structure is in four (five!) parts:
// Initialization of a board & structure is in four (five!) parts:
//
//
// 0) iiEllisInit()  - Initialize iiEllis subsystem.
// 1) iiSetAddress() - Define the board address & delay function for a board.
// 1) iiSetAddress() - Define the board address & delay function for a board.
// 2) iiReset()      - Reset the board   (provided it exists)
// 2) iiReset()      - Reset the board   (provided it exists)
//       -- Note you may do this to several boards --
//       -- Note you may do this to several boards --
@@ -523,7 +522,6 @@ typedef void (*delayFunc_t)(unsigned int);
// loadware.  To change loadware, you must begin again with step 2, resetting
// loadware.  To change loadware, you must begin again with step 2, resetting
// the board again (step 1 not needed).
// the board again (step 1 not needed).


static void iiEllisInit(void);
static int iiSetAddress(i2eBordStrPtr, int, delayFunc_t );
static int iiSetAddress(i2eBordStrPtr, int, delayFunc_t );
static int iiReset(i2eBordStrPtr);
static int iiReset(i2eBordStrPtr);
static int iiResetDelay(i2eBordStrPtr);
static int iiResetDelay(i2eBordStrPtr);
+198 −217
Original line number Original line Diff line number Diff line
@@ -314,28 +314,24 @@ MODULE_PARM_DESC(poll_only, "Do not use card interrupts");
/* for sysfs class support */
/* for sysfs class support */
static struct class *ip2_class;
static struct class *ip2_class;


// Some functions to keep track of what irq's we have
/* Some functions to keep track of what irqs we have */


static int
static int __init is_valid_irq(int irq)
is_valid_irq(int irq)
{
{
	int *i = Valid_Irqs;
	int *i = Valid_Irqs;
	
	
	while ((*i != 0) && (*i != irq)) {
	while (*i != 0 && *i != irq)
		i++;
		i++;
	}

	return (*i);
	return *i;
}
}


static void
static void __init mark_requested_irq(char irq)
mark_requested_irq( char irq )
{
{
	rirqs[iindx++] = irq;
	rirqs[iindx++] = irq;
}
}


#ifdef MODULE
static int __exit clear_requested_irq(char irq)
static int
clear_requested_irq( char irq )
{
{
	int i;
	int i;
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
@@ -346,17 +342,15 @@ clear_requested_irq( char irq )
	}
	}
	return 0;
	return 0;
}
}
#endif


static int
static int have_requested_irq(char irq)
have_requested_irq( char irq )
{
{
	// array init to zeros so 0 irq will not be requested as a side effect
	/* array init to zeros so 0 irq will not be requested as a side
	 * effect */
	int i;
	int i;
	for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i)
		if (rirqs[i] == irq)
		if (rirqs[i] == irq)
			return 1;
			return 1;
	}
	return 0;
	return 0;
}
}


@@ -380,9 +374,6 @@ static void __exit ip2_cleanup_module(void)
	int err;
	int err;
	int i;
	int i;


#ifdef IP2DEBUG_INIT
	printk (KERN_DEBUG "Unloading %s: version %s\n", pcName, pcVersion );
#endif
	/* Stop poll timer if we had one. */
	/* Stop poll timer if we had one. */
	if (TimerOn) {
	if (TimerOn) {
		del_timer(&PollTimer);
		del_timer(&PollTimer);
@@ -390,36 +381,37 @@ static void __exit ip2_cleanup_module(void)
	}
	}


	/* Reset the boards we have. */
	/* Reset the boards we have. */
	for( i = 0; i < IP2_MAX_BOARDS; ++i ) {
	for (i = 0; i < IP2_MAX_BOARDS; i++)
		if ( i2BoardPtrTable[i] ) {
		if (i2BoardPtrTable[i])
			iiReset(i2BoardPtrTable[i]);
			iiReset(i2BoardPtrTable[i]);
		}
	}


	/* The following is done at most once, if any boards were installed. */
	/* The following is done at most once, if any boards were installed. */
	for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
	for (i = 0; i < IP2_MAX_BOARDS; i++) {
		if (i2BoardPtrTable[i]) {
		if (i2BoardPtrTable[i]) {
			iiResetDelay(i2BoardPtrTable[i]);
			iiResetDelay(i2BoardPtrTable[i]);
			/* free io addresses and Tibet */
			/* free io addresses and Tibet */
			release_region(ip2config.addr[i], 8);
			release_region(ip2config.addr[i], 8);
			device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
			device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
			device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
			device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR,
						4 * i + 1));
		}
		}
		/* Disable and remove interrupt handler. */
		/* Disable and remove interrupt handler. */
		if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) {	
		if (ip2config.irq[i] > 0 &&
				have_requested_irq(ip2config.irq[i])) {
			free_irq(ip2config.irq[i], (void *)&pcName);
			free_irq(ip2config.irq[i], (void *)&pcName);
			clear_requested_irq(ip2config.irq[i]);
			clear_requested_irq(ip2config.irq[i]);
		}
		}
	}
	}
	class_destroy(ip2_class);
	class_destroy(ip2_class);
	if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) {
	err = tty_unregister_driver(ip2_tty_driver);
		printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err);
	if (err)
	}
		printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n",
				err);
	put_tty_driver(ip2_tty_driver);
	put_tty_driver(ip2_tty_driver);
	unregister_chrdev(IP2_IPL_MAJOR, pcIpl);
	unregister_chrdev(IP2_IPL_MAJOR, pcIpl);
	remove_proc_entry("ip2mem", NULL);
	remove_proc_entry("ip2mem", NULL);


	// free memory
	/* free memory */
	for (i = 0; i < IP2_MAX_BOARDS; i++) {
	for (i = 0; i < IP2_MAX_BOARDS; i++) {
		void *pB;
		void *pB;
#ifdef CONFIG_PCI
#ifdef CONFIG_PCI
@@ -434,17 +426,11 @@ static void __exit ip2_cleanup_module(void)
			kfree(pB);
			kfree(pB);
			i2BoardPtrTable[i] = NULL;
			i2BoardPtrTable[i] = NULL;
		}
		}
		if ((DevTableMem[i]) != NULL ) {
		if (DevTableMem[i] != NULL) {
			kfree(DevTableMem[i]);
			kfree(DevTableMem[i]);
			DevTableMem[i] = NULL;
			DevTableMem[i] = NULL;
		}
		}
	}
	}

	/* Cleanup the iiEllis subsystem. */
	iiEllisCleanup();
#ifdef IP2DEBUG_INIT
	printk (KERN_DEBUG "IP2 Unloaded\n" );
#endif
}
}
module_exit(ip2_cleanup_module);
module_exit(ip2_cleanup_module);


@@ -552,14 +538,13 @@ static int __init ip2_setup(char *str)
__setup("ip2=", ip2_setup);
__setup("ip2=", ip2_setup);
#endif /* !MODULE */
#endif /* !MODULE */


static int ip2_loadmain(void)
static int __init ip2_loadmain(void)
{
{
	int i, j, box;
	int i, j, box;
	int err = 0;
	int err = 0;
	static int loaded;
	i2eBordStrPtr pB = NULL;
	i2eBordStrPtr pB = NULL;
	int rc = -1;
	int rc = -1;
	static struct pci_dev *pci_dev_i = NULL;
	struct pci_dev *pdev = NULL;
	const struct firmware *fw = NULL;
	const struct firmware *fw = NULL;


	if (poll_only) {
	if (poll_only) {
@@ -579,17 +564,18 @@ static int ip2_loadmain(void)
			ip2config.irq[i] = irq[i];
			ip2config.irq[i] = irq[i];
		else
		else
			ip2config.irq[i] = 0;
			ip2config.irq[i] = 0;
	// This is a little bit of a hack.  If poll_only=1 on command
	/* This is a little bit of a hack.  If poll_only=1 on command
	// line back in ip2.c OR all IRQs on all specified boards are
	   line back in ip2.c OR all IRQs on all specified boards are
	// explicitly set to 0, then drop to poll only mode and override
	   explicitly set to 0, then drop to poll only mode and override
	// PCI or EISA interrupts.  This superceeds the old hack of
	   PCI or EISA interrupts.  This superceeds the old hack of
	// triggering if all interrupts were zero (like da default).
	   triggering if all interrupts were zero (like da default).
	// Still a hack but less prone to random acts of terrorism.
	   Still a hack but less prone to random acts of terrorism.
	//

	// What we really should do, now that the IRQ default is set
	   What we really should do, now that the IRQ default is set
	// to -1, is to use 0 as a hard coded, do not probe.
	   to -1, is to use 0 as a hard coded, do not probe.
	//

	//	/\/\|=mhw=|\/\/
		/\/\|=mhw=|\/\/
	*/
		poll_only |= irq[i];
		poll_only |= irq[i];
	}
	}
	poll_only = !poll_only;
	poll_only = !poll_only;
@@ -597,22 +583,10 @@ static int ip2_loadmain(void)
	/* Announce our presence */
	/* Announce our presence */
	printk(KERN_INFO "%s version %s\n", pcName, pcVersion);
	printk(KERN_INFO "%s version %s\n", pcName, pcVersion);


	// ip2 can be unloaded and reloaded for no good reason
	// we can't let that happen here or bad things happen
	// second load hoses board but not system - fixme later
	if (loaded) {
		printk( KERN_INFO "Still loaded\n" );
		return 0;
	}
	loaded++;

	ip2_tty_driver = alloc_tty_driver(IP2_MAX_PORTS);
	ip2_tty_driver = alloc_tty_driver(IP2_MAX_PORTS);
	if (!ip2_tty_driver)
	if (!ip2_tty_driver)
		return -ENOMEM;
		return -ENOMEM;


	/* Initialise the iiEllis subsystem. */
	iiEllisInit();

	/* Initialise all the boards we can find (up to the maximum). */
	/* Initialise all the boards we can find (up to the maximum). */
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
		switch (ip2config.addr[i]) {
		switch (ip2config.addr[i]) {
@@ -620,66 +594,66 @@ static int ip2_loadmain(void)
			break;
			break;
		default: /* ISA */
		default: /* ISA */
		   /* ISA address must be specified */
		   /* ISA address must be specified */
			if ( (ip2config.addr[i] < 0x100) || (ip2config.addr[i] > 0x3f8) ) {
			if (ip2config.addr[i] < 0x100 ||
				printk ( KERN_ERR "IP2: Bad ISA board %d address %x\n",
					ip2config.addr[i] > 0x3f8) {
							 i, ip2config.addr[i] );
				printk(KERN_ERR "IP2: Bad ISA board %d "
						"address %x\n", i,
						ip2config.addr[i]);
				ip2config.addr[i] = 0;
				ip2config.addr[i] = 0;
			} else {
				break;
			}
			ip2config.type[i] = ISA;
			ip2config.type[i] = ISA;


				/* Check for valid irq argument, set for polling if invalid */
			/* Check for valid irq argument, set for polling if
				if (ip2config.irq[i] && !is_valid_irq(ip2config.irq[i])) {
			 * invalid */
					printk(KERN_ERR "IP2: Bad IRQ(%d) specified\n",ip2config.irq[i]);
			if (ip2config.irq[i] &&
					ip2config.irq[i] = 0;// 0 is polling and is valid in that sense
					!is_valid_irq(ip2config.irq[i])) {
				}
				printk(KERN_ERR "IP2: Bad IRQ(%d) specified\n",
						ip2config.irq[i]);
				/* 0 is polling and is valid in that sense */
				ip2config.irq[i] = 0;
			}
			}
			break;
			break;
		case PCI:
		case PCI:
#ifdef CONFIG_PCI
#ifdef CONFIG_PCI
		{
		{
			u32 addr;
			int status;
			int status;


				pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
			pdev = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
							  PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
					PCI_DEVICE_ID_COMPUTONE_IP2EX, pdev);
				if (pci_dev_i != NULL) {
			if (pdev == NULL) {
					unsigned int addr;
				ip2config.addr[i] = 0;
				printk(KERN_ERR "IP2: PCI board %d not "
						"found\n", i);
				break;
			}


					if (pci_enable_device(pci_dev_i)) {
			if (pci_enable_device(pdev)) {
						printk( KERN_ERR "IP2: can't enable PCI device at %s\n",
				dev_err(&pdev->dev, "can't enable device\n");
							pci_name(pci_dev_i));
				break;
				break;
			}
			}
			ip2config.type[i] = PCI;
			ip2config.type[i] = PCI;
					ip2config.pci_dev[i] = pci_dev_get(pci_dev_i);
			ip2config.pci_dev[i] = pci_dev_get(pdev);
					status =
			status = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_1,
					pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr);
					&addr);
					if ( addr & 1 ) {
			if (addr & 1)
				ip2config.addr[i] = (USHORT)(addr & 0xfffe);
				ip2config.addr[i] = (USHORT)(addr & 0xfffe);
					} else {
			else
						printk( KERN_ERR "IP2: PCI I/O address error\n");
				dev_err(&pdev->dev, "I/O address error\n");
					}

//		If the PCI BIOS assigned it, lets try and use it.  If we
//		can't acquire it or it screws up, deal with it then.


//					if (!is_valid_irq(pci_irq)) {
			ip2config.irq[i] = pdev->irq;
//						printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq);
//						pci_irq = 0;
//					}
					ip2config.irq[i] = pci_dev_i->irq;
				} else {	// ann error
					ip2config.addr[i] = 0;
					printk(KERN_ERR "IP2: PCI board %d not found\n", i);
				} 
		}
		}
#else
#else
			printk( KERN_ERR "IP2: PCI card specified but PCI support not\n");
			printk(KERN_ERR "IP2: PCI card specified but PCI "
			printk( KERN_ERR "IP2: configured in this kernel.\n");
					"support not enabled.\n");
			printk( KERN_ERR "IP2: Recompile kernel with CONFIG_PCI defined!\n");
			printk(KERN_ERR "IP2: Recompile kernel with CONFIG_PCI "
					"defined!\n");
#endif /* CONFIG_PCI */
#endif /* CONFIG_PCI */
			break;
			break;
		case EISA:
		case EISA:
			if ( (ip2config.addr[i] = find_eisa_board( Eisa_slot + 1 )) != 0) {
			ip2config.addr[i] = find_eisa_board(Eisa_slot + 1);
			if (ip2config.addr[i] != 0) {
				/* Eisa_irq set as side effect, boo */
				/* Eisa_irq set as side effect, boo */
				ip2config.type[i] = EISA;
				ip2config.type[i] = EISA;
			} 
			} 
@@ -687,23 +661,24 @@ static int ip2_loadmain(void)
			break;
			break;
		}	/* switch */
		}	/* switch */
	}	/* for */
	}	/* for */
	if (pci_dev_i)
	pci_dev_put(pdev);
		pci_dev_put(pci_dev_i);


	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
		if (ip2config.addr[i]) {
		if (ip2config.addr[i]) {
			pB = kzalloc(sizeof(i2eBordStr), GFP_KERNEL);
			pB = kzalloc(sizeof(i2eBordStr), GFP_KERNEL);
			if (pB) {
			if (pB) {
				i2BoardPtrTable[i] = pB;
				i2BoardPtrTable[i] = pB;
				iiSetAddress( pB, ip2config.addr[i], ii2DelayTimer );
				iiSetAddress(pB, ip2config.addr[i],
						ii2DelayTimer);
				iiReset(pB);
				iiReset(pB);
			} else {
			} else
				printk(KERN_ERR "IP2: board memory allocation error\n");
				printk(KERN_ERR "IP2: board memory allocation "
			}
						"error\n");
		}
		}
	}
	}
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
		if ( ( pB = i2BoardPtrTable[i] ) != NULL ) {
		pB = i2BoardPtrTable[i];
		if (pB != NULL) {
			iiResetDelay(pB);
			iiResetDelay(pB);
			break;
			break;
		}
		}
@@ -733,20 +708,23 @@ static int ip2_loadmain(void)
	ip2_tty_driver->subtype              = SERIAL_TYPE_NORMAL;
	ip2_tty_driver->subtype              = SERIAL_TYPE_NORMAL;
	ip2_tty_driver->init_termios         = tty_std_termios;
	ip2_tty_driver->init_termios         = tty_std_termios;
	ip2_tty_driver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
	ip2_tty_driver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
	ip2_tty_driver->flags                = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
	ip2_tty_driver->flags                = TTY_DRIVER_REAL_RAW |
		TTY_DRIVER_DYNAMIC_DEV;
	tty_set_operations(ip2_tty_driver, &ip2_ops);
	tty_set_operations(ip2_tty_driver, &ip2_ops);


	ip2trace(ITRC_NO_PORT, ITRC_INIT, 3, 0);
	ip2trace(ITRC_NO_PORT, ITRC_INIT, 3, 0);


	/* Register the tty devices. */
	err = tty_register_driver(ip2_tty_driver);
	if ( ( err = tty_register_driver ( ip2_tty_driver ) ) ) {
	if (err) {
		printk(KERN_ERR "IP2: failed to register tty driver (%d)\n", err);
		printk(KERN_ERR "IP2: failed to register tty driver\n");
		put_tty_driver(ip2_tty_driver);
		put_tty_driver(ip2_tty_driver);
		return -EINVAL;
		return err; /* leaking resources */
	} else
	}
	/* Register the IPL driver. */

	if ( ( err = register_chrdev ( IP2_IPL_MAJOR, pcIpl, &ip2_ipl ) ) ) {
	err = register_chrdev(IP2_IPL_MAJOR, pcIpl, &ip2_ipl);
		printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err );
	if (err) {
		printk(KERN_ERR "IP2: failed to register IPL device (%d)\n",
				err);
	} else {
	} else {
		/* create the sysfs class */
		/* create the sysfs class */
		ip2_class = class_create(THIS_MODULE, "ip2");
		ip2_class = class_create(THIS_MODULE, "ip2");
@@ -758,7 +736,8 @@ static int ip2_loadmain(void)
	/* Register the read_procmem thing */
	/* Register the read_procmem thing */
	if (!proc_create("ip2mem",0,NULL,&ip2mem_proc_fops)) {
	if (!proc_create("ip2mem",0,NULL,&ip2mem_proc_fops)) {
		printk(KERN_ERR "IP2: failed to register read_procmem\n");
		printk(KERN_ERR "IP2: failed to register read_procmem\n");
	} else {
		return -EIO; /* leaking resources */
	}


	ip2trace(ITRC_NO_PORT, ITRC_INIT, 4, 0);
	ip2trace(ITRC_NO_PORT, ITRC_INIT, 4, 0);
	/* Register the interrupt handler or poll handler, depending upon the
	/* Register the interrupt handler or poll handler, depending upon the
@@ -766,11 +745,11 @@ static int ip2_loadmain(void)
	 */
	 */


	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
			if ( 0 == ip2config.addr[i] ) {
		if (ip2config.addr[i] == 0)
			continue;
			continue;
			}


			if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
		pB = i2BoardPtrTable[i];
		if (pB != NULL) {
			device_create_drvdata(ip2_class, NULL,
			device_create_drvdata(ip2_class, NULL,
					      MKDEV(IP2_IPL_MAJOR, 4 * i),
					      MKDEV(IP2_IPL_MAJOR, 4 * i),
					      NULL, "ipl%d", i);
					      NULL, "ipl%d", i);
@@ -778,23 +757,19 @@ static int ip2_loadmain(void)
					      MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
					      MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
					      NULL, "stat%d", i);
					      NULL, "stat%d", i);


			    for ( box = 0; box < ABS_MAX_BOXES; ++box )
			for (box = 0; box < ABS_MAX_BOXES; box++)
			    {
				for (j = 0; j < ABS_BIGGEST_BOX; j++)
			        for ( j = 0; j < ABS_BIGGEST_BOX; ++j )
			        {
					if (pB->i2eChannelMap[box] & (1 << j))
					if (pB->i2eChannelMap[box] & (1 << j))
				    {
						tty_register_device(
				        tty_register_device(ip2_tty_driver,
							ip2_tty_driver,
							j + ABS_BIGGEST_BOX *
							j + ABS_BIGGEST_BOX *
						    (box+i*ABS_MAX_BOXES), NULL);
							(box+i*ABS_MAX_BOXES),
			    	    }
							NULL);
			        }
			    }
		}
		}


		if (poll_only) {
		if (poll_only) {
//		Poll only forces driver to only use polling and
			/* Poll only forces driver to only use polling and
//		to ignore the probed PCI or EISA interrupts.
			   to ignore the probed PCI or EISA interrupts. */
			ip2config.irq[i] = CIR_POLL;
			ip2config.irq[i] = CIR_POLL;
		}
		}
		if (ip2config.irq[i] == CIR_POLL) {
		if (ip2config.irq[i] == CIR_POLL) {
@@ -809,31 +784,37 @@ static int ip2_loadmain(void)
			if (have_requested_irq(ip2config.irq[i]))
			if (have_requested_irq(ip2config.irq[i]))
				continue;
				continue;
			rc = request_irq(ip2config.irq[i], ip2_interrupt,
			rc = request_irq(ip2config.irq[i], ip2_interrupt,
					IP2_SA_FLAGS | (ip2config.type[i] == PCI ? IRQF_SHARED : 0),
				IP2_SA_FLAGS |
				(ip2config.type[i] == PCI ? IRQF_SHARED : 0),
				pcName, i2BoardPtrTable[i]);
				pcName, i2BoardPtrTable[i]);
			if (rc) {
			if (rc) {
					printk(KERN_ERR "IP2: an request_irq failed: error %d\n",rc);
				printk(KERN_ERR "IP2: request_irq failed: "
						"error %d\n", rc);
				ip2config.irq[i] = CIR_POLL;
				ip2config.irq[i] = CIR_POLL;
				printk(KERN_INFO "IP2: Polling %ld/sec.\n",
				printk(KERN_INFO "IP2: Polling %ld/sec.\n",
						(POLL_TIMEOUT - jiffies));
						(POLL_TIMEOUT - jiffies));
				goto retry;
				goto retry;
			}
			}
			mark_requested_irq(ip2config.irq[i]);
			mark_requested_irq(ip2config.irq[i]);
				/* Initialise the interrupt handler bottom half (aka slih). */
			/* Initialise the interrupt handler bottom half
			 * (aka slih). */
		}
		}
	}
	}

	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
		if (i2BoardPtrTable[i]) {
		if (i2BoardPtrTable[i]) {
				set_irq( i, ip2config.irq[i] ); /* set and enable board interrupt */
			/* set and enable board interrupt */
			}
			set_irq(i, ip2config.irq[i]);
		}
		}
	}
	}

	ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0);
	ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0);
	goto out;

	return 0;


out_chrdev:
out_chrdev:
	unregister_chrdev(IP2_IPL_MAJOR, "ip2");
	unregister_chrdev(IP2_IPL_MAJOR, "ip2");
out:
	/* unregister and put tty here */
	return err;
	return err;
}
}
module_init(ip2_loadmain);
module_init(ip2_loadmain);