Changeset 1646

Show
Ignore:
Timestamp:
11/26/02 01:12:11 (10 years ago)
Author:
mds
Message:

updates, cleanup, wait for update before returning values

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/bmcsensors.c

    r1635 r1646  
    7575 
    7676static void bmcsensors_update_client(struct i2c_client *client); 
    77 static void bmcsensors_init_client(struct i2c_client *client); 
    7877static int bmcsensors_find(int *address); 
    7978static void bmcsensors_reserve_sdr(void); 
     
    406405        bmc_data.sysctl_id = i; 
    407406 
    408         bmcsensors_init_client(&bmc_client); 
    409407        printk(KERN_INFO "bmcsensors.o: %d reservations cancelled\n", errorcount); 
    410408        printk(KERN_INFO "bmcsensors.o: registered %d temp, %d volt, %d current, %d fan sensors\n", 
    411409                        temps, volts, currs, fans); 
    412         bmcsensors_update_client(&bmc_client); 
     410/* 
     411        This completes the initialization. The first userspace read 
     412        of a /proc value will force the first 
     413        bmcsensors_update_client() which starts the 
     414        reading of the sensors themselves via IPMI messages. 
     415*/ 
    413416} 
    414417 
     
    591594                if(sdrd_count == 0) { 
    592595                        printk(KERN_INFO "bmcsensors.o: No recognized sensors found.\n"); 
    593                         rstate = STATE_DONE; 
    594596                        /* unregister?? */ 
    595597                } else { 
    596598                        bmcsensors_build_proc_table(); 
    597                         rstate = STATE_READING; 
    598                 } 
     599                } 
     600                rstate = STATE_DONE; 
    599601        } else { 
    600602                bmcsensors_get_sdr(0, nextrecord, 0); 
     
    611613                case STATE_RESERVE: 
    612614                        resid = (((u16)msg->data[2]) << 8) || msg->data[1]; 
    613 #if 1 
    614                         printk(KERN_INFO "bmcsensors.o: Got first resid 0x%.4x\n", resid); 
     615#ifdef DEBUG 
     616                        printk(KERN_DEBUG "bmcsensors.o: Got first resid 0x%.4x\n", resid); 
    615617#endif 
    616618                        bmcsensors_get_sdr(0, 0, 0); 
     
    629631                case STATE_UNCANCEL: 
    630632                        resid = (((u16)msg->data[2]) << 8) || msg->data[1]; 
    631 #if 1 
    632                         printk(KERN_INFO "bmcsensors.o: Got new resid 0x%.4x\n", resid); 
     633#ifdef DEBUG 
     634                        printk(KERN_DEBUG "bmcsensors.o: Got new resid 0x%.4x\n", resid); 
    633635#endif 
    634636                        rx_msg_data_offset = 0; 
     
    652654        if(state == STATE_SDR && msg->msg.data[0] == 0xc5) { 
    653655                /* )(*&@(*&#@$ reservation cancelled, get new resid */ 
    654                 if(++errorcount > 1000) { 
     656                if(++errorcount > 275) { 
    655657                        printk(KERN_ERR 
    656658                               "bmcsensors.o: Too many reservations cancelled, giving up\n"); 
    657659                        state = STATE_DONE; 
    658660                } else { 
    659 #if 1 
    660                         printk(KERN_ERR 
     661#ifdef DEBUG 
     662                        printk(KERN_DEBUG 
    661663                               "bmcsensors.o: resid 0x%04x cancelled, getting new one\n", resid); 
    662664#endif 
     
    708710static void bmcsensors_get_sdr(u16 res_id, u16 record, u8 offset) 
    709711{ 
    710 #if 1 
    711         printk(KERN_INFO "bmcsensors.o: Get SDR 0x%x 0x%x 0x%x\n", 
     712#ifdef DEBUG 
     713        printk(KERN_DEBUG "bmcsensors.o: Get SDR 0x%x 0x%x 0x%x\n", 
    712714                       res_id, record, offset); 
    713715#endif 
     
    819821} 
    820822 
    821 static void bmcsensors_init_client(struct i2c_client *client) 
    822 { 
    823 /*******************************************/ 
    824  
    825  
    826  
     823static void bmc_do_pause(unsigned int amount) 
     824{ 
     825        current->state = TASK_INTERRUPTIBLE; 
     826        schedule_timeout(amount); 
    827827} 
    828828 
     
    830830{ 
    831831        struct bmcsensors_data *data = client->data; 
    832         int i; 
     832        int j = 0; 
    833833 
    834834/* 
     
    836836*/ 
    837837 
     838        /* if within 3 seconds you get old data */ 
    838839        if ((jiffies - data->last_updated > 3 * HZ) || 
    839840            (jiffies < data->last_updated) || !data->valid) { 
     
    841842                if(state != STATE_READING) { 
    842843                        state = STATE_READING; 
     844#ifdef DEBUG 
     845                        printk(KERN_DEBUG "bmcsensors.o: starting update\n", j); 
     846#endif 
    843847                        bmcsensors_get_reading(client, 0); 
    844848                } 
     849                /* wait 4 seconds max */ 
     850                while(state == STATE_READING && j++ < 100) 
     851                        bmc_do_pause(HZ / 25); 
     852#ifdef DEBUG 
     853                printk("bmcsensors.o: update complete; j = %d\n", j); 
     854#endif 
     855                data->last_updated = jiffies; 
     856                data->valid = 1; 
    845857        } 
    846858 
     
    910922        int i; 
    911923        struct bmcsensors_data *data = client->data; 
    912         int nr = ctl_name - BMC_SYSCTL_TEMP1 + 1; 
    913924 
    914925        if((i = find_sdrd(ctl_name)) < 0) {