 mxvar_sdriver->open = mxser_open; mxvar_sdriver->close = mxser_close; mxvar_sdriver->write = mxser_write; mxvar_sdriver->put_char = mxser_put_char; mxvar_sdriver->flush_chars = mxser_flush_chars; mxvar_sdriver->write_room = mxser_write_room; mxvar_sdriver->chars_in_buffer = mxser_chars_in_buffer; mxvar_sdriver->flush_buffer = mxser_flush_buffer; mxvar_sdriver->ioctl = mxser_ioctl; mxvar_sdriver->throttle = mxser_throttle; mxvar_sdriver->unthrottle = mxser_unthrottle; mxvar_sdriver->set_termios = mxser_set_termios; mxvar_sdriver->stop = mxser_stop; mxvar_sdriver->start = mxser_start; mxvar_sdriver->hangup = mxser_hangup; mxvar_sdriver->break_ctl = mxser_rs_break; mxvar_sdriver->wait_until_sent = mxser_wait_until_sent; 
static int mxser_init(void){	int i, m, retval, b, n;	int ret1;	struct pci_dev *pdev = NULL;	int index;	unsigned char busnum, devnum;	struct mxser_hwconf hwconf;	mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);	if (!mxvar_sdriver)		return -ENOMEM;	spin_lock_init(&gm_lock);	for (i = 0; i < MXSER_BOARDS; i++) {		mxsercfg[i].board_type = -1;	}	printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", MXSER_VERSION);	/* Initialize the tty_driver structure */	memset(mxvar_sdriver, 0, sizeof(struct tty_driver));	mxvar_sdriver->magic = TTY_DRIVER_MAGIC;	mxvar_sdriver->name = "ttyM";	mxvar_sdriver->major = ttymajor;	mxvar_sdriver->minor_start = 0;	mxvar_sdriver->num = MXSER_PORTS + 1;	mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;	mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;	mxvar_sdriver->init_termios = tty_std_termios;	mxvar_sdriver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;	mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW;	tty_set_operations(mxvar_sdriver, &mxser_ops);	mxvar_sdriver->ttys = mxvar_tty;	mxvar_sdriver->termios = mxvar_termios;	mxvar_sdriver->termios_locked = mxvar_termios_locked;	mxvar_sdriver->open = mxser_open;	mxvar_sdriver->close = mxser_close;	mxvar_sdriver->write = mxser_write;	mxvar_sdriver->put_char = mxser_put_char;	mxvar_sdriver->flush_chars = mxser_flush_chars;	mxvar_sdriver->write_room = mxser_write_room;	mxvar_sdriver->chars_in_buffer = mxser_chars_in_buffer;	mxvar_sdriver->flush_buffer = mxser_flush_buffer;	mxvar_sdriver->ioctl = mxser_ioctl;	mxvar_sdriver->throttle = mxser_throttle;	mxvar_sdriver->unthrottle = mxser_unthrottle;	mxvar_sdriver->set_termios = mxser_set_termios;	mxvar_sdriver->stop = mxser_stop;	mxvar_sdriver->start = mxser_start;	mxvar_sdriver->hangup = mxser_hangup;	mxvar_sdriver->break_ctl = mxser_rs_break;	mxvar_sdriver->wait_until_sent = mxser_wait_until_sent;	mxvar_diagflag = 0;	memset(mxvar_table, 0, MXSER_PORTS * sizeof(struct mxser_struct));	memset(&mxvar_log, 0, sizeof(struct mxser_log));	memset(&mxser_msr, 0, sizeof(unsigned char) * (MXSER_PORTS + 1));	memset(&mon_data_ext, 0, sizeof(struct mxser_mon_ext));	memset(&mxser_set_baud_method, 0, sizeof(int) * (MXSER_PORTS + 1));	memset(&hwconf, 0, sizeof(struct mxser_hwconf));	m = 0;	/* Start finding ISA boards here */	for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) {		int cap;		if (!(cap = mxserBoardCAP[b]))			continue;		retval = mxser_get_ISA_conf(cap, &hwconf);		if (retval != 0)			printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]);		if (retval <= 0) {			if (retval == MXSER_ERR_IRQ)				printk(KERN_ERR "Invalid interrupt number,board not configured\n");			else if (retval == MXSER_ERR_IRQ_CONFLIT)				printk(KERN_ERR "Invalid interrupt number,board not configured\n");			else if (retval == MXSER_ERR_VECTOR)				printk(KERN_ERR "Invalid interrupt vector,board not configured\n");			else if (retval == MXSER_ERR_IOADDR)				printk(KERN_ERR "Invalid I/O address,board not configured\n");			continue;		}		hwconf.pciInfo.busNum = 0;		hwconf.pciInfo.devNum = 0;		hwconf.pciInfo.pdev = NULL;		mxser_getcfg(m, &hwconf);		//init mxsercfg first, or mxsercfg data is not correct on ISR.		//mxser_initbrd will hook ISR.		if (mxser_initbrd(m, &hwconf) < 0)			continue;		m++;	}	/* Start finding ISA boards from module arg */	for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) {		int cap;		if (!(cap = ioaddr[b]))			continue;		retval = mxser_get_ISA_conf(cap, &hwconf);		if (retval != 0)			printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]);		if (retval <= 0) {			if (retval == MXSER_ERR_IRQ)				printk(KERN_ERR "Invalid interrupt number,board not configured\n");			else if (retval == MXSER_ERR_IRQ_CONFLIT)				printk(KERN_ERR "Invalid interrupt number,board not configured\n");			else if (retval == MXSER_ERR_VECTOR)				printk(KERN_ERR "Invalid interrupt vector,board not configured\n");			else if (retval == MXSER_ERR_IOADDR)				printk(KERN_ERR "Invalid I/O address,board not configured\n");			continue;		}		hwconf.pciInfo.busNum = 0;		hwconf.pciInfo.devNum = 0;		hwconf.pciInfo.pdev = NULL;		mxser_getcfg(m, &hwconf);		//init mxsercfg first, or mxsercfg data is not correct on ISR.		//mxser_initbrd will hook ISR.		if (mxser_initbrd(m, &hwconf) < 0)			continue;		m++;	}	/* start finding PCI board here */#ifdef CONFIG_PCI	n = (sizeof(mxser_pcibrds) / sizeof(mxser_pcibrds[0])) - 1;	index = 0;	b = 0;	while (b < n) {		pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev);			if (pdev == NULL) {			b++;			continue;		}		hwconf.pciInfo.busNum = busnum = pdev->bus->number;		hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3;		hwconf.pciInfo.pdev = pdev;		printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], busnum, devnum >> 3);		index++;		if (m >= MXSER_BOARDS) {			printk(KERN_ERR "Too many Smartio/Industio family boards find (maximum %d),board not configured\n", MXSER_BOARDS);		} else {			if (pci_enable_device(pdev)) {				printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n");				continue;			}			retval = mxser_get_PCI_conf(busnum, devnum, (int) mxser_pcibrds[b].driver_data, &hwconf);			if (retval < 0) {				if (retval == MXSER_ERR_IRQ)					printk(KERN_ERR "Invalid interrupt number,board not configured\n");				else if (retval == MXSER_ERR_IRQ_CONFLIT)					printk(KERN_ERR "Invalid interrupt number,board not configured\n");				else if (retval == MXSER_ERR_VECTOR)					printk(KERN_ERR "Invalid interrupt vector,board not configured\n");				else if (retval == MXSER_ERR_IOADDR)					printk(KERN_ERR "Invalid I/O address,board not configured\n");				continue;			}			mxser_getcfg(m, &hwconf);			//init mxsercfg first, or mxsercfg data is not correct on ISR.			//mxser_initbrd will hook ISR.			if (mxser_initbrd(m, &hwconf) < 0)				continue;			m++;		}	}#endif	ret1 = 0;	if (!(ret1 = tty_register_driver(mxvar_sdriver))) {		return 0;	} else		printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n");	if (ret1) {		for (i = 0; i < MXSER_BOARDS; i++) {			if (mxsercfg[i].board_type == -1)				continue;			else {				free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);				//todo: release io, vector			}		}		return -1;	}	return (0);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/57432345b644ef92dcd0a378db6bc40ab0e7f314/mxser.c/clean/drivers/char/mxser.c