/*
 * set leds state according to channel activity
 */
static void pcan_led_timer(unsigned long arg)
{
	struct pcan_pccard *card = (struct pcan_pccard *)arg;
	struct net_device *netdev;
	int i, up_count = 0;
	u8 ccr;

	ccr = card->ccr;
	for (i = 0; i < card->chan_count; i++) {
		/* default is: not configured */
		ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
		ccr |= PCC_CCR_LED_ON_CHAN(i);

		netdev = card->channel[i].netdev;
		if (!netdev || !(netdev->flags & IFF_UP))
			continue;

		up_count++;

		/* no activity (but configured) */
		ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
		ccr |= PCC_CCR_LED_SLOW_CHAN(i);

		/* if bytes counters changed, set fast blinking led */
		if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) {
			card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes;
			ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
			ccr |= PCC_CCR_LED_FAST_CHAN(i);
		}
		if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) {
			card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes;
			ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
			ccr |= PCC_CCR_LED_FAST_CHAN(i);
		}
	}

	/* write the new leds state */
	pcan_write_reg(card, PCC_CCR, ccr);

	/* restart timer (except if no more configured channels) */
	if (up_count)
		mod_timer(&card->led_timer, jiffies + HZ);
}
static void pcan_led_timer(unsigned long arg)
{
	struct pcan_pccard *card = (struct pcan_pccard *)arg;
	struct net_device *netdev;
	int i, up_count = 0;
	u8 ccr;

	ccr = card->ccr;
	for (i = 0; i < card->chan_count; i++) {
		
		ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
		ccr |= PCC_CCR_LED_ON_CHAN(i);

		netdev = card->channel[i].netdev;
		if (!netdev || !(netdev->flags & IFF_UP))
			continue;

		up_count++;

		
		ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
		ccr |= PCC_CCR_LED_SLOW_CHAN(i);

		
		if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) {
			card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes;
			ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
			ccr |= PCC_CCR_LED_FAST_CHAN(i);
		}
		if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) {
			card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes;
			ccr &= ~PCC_CCR_LED_MASK_CHAN(i);
			ccr |= PCC_CCR_LED_FAST_CHAN(i);
		}
	}

	
	pcan_write_reg(card, PCC_CCR, ccr);

	
	if (up_count)
		mod_timer(&card->led_timer, jiffies + HZ);
}