#if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938) wordlength = 1; #endif  
static int __init ne_probe1(struct net_device *dev, int ioaddr){	int i;	unsigned char SA_prom[32];	int wordlength = 2;	const char *name = NULL;	int start_page, stop_page;	int neX000, ctron, copam, bad_card;	int reg0, ret;	static unsigned version_printed;	if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))		return -EBUSY;	reg0 = inb_p(ioaddr);	if (reg0 == 0xFF) {		ret = -ENODEV;		goto err_out;	}	/* Do a preliminary verification that we have a 8390. */	{		int regd;		outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);		regd = inb_p(ioaddr + 0x0d);		outb_p(0xff, ioaddr + 0x0d);		outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);		inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */		if (inb_p(ioaddr + EN0_COUNTER0) != 0) {			outb_p(reg0, ioaddr);			outb_p(regd, ioaddr + 0x0d);	/* Restore the old values. */			ret = -ENODEV;			goto err_out;		}	}	if (ei_debug  &&  version_printed++ == 0)		printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2);	printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr);	/* A user with a poor card that fails to ack the reset, or that	   does not have a valid 0x57,0x57 signature can still use this	   without having to recompile. Specifying an i/o address along	   with an otherwise unused dev->mem_end value of "0xBAD" will	   cause the driver to skip these parts of the probe. */	bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));	/* Reset card. Who knows what dain-bramaged state it was left in. */	{		unsigned long reset_start_time = jiffies;		/* DON'T change these to inb_p/outb_p or reset will fail on clones. */		outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);		while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)		if (jiffies - reset_start_time > 2*HZ/100) {			if (bad_card) {				printk(" (warning: no reset ack)");				break;			} else {				printk(" not found (no reset ack).\n");				ret = -ENODEV;				goto err_out;			}		}		outb_p(0xff, ioaddr + EN0_ISR);		/* Ack all intr. */	}	/* Read the 16 bytes of station address PROM.	   We must first initialize registers, similar to NS8390_init(eifdev, 0).	   We can't reliably read the SAPROM address without this.	   (I learned the hard way!). */	{		struct {unsigned char value, offset; } program_seq[] =		{			{E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/			{0x48,	EN0_DCFG},	/* Set byte-wide (0x48) access. */			{0x00,	EN0_RCNTLO},	/* Clear the count regs. */			{0x00,	EN0_RCNTHI},			{0x00,	EN0_IMR},	/* Mask completion irq. */			{0xFF,	EN0_ISR},			{E8390_RXOFF, EN0_RXCR},	/* 0x20  Set to monitor */			{E8390_TXOFF, EN0_TXCR},	/* 0x02  and loopback mode. */			{32,	EN0_RCNTLO},			{0x00,	EN0_RCNTHI},			{0x00,	EN0_RSARLO},	/* DMA starting at 0x0000. */			{0x00,	EN0_RSARHI},			{E8390_RREAD+E8390_START, E8390_CMD},		};		for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)			outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);	}	for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {		SA_prom[i] = inb(ioaddr + NE_DATAPORT);		SA_prom[i+1] = inb(ioaddr + NE_DATAPORT);		if (SA_prom[i] != SA_prom[i+1])			wordlength = 1;	}	if (wordlength == 2)	{		for (i = 0; i < 16; i++)			SA_prom[i] = SA_prom[i+i];		/* We must set the 8390 for word mode. */		outb_p(DCR_VAL, ioaddr + EN0_DCFG);		start_page = NESM_START_PG;		stop_page = NESM_STOP_PG;	} else {		start_page = NE1SM_START_PG;		stop_page = NE1SM_STOP_PG;	}#if  defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R)	neX000 = ((SA_prom[14] == 0x57  &&  SA_prom[15] == 0x57)		|| (SA_prom[14] == 0x42 && SA_prom[15] == 0x42));#else	neX000 = (SA_prom[14] == 0x57  &&  SA_prom[15] == 0x57);#endif	ctron =  (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);	copam =  (SA_prom[14] == 0x49 && SA_prom[15] == 0x00);	/* Set up the rest of the parameters. */	if (neX000 || bad_card || copam) {		name = (wordlength == 2) ? "NE2000" : "NE1000";	}	else if (ctron)	{		name = (wordlength == 2) ? "Ctron-8" : "Ctron-16";		start_page = 0x01;		stop_page = (wordlength == 2) ? 0x40 : 0x20;	}	else	{#ifdef SUPPORT_NE_BAD_CLONES		/* Ack!  Well, there might be a *bad* NE*000 clone there.		   Check for total bogus addresses. */		for (i = 0; bad_clone_list[i].name8; i++)		{			if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&				SA_prom[1] == bad_clone_list[i].SAprefix[1] &&				SA_prom[2] == bad_clone_list[i].SAprefix[2])			{				if (wordlength == 2)				{					name = bad_clone_list[i].name16;				} else {					name = bad_clone_list[i].name8;				}				break;			}		}		if (bad_clone_list[i].name8 == NULL)		{			printk(" not found (invalid signature %2.2x %2.2x).\n",				SA_prom[14], SA_prom[15]);			ret = -ENXIO;			goto err_out;		}#else		printk(" not found.\n");		ret = -ENXIO;		goto err_out;#endif	}	if (dev->irq < 2)	{		unsigned long cookie = probe_irq_on();		outb_p(0x50, ioaddr + EN0_IMR);	/* Enable one interrupt. */		outb_p(0x00, ioaddr + EN0_RCNTLO);		outb_p(0x00, ioaddr + EN0_RCNTHI);		outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */		mdelay(10);		/* wait 10ms for interrupt to propagate */		outb_p(0x00, ioaddr + EN0_IMR); 		/* Mask it again. */		dev->irq = probe_irq_off(cookie);		if (ei_debug > 2)			printk(" autoirq is %d\n", dev->irq);	} else if (dev->irq == 2)		/* Fixup for users that don't know that IRQ 2 is really IRQ 9,		   or don't know which one to set. */		dev->irq = 9;	if (! dev->irq) {		printk(" failed to detect IRQ line.\n");		ret = -EAGAIN;		goto err_out;	}	/* Snarf the interrupt now.  There's no point in waiting since we cannot	   share and the board will usually be enabled. */	ret = request_irq(dev->irq, ei_interrupt, 0, name, dev);	if (ret) {		printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);		goto err_out;	}	dev->base_addr = ioaddr;#ifdef CONFIG_PLAT_MAPPI	outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP,		ioaddr + E8390_CMD); /* 0x61 */	for (i = 0 ; i < ETHER_ADDR_LEN ; i++) {		dev->dev_addr[i] = SA_prom[i]			= inb_p(ioaddr + EN1_PHYS_SHIFT(i));		printk(" %2.2x", SA_prom[i]);	}#else	for(i = 0; i < ETHER_ADDR_LEN; i++) {		printk(" %2.2x", SA_prom[i]);		dev->dev_addr[i] = SA_prom[i];	}#endif	printk("\n%s: %s found at %#x, using IRQ %d.\n",		dev->name, name, ioaddr, dev->irq);	ei_status.name = name;	ei_status.tx_start_page = start_page;	ei_status.stop_page = stop_page;#ifdef CONFIG_PLAT_OAKS32R	ei_status.word16 = 0;#else	ei_status.word16 = (wordlength == 2);#endif	ei_status.rx_start_page = start_page + TX_PAGES;#ifdef PACKETBUF_MEMSIZE	 /* Allow the packet buffer size to be overridden by know-it-alls. */	ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;#endif	ei_status.reset_8390 = &ne_reset_8390;	ei_status.block_input = &ne_block_input;	ei_status.block_output = &ne_block_output;	ei_status.get_8390_hdr = &ne_get_8390_hdr;	ei_status.priv = 0;	dev->open = &ne_open;	dev->stop = &ne_close;#ifdef CONFIG_NET_POLL_CONTROLLER	dev->poll_controller = ei_poll;#endif	NS8390_init(dev, 0);	ret = register_netdev(dev);	if (ret)		goto out_irq;	return 0;out_irq:	free_irq(dev->irq, dev);err_out:	release_region(ioaddr, NE_IO_EXTENT);	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/9cc975e00ddb291035bc4d2d49cdc8768ddf1cc3/ne.c/buggy/drivers/net/ne.c