if (!in_interrupt()) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); } 
if (!in_interrupt()) schedule_timeout_interruptible(1); 
static int hp100_down_vg_link(struct net_device *dev){	struct hp100_private *lp = netdev_priv(dev);	int ioaddr = dev->base_addr;	unsigned long time;	long savelan, newlan;#ifdef HP100_DEBUG_B	hp100_outw(0x4224, TRACE);	printk("hp100: %s: down_vg_link\n", dev->name);#endif	hp100_page(MAC_CTRL);	time = jiffies + (HZ / 4);	do {		if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST)			break;		if (!in_interrupt()) {			set_current_state(TASK_INTERRUPTIBLE);			schedule_timeout(1);		}	} while (time_after(time, jiffies));	if (time_after_eq(jiffies, time))	/* no signal->no logout */		return 0;	/* Drop the VG Link by clearing the link up cmd and load addr. */	hp100_andb(~(HP100_LOAD_ADDR | HP100_LINK_CMD), VG_LAN_CFG_1);	hp100_orb(HP100_VG_SEL, VG_LAN_CFG_1);	/* Conditionally stall for >250ms on Link-Up Status (to go down) */	time = jiffies + (HZ / 2);	do {		if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST))			break;		if (!in_interrupt()) {			set_current_state(TASK_INTERRUPTIBLE);			schedule_timeout(1);		}	} while (time_after(time, jiffies));#ifdef HP100_DEBUG	if (time_after_eq(jiffies, time))		printk("hp100: %s: down_vg_link: Link does not go down?\n", dev->name);#endif	/* To prevent condition where Rev 1 VG MAC and old hubs do not complete */	/* logout under traffic (even though all the status bits are cleared),  */	/* do this workaround to get the Rev 1 MAC in its idle state */	if (lp->chip == HP100_CHIPID_LASSEN) {		/* Reset VG MAC to insure it leaves the logoff state even if */		/* the Hub is still emitting tones */		hp100_andb(~HP100_VG_RESET, VG_LAN_CFG_1);		udelay(1500);	/* wait for >1ms */		hp100_orb(HP100_VG_RESET, VG_LAN_CFG_1);	/* Release Reset */		udelay(1500);	}	/* New: For lassen, switch to 10 Mbps mac briefly to clear training ACK */	/* to get the VG mac to full reset. This is not req.d with later chips */	/* Note: It will take the between 1 and 2 seconds for the VG mac to be */	/* selected again! This will be left to the connect hub function to */	/* perform if desired.  */	if (lp->chip == HP100_CHIPID_LASSEN) {		/* Have to write to 10 and 100VG control registers simultaneously */		savelan = newlan = hp100_inl(10_LAN_CFG_1);	/* read 10+100 LAN_CFG regs */		newlan &= ~(HP100_VG_SEL << 16);		newlan |= (HP100_DOT3_MAC) << 8;		hp100_andb(~HP100_AUTO_MODE, MAC_CFG_3);	/* Autosel off */		hp100_outl(newlan, 10_LAN_CFG_1);		/* Conditionally stall for 5sec on VG selected. */		time = jiffies + (HZ * 5);		do {			if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST))				break;			if (!in_interrupt()) {				set_current_state(TASK_INTERRUPTIBLE);				schedule_timeout(1);			}		} while (time_after(time, jiffies));		hp100_orb(HP100_AUTO_MODE, MAC_CFG_3);	/* Autosel back on */		hp100_outl(savelan, 10_LAN_CFG_1);	}	time = jiffies + (3 * HZ);	/* Timeout 3s */	do {		if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0)			break;		if (!in_interrupt()) {			set_current_state(TASK_INTERRUPTIBLE);			schedule_timeout(1);		}	} while (time_after(time, jiffies));	if (time_before_eq(time, jiffies)) {#ifdef HP100_DEBUG		printk("hp100: %s: down_vg_link: timeout\n", dev->name);#endif		return -EIO;	}	time = jiffies + (2 * HZ);	/* This seems to take a while.... */	do {		if (!in_interrupt()) {			set_current_state(TASK_INTERRUPTIBLE);			schedule_timeout(1);		}	} while (time_after(time, jiffies));	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/3173c8907ffb2c64456142da3df2bd0500bd59e0/hp100.c/clean/drivers/net/hp100.c