Changeset 2516

Show
Ignore:
Timestamp:
05/09/04 09:24:37 (9 years ago)
Author:
khali
Message:

Discard unused variable in private driver data.

Less agressive initialization process (do not reset the chip,
closes ticket #1154; preserve application mode)
Fix temp1 (instead of temp2) limits being unsettable in application
mode 2 (tickets #894 and #1219).
Ensure that temp2 and in4 are not used at the same time (ticket
#894).

Files:
1 modified

Legend:

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

    r2445 r2516  
    124124        char valid;             /* !=0 if following fields are valid */ 
    125125        unsigned long last_updated;     /* In jiffies */ 
    126         unsigned long last_updated_v00; 
    127         /* In jiffies (used only by rev00 chips) */ 
    128126 
    129127        u8 voltage[5];          /* Register values; [0] = VDD */ 
     
    342340 
    343341        /* Initialize the GL520SM chip */ 
    344         data->two_temps = 1; 
    345342        data->alarm_mask = 0xff; 
    346343        gl520_init_client(new_client); 
     344        if (data->two_temps) 
     345                data->voltage_max[4] = data->voltage_min[4] = 
     346                        data->voltage[4] = 0; 
     347        else 
     348                data->temp_hyst[1] = data->temp_over[1] = 
     349                        data->temp[1] = 0; 
     350 
    347351        return 0; 
    348352 
     
    360364 
    361365 
    362 /* Called when we have found a new GL520SM. It should set limits, etc. */ 
     366/* Called when we have found a new GL520SM. */ 
    363367static void gl520_init_client(struct i2c_client *client) 
    364368{ 
    365         /* Power-on defaults (bit 7=1) */ 
    366         gl520_write_value(client, GL520_REG_CONF, 0x80); 
    367  
    368         /* No noisy output (bit 2=1), Comparator mode (bit 3=0), two fans (bit4=0), 
    369            standby mode (bit6=0) */ 
    370         gl520_write_value(client, GL520_REG_CONF, 0x04); 
    371  
    372         /* Never interrupts */ 
    373         gl520_write_value(client, GL520_REG_MASK, 0x00); 
    374  
    375         /* Clear status register (bit 5=1), start (bit6=1) */ 
    376         gl520_write_value(client, GL520_REG_CONF, 0x24); 
    377         gl520_write_value(client, GL520_REG_CONF, 0x44); 
     369        struct gl520_data *data = (struct gl520_data *)(client->data); 
     370        u8 oldconf, conf; 
     371 
     372        conf = oldconf = gl520_read_value(client, GL520_REG_CONF); 
     373        data->two_temps = !(conf & 0x10); 
     374 
     375        /* If IRQ# is disabled, we can safely force comparator mode */ 
     376        if (!(conf & 0x20)) 
     377                conf &= 0xf7; 
     378 
     379        /* Enable monitoring if needed */ 
     380        conf |= 0x40; 
     381 
     382        if (conf != oldconf) 
     383                gl520_write_value(client, GL520_REG_CONF, conf); 
    378384} 
    379385 
     
    482488 
    483489                /* Temp1 and Vin4 are the same input */ 
    484                 data->temp[1] = gl520_read_value(client, GL520_REG_TEMP2); 
    485                 data->temp_over[1] = 
    486                     gl520_read_value(client, GL520_REG_TEMP2_OVER); 
    487                 data->temp_hyst[1] = 
    488                     gl520_read_value(client, GL520_REG_TEMP2_HYST); 
    489  
    490                 data->voltage[4] = 
    491                     gl520_read_value(client, GL520_REG_VIN4); 
    492                 data->voltage_min[4] = 
    493                     gl520_read_value(client, GL520_REG_VIN4_MIN); 
    494                 data->voltage_max[4] = 
    495                     gl520_read_value(client, GL520_REG_VIN4_MAX); 
     490                if (data->two_temps) { 
     491                        data->temp[1] = 
     492                            gl520_read_value(client, GL520_REG_TEMP2); 
     493                        data->temp_over[1] = 
     494                            gl520_read_value(client, GL520_REG_TEMP2_OVER); 
     495                        data->temp_hyst[1] = 
     496                            gl520_read_value(client, GL520_REG_TEMP2_HYST); 
     497                } else { 
     498                        data->voltage[4] = 
     499                            gl520_read_value(client, GL520_REG_VIN4); 
     500                        data->voltage_min[4] = 
     501                            gl520_read_value(client, GL520_REG_VIN4_MIN); 
     502                        data->voltage_max[4] = 
     503                            gl520_read_value(client, GL520_REG_VIN4_MAX); 
     504                } 
    496505 
    497506                data->last_updated = jiffies; 
     
    518527                *nrels_mag = 3; 
    519528        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
    520                 if ((nr == 0) && (!data->two_temps)) 
     529                if ((nr == 1) && (!data->two_temps)) 
    521530                        return; 
    522531                regnr = 
     
    767776                                old |= 0x10; 
    768777                                data->two_temps = 0; 
     778                                data->temp_hyst[1] = data->temp_over[1] = 
     779                                        data->temp[1] = 0; 
    769780                        } else { 
    770781                                data->two_temps = 1; 
     782                                data->voltage_max[4] = data->voltage_min[4] = 
     783                                        data->voltage[4] = 0; 
    771784                        } 
    772785                        gl520_write_value(client, GL520_REG_CONF, old);