int __init ultramca_probe(struct device *gen_dev) 
static int __init ultramca_probe(struct device *gen_dev) 
int __init ultramca_probe(struct device *gen_dev){	unsigned short ioaddr;	struct net_device *dev;	unsigned char reg4, num_pages;	struct mca_device *mca_dev = to_mca_device(gen_dev);	char slot = mca_dev->slot;	unsigned char pos2 = 0xff, pos3 = 0xff, pos4 = 0xff, pos5 = 0xff;	int i, rc;	int adapter = mca_dev->index;	int tbase = 0;	int tirq = 0;	int base_addr = ultra_io[ultra_found];	int irq = ultra_irq[ultra_found];	if (base_addr || irq) {		printk(KERN_INFO "Probing for SMC MCA adapter");		if (base_addr) {			printk(KERN_INFO " at I/O address 0x%04x%c",			       base_addr, irq ? ' ' : '\n');		}		if (irq) {			printk(KERN_INFO "using irq %d\n", irq);		}	}	tirq = 0;	tbase = 0;	/* If we're trying to match a specificied irq or io address,	 * we'll reject the adapter found unless it's the one we're	 * looking for */	pos2 = mca_device_read_stored_pos(mca_dev, 2); /* io_addr */	pos3 = mca_device_read_stored_pos(mca_dev, 3); /* shared mem */	pos4 = mca_device_read_stored_pos(mca_dev, 4); /* ROM bios addr range */	pos5 = mca_device_read_stored_pos(mca_dev, 5); /* irq, media and RIPL */	/* Test the following conditions:	 * - If an irq parameter is supplied, compare it	 *   with the irq of the adapter we found	 * - If a base_addr paramater is given, compare it	 *   with the base_addr of the adapter we found	 * - Check that the irq and the base_addr of the	 *   adapter we found is not already in use by	 *   this driver	 */	switch (mca_dev->index) {	case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A:	case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A:	case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A:	case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A:		{			tbase = addr_table[(pos2 & 0xf0) >> 4].base_addr;			tirq  = irq_table[(pos5 & 0xc) >> 2].new_irq;			break;		}	case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A:	case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A:	case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A:	case _efe5_IBM_PS2_Adapter_A_for_Ethernet:		{			tbase = ((pos2 & 0x0fe) * 0x10);			tirq  = irq_table[(pos5 & 3)].old_irq;			break;		}	}		if(!tirq || !tbase 	   || (irq && irq != tirq) 	   || (base_addr && tbase != base_addr))		/* FIXME: we're trying to force the ordering of the		 * devices here, there should be a way of getting this		 * to happen */		return -ENXIO;        /* Adapter found. */	dev  = alloc_ei_netdev();	if(!dev)		return -ENODEV;	SET_MODULE_OWNER(dev);	SET_NETDEV_DEV(dev, gen_dev);	mca_device_set_name(mca_dev, smc_mca_adapter_names[adapter]);	mca_device_set_claim(mca_dev, 1);	printk(KERN_INFO "smc_mca: %s found in slot %d\n",		       smc_mca_adapter_names[adapter], slot + 1);	ultra_found++;	dev->base_addr = ioaddr = mca_device_transform_ioport(mca_dev, tbase);	dev->irq       = mca_device_transform_irq(mca_dev, tirq);	dev->mem_start = 0;	num_pages      = 40;	switch (adapter) {	/* card-# in const array above [hs] */		case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A:		case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A:		{			for (i = 0; i < 16; i++) { /* taking 16 counts						    * up to 15 [hs] */				if (mem_table[i].mem_index == (pos3 & ~MEM_MASK)) {					dev->mem_start = (unsigned long)					  mca_device_transform_memory(mca_dev, (void *)mem_table[i].mem_start);					num_pages = mem_table[i].num_pages;				}			}			break;		}		case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A:		case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A:		case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A:		case _efe5_IBM_PS2_Adapter_A_for_Ethernet:		{			dev->mem_start = (unsigned long)			  mca_device_transform_memory(mca_dev, (void *)((pos3 & 0xfc) * 0x1000));			num_pages = 0x40;			break;		}		case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A:		case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A:		{			/* courtesy of gamera@quartz.ocn.ne.jp, pos3 indicates			 * the index of the 0x2000 step.			 * beware different number of pages [hs]			 */			dev->mem_start = (unsigned long) 			  mca_device_transform_memory(mca_dev, (void *)(0xc0000 + (0x2000 * (pos3 & 0xf))));			num_pages = 0x20 + (2 * (pos3 & 0x10));			break;		}	}	/* sanity check, shouldn't happen */	if (dev->mem_start == 0) {		rc = -ENODEV;		goto err_unclaim;	}	if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME)) {		rc = -ENODEV;		goto err_unclaim;	}	reg4 = inb(ioaddr + 4) & 0x7f;	outb(reg4, ioaddr + 4);	printk(KERN_INFO "smc_mca[%d]: Parameters: %#3x,", slot + 1, ioaddr);	for (i = 0; i < 6; i++)		printk(" %2.2X", dev->dev_addr[i] = inb(ioaddr + 8 + i));	/* Switch from the station address to the alternate register set	 * and read the useful registers there.	 */	outb(0x80 | reg4, ioaddr + 4);	/* Enable FINE16 mode to avoid BIOS ROM width mismatches @ reboot.	 */	outb(0x80 | inb(ioaddr + 0x0c), ioaddr + 0x0c);	/* Switch back to the station address register set so that	 * the MS-DOS driver can find the card after a warm boot.	 */	outb(reg4, ioaddr + 4);	gen_dev->driver_data = dev;	/* The 8390 isn't at the base address, so fake the offset	 */	dev->base_addr = ioaddr + ULTRA_NIC_OFFSET;	ei_status.name = "SMC Ultra MCA";	ei_status.word16 = 1;	ei_status.tx_start_page = START_PG;	ei_status.rx_start_page = START_PG + TX_PAGES;	ei_status.stop_page = num_pages;	ei_status.mem = ioremap(dev->mem_start, (ei_status.stop_page - START_PG) * 256);	if (!ei_status.mem) {		rc = -ENOMEM;		goto err_release_region;	}	dev->mem_end = dev->mem_start + (ei_status.stop_page - START_PG) * 256;	printk(", IRQ %d memory %#lx-%#lx.\n",	dev->irq, dev->mem_start, dev->mem_end - 1);	ei_status.reset_8390 = &ultramca_reset_8390;	ei_status.block_input = &ultramca_block_input;	ei_status.block_output = &ultramca_block_output;	ei_status.get_8390_hdr = &ultramca_get_8390_hdr;	ei_status.priv = slot;	dev->open = &ultramca_open;	dev->stop = &ultramca_close_card;#ifdef CONFIG_NET_POLL_CONTROLLER	dev->poll_controller = ei_poll;#endif	NS8390_init(dev, 0);	rc = register_netdev(dev);	if (rc)		goto err_unmap;	return 0;err_unmap:	iounmap(ei_status.mem);err_release_region:	release_region(ioaddr, ULTRA_IO_EXTENT);err_unclaim:	mca_device_set_claim(mca_dev, 0);	free_netdev(dev);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/725c0f922f04e5a3a7d2ba66dbc10b8e20000712/smc-mca.c/clean/drivers/net/smc-mca.c