#ifdef CONFIG_PM 
#ifdef CONFIG_PM_LEGACY 
static int __init el3_probe(int card_idx){	struct net_device *dev;	struct el3_private *lp;	short lrs_state = 0xff, i;	int ioaddr, irq, if_port;	u16 phys_addr[3];	static int current_tag;	int err = -ENODEV;#if defined(__ISAPNP__)	static int pnp_cards;	struct pnp_dev *idev = NULL;	if (nopnp == 1)		goto no_pnp;	for (i=0; el3_isapnp_adapters[i].vendor != 0; i++) {		int j;		while ((idev = pnp_find_dev(NULL,					    el3_isapnp_adapters[i].vendor,					    el3_isapnp_adapters[i].function,					    idev))) {			if (pnp_device_attach(idev) < 0)				continue;			if (pnp_activate_dev(idev) < 0) {__again:				pnp_device_detach(idev);				continue;			}			if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0))				goto __again;			ioaddr = pnp_port_start(idev, 0);			if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509 PnP")) {				pnp_device_detach(idev);				return -EBUSY;			}			irq = pnp_irq(idev, 0);			if (el3_debug > 3)				printk ("ISAPnP reports %s at i/o 0x%x, irq %d\n",					(char*) el3_isapnp_adapters[i].driver_data, ioaddr, irq);			EL3WINDOW(0);			for (j = 0; j < 3; j++)				el3_isapnp_phys_addr[pnp_cards][j] =					phys_addr[j] =						htons(read_eeprom(ioaddr, j));			if_port = read_eeprom(ioaddr, 8) >> 14;			dev = alloc_etherdev(sizeof (struct el3_private));			if (!dev) {					release_region(ioaddr, EL3_IO_EXTENT);					pnp_device_detach(idev);					return -ENOMEM;			}			SET_MODULE_OWNER(dev);			SET_NETDEV_DEV(dev, &idev->dev);			pnp_cards++;			netdev_boot_setup_check(dev);			goto found;		}	}no_pnp:#endif /* __ISAPNP__ */	/* Select an open I/O location at 0x1*0 to do contention select. */	for ( ; id_port < 0x200; id_port += 0x10) {		if (!request_region(id_port, 1, "3c509"))			continue;		outb(0x00, id_port);		outb(0xff, id_port);		if (inb(id_port) & 0x01){			release_region(id_port, 1);			break;		} else			release_region(id_port, 1);	}	if (id_port >= 0x200) {		/* Rare -- do we really need a warning? */		printk(" WARNING: No I/O port available for 3c509 activation.\n");		return -ENODEV;	}	/* Next check for all ISA bus boards by sending the ID sequence to the	   ID_PORT.  We find cards past the first by setting the 'current_tag'	   on cards as they are found.  Cards with their tag set will not	   respond to subsequent ID sequences. */	outb(0x00, id_port);	outb(0x00, id_port);	for(i = 0; i < 255; i++) {		outb(lrs_state, id_port);		lrs_state <<= 1;		lrs_state = lrs_state & 0x100 ? lrs_state ^ 0xcf : lrs_state;	}	/* For the first probe, clear all board's tag registers. */	if (current_tag == 0)		outb(0xd0, id_port);	else				/* Otherwise kill off already-found boards. */		outb(0xd8, id_port);	if (id_read_eeprom(7) != 0x6d50) {		return -ENODEV;	}	/* Read in EEPROM data, which does contention-select.	   Only the lowest address board will stay "on-line".	   3Com got the byte order backwards. */	for (i = 0; i < 3; i++) {		phys_addr[i] = htons(id_read_eeprom(i));	}#if defined(__ISAPNP__)	if (nopnp == 0) {		/* The ISA PnP 3c509 cards respond to the ID sequence.		   This check is needed in order not to register them twice. */		for (i = 0; i < pnp_cards; i++) {			if (phys_addr[0] == el3_isapnp_phys_addr[i][0] &&			    phys_addr[1] == el3_isapnp_phys_addr[i][1] &&			    phys_addr[2] == el3_isapnp_phys_addr[i][2])			{				if (el3_debug > 3)					printk("3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n",						phys_addr[0] & 0xff, phys_addr[0] >> 8,						phys_addr[1] & 0xff, phys_addr[1] >> 8,						phys_addr[2] & 0xff, phys_addr[2] >> 8);				/* Set the adaptor tag so that the next card can be found. */				outb(0xd0 + ++current_tag, id_port);				goto no_pnp;			}		}	}#endif /* __ISAPNP__ */	{		unsigned int iobase = id_read_eeprom(8);		if_port = iobase >> 14;		ioaddr = 0x200 + ((iobase & 0x1f) << 4);	}	irq = id_read_eeprom(9) >> 12;	dev = alloc_etherdev(sizeof (struct el3_private));	if (!dev)		return -ENOMEM;	SET_MODULE_OWNER(dev);	netdev_boot_setup_check(dev);		/* Set passed-in IRQ or I/O Addr. */	if (dev->irq > 1  &&  dev->irq < 16)			irq = dev->irq;	if (dev->base_addr) {		if (dev->mem_end == 0x3c509 	/* Magic key */		    && dev->base_addr >= 0x200  &&  dev->base_addr <= 0x3e0)			ioaddr = dev->base_addr & 0x3f0;		else if (dev->base_addr != ioaddr)			goto out;	}	if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509")) {		err = -EBUSY;		goto out;	}	/* Set the adaptor tag so that the next card can be found. */	outb(0xd0 + ++current_tag, id_port);	/* Activate the adaptor at the EEPROM location. */	outb((ioaddr >> 4) | 0xe0, id_port);	EL3WINDOW(0);	if (inw(ioaddr) != 0x6d50)		goto out1;	/* Free the interrupt so that some other card can use it. */	outw(0x0f00, ioaddr + WN0_IRQ);#if defined(__ISAPNP__) found:							/* PNP jumps here... */#endif /* __ISAPNP__ */	memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr));	dev->base_addr = ioaddr;	dev->irq = irq;	dev->if_port = if_port;	lp = netdev_priv(dev);#if defined(__ISAPNP__)	lp->dev = &idev->dev;#endif	err = el3_common_init(dev);	if (err)		goto out1;#ifdef CONFIG_PM	/* register power management */	lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback);	if (lp->pmdev) {		struct pm_dev *p;		p = lp->pmdev;		p->data = (struct net_device *)dev;	}#endif	el3_cards++;	lp->next_dev = el3_root_dev;	el3_root_dev = dev;	return 0;out1:#if defined(__ISAPNP__)	if (idev)		pnp_device_detach(idev);#endifout:	free_netdev(dev);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/bca73e4bf8563d83f7856164caa44d5f42e44cca/3c509.c/clean/drivers/net/3c509.c