kernels/linux-2.4.0/drivers/net/wan/sdla_chdlc.c
/*============================================================================
 * Update device status & statistics
 * This procedure is called when updating the PROC file system and returns
 * various communications statistics. These statistics are accumulated from 3 
 * different locations:
 * 	1) The 'if_stats' recorded for the device.
 * 	2) Communication error statistics on the adapter.
 *      3) CHDLC operational statistics on the adapter.
 * The board level statistics are read during a timer interrupt. Note that we 
 * read the error and operational statistics during consecitive timer ticks so
 * as to minimize the time that we are inside the interrupt handler.
 *
 */
Update device status & statistics
This procedure is called when updating the PROC file system and returns
various communications statistics. These statistics are accumulated from 3
different locations:
1) The 'if_stats' recorded for the device.
2) Communication error statistics on the adapter.
3) CHDLC operational statistics on the adapter.
The board level statistics are read during a timer interrupt. Note that we
read the error and operational statistics during consecitive timer ticks so
as to minimize the time that we are inside the interrupt handler.
Update device status & statistics This procedure is called when updating the PROC file system and returns various communications statistics . These statistics are accumulated from 3 different locations : 1 ) The ' if_stats ' recorded for the device . 2 ) Communication error statistics on the adapter . 3 ) CHDLC operational statistics on the adapter . The board level statistics are read during a timer interrupt . Note that we read the error and operational statistics during consecitive timer ticks so as to minimize the time that we are inside the interrupt handler .
static int update (wan_device_t* wandev)
{
	sdla_t* card = wandev->private;
 	struct net_device* dev = card->wandev.dev;
        volatile chdlc_private_area_t* chdlc_priv_area = dev->priv;
        SHARED_MEMORY_INFO_STRUCT *flags;
	unsigned long timeout;
	if((wandev == NULL) || (wandev->private == NULL))
		return -EFAULT;
	if(wandev->state == WAN_UNCONFIGURED)
		return -ENODEV;
        if(!card->u.c.flags)
                return -ENODEV;
	if(test_bit(1, (void*)&card->wandev.critical))
                return -EAGAIN;
	if(!netif_running(dev))
		return -ENODEV;
      	flags = card->u.c.flags;
       	if(chdlc_priv_area->update_comms_stats){
		return -EAGAIN;
	}
	chdlc_priv_area->update_comms_stats = 2;
       	flags->interrupt_info_struct.interrupt_permission |= APP_INT_ON_TIMER;
	chdlc_priv_area->timer_int_enabled = TMR_INT_ENABLED_UPDATE;
        timeout = jiffies;
        for(;;) {
		if(chdlc_priv_area->update_comms_stats == 0)
			break;
                if ((jiffies - timeout) > (1 * HZ)){
    			chdlc_priv_area->update_comms_stats = 0;
 			chdlc_priv_area->timer_int_enabled &=
				~TMR_INT_ENABLED_UPDATE; 
 			return -EAGAIN;
		}
        }
	return 0;
}
static int update ( wan_device_t * wandev ) { sdla_t * card = wandev -> private ; struct net_device * dev = card -> wandev . dev ; volatile chdlc_private_area_t * chdlc_priv_area = dev -> priv ; SHARED_MEMORY_INFO_STRUCT * flags ; unsigned long timeout ; if ( ( wandev == NULL ) || ( wandev -> private == NULL ) ) return - EFAULT ; if ( wandev -> state == WAN_UNCONFIGURED ) return - ENODEV ; if ( ! card -> u . c . flags ) return - ENODEV ; if ( test_bit ( 1 , ( void * ) & card -> wandev . critical ) ) return - EAGAIN ; if ( ! netif_running ( dev ) ) return - ENODEV ; flags = card -> u . c . flags ; if ( chdlc_priv_area -> update_comms_stats ) { return - EAGAIN ; } chdlc_priv_area -> update_comms_stats = 2 ; flags -> interrupt_info_struct . interrupt_permission |= APP_INT_ON_TIMER ; chdlc_priv_area -> timer_int_enabled = TMR_INT_ENABLED_UPDATE ; timeout = jiffies ; for ( ; ; ) { if ( chdlc_priv_area -> update_comms_stats == 0 ) break ; if ( ( jiffies - timeout ) > ( 1 * HZ ) ) { chdlc_priv_area -> update_comms_stats = 0 ; chdlc_priv_area -> timer_int_enabled &= ~ TMR_INT_ENABLED_UPDATE ; return - EAGAIN ; } } return 0 ; }
Update device status & statistics
 This procedure is called when updating the PROC file system and returns
 various communications statistics.
Update device status & statistics This procedure is called when updating the PROC file system and returns various communications statistics .
/* sanity checks */ /* more sanity checks */ /* we will need 2 timer interrupts to complete the */ /* reading of the statistics */ /* wait a maximum of 1 second for the statistics to be updated */