Changeset 2210

Show
Ignore:
Timestamp:
01/09/04 22:26:54 (9 years ago)
Author:
khali
Message:

Change the way the lm90 driver handles hysteresis. Now similar

to the 2.6 version of the driver.

Location:
lm-sensors/trunk
Files:
4 modified

Legend:

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

    r2192 r2210  
    131131static void lm90_remote_tcrit(struct i2c_client *client, int operation, 
    132132        int ctl_name, int *nrels_mag, long *results); 
    133 static void lm90_hyst(struct i2c_client *client, int operation, 
     133static void lm90_local_hyst(struct i2c_client *client, int operation, 
     134        int ctl_name, int *nrels_mag, long *results); 
     135static void lm90_remote_hyst(struct i2c_client *client, int operation, 
    134136        int ctl_name, int *nrels_mag, long *results); 
    135137static void lm90_alarms(struct i2c_client *client, int operation, 
     
    165167        u16 remote_temp, remote_high, remote_low; /* combined */ 
    166168        u8 local_crit, remote_crit; 
    167         u8 hyst; 
     169        u8 hyst; /* linked to two sysctl files (hyst1 RW, hyst2 RO) */ 
    168170        u16 alarms; /* bitvector, combined */ 
    169171}; 
     
    180182#define LM90_SYSCTL_LOCAL_TCRIT   1204 
    181183#define LM90_SYSCTL_REMOTE_TCRIT  1205 
    182 #define LM90_SYSCTL_HYST          1207 
     184#define LM90_SYSCTL_LOCAL_HYST    1207 
     185#define LM90_SYSCTL_REMOTE_HYST   1208 
    183186#define LM90_SYSCTL_ALARMS        1210 
    184187 
     
    204207        {LM90_SYSCTL_REMOTE_TCRIT, "tcrit2", NULL, 0, 0644, NULL, 
    205208         &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_remote_tcrit}, 
    206         {LM90_SYSCTL_HYST, "hyst", NULL, 0, 0644, NULL, 
    207          &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_hyst}, 
     209        {LM90_SYSCTL_LOCAL_HYST, "hyst1", NULL, 0, 0644, NULL, 
     210         &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_local_hyst}, 
     211        {LM90_SYSCTL_REMOTE_HYST, "hyst2", NULL, 0, 0444, NULL, 
     212         &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_remote_hyst}, 
    208213        {LM90_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, 
    209214         &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_alarms}, 
     
    634639} 
    635640 
    636 static void lm90_hyst(struct i2c_client *client, int operation, 
     641/* 
     642 * One quick note about hysteresis. Internally, the hysteresis value 
     643 * is held in a single register by the LM90, as a relative value. 
     644 * This relative value applies to both the local critical temperature 
     645 * and the remote critical temperature. Since all temperatures exported 
     646 * through procfs have to be absolute, we have to do some conversions. 
     647 * The solution retained here is to export two absolute values, one for 
     648 * each critical temperature. In order not to confuse the users too 
     649 * much, only one file is writable. Would we fail to do so, users 
     650 * would probably attempt to write to both files, as if they were 
     651 * independant, and since they aren't, they wouldn't understand why 
     652 * setting one affects the other one (and would probably claim there's 
     653 * a bug in the driver). 
     654 */ 
     655 
     656static void lm90_local_hyst(struct i2c_client *client, int operation, 
    637657        int ctl_name, int *nrels_mag, long *results) 
    638658{ 
     
    644664        { 
    645665                lm90_update_client(client); 
    646                 results[0] = TEMP1_FROM_REG(data->hyst); 
     666                results[0] = TEMP1_FROM_REG(data->local_crit) - 
     667                        TEMP1_FROM_REG(data->hyst); 
    647668                *nrels_mag = 1; 
    648669        } 
     
    651672                if (*nrels_mag >= 1) 
    652673                { 
    653                         data->hyst = HYST_TO_REG(results[0]); 
     674                        data->hyst = HYST_TO_REG(data->local_crit - results[0]); 
    654675                        i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 
    655676                                data->hyst); 
     
    658679} 
    659680 
    660 static void lm90_alarms(struct i2c_client *client, int operation, 
     681static void lm90_remote_hyst(struct i2c_client *client, int operation, 
    661682        int ctl_name, int *nrels_mag, long *results) 
    662683{ 
     
    668689        { 
    669690                lm90_update_client(client); 
     691                results[0] = TEMP1_FROM_REG(data->remote_crit) - 
     692                        TEMP1_FROM_REG(data->hyst); 
     693                *nrels_mag = 1; 
     694        } 
     695} 
     696 
     697static void lm90_alarms(struct i2c_client *client, int operation, 
     698        int ctl_name, int *nrels_mag, long *results) 
     699{ 
     700        struct lm90_data *data = client->data; 
     701 
     702        if (operation == SENSORS_PROC_REAL_INFO) 
     703                *nrels_mag = 0; /* magnitude */ 
     704        else if (operation == SENSORS_PROC_REAL_READ) 
     705        { 
     706                lm90_update_client(client); 
    670707                results[0] = data->alarms; 
    671708                *nrels_mag = 1; 
  • lm-sensors/trunk/lib/chips.c

    r2207 r2210  
    728728      SENSORS_LM90_REMOTE_TEMP, SENSORS_LM90_REMOTE_TEMP, 
    729729      RW, LM90_SYSCTL_REMOTE_TCRIT, VALUE(1), 0 }, 
    730     { SENSORS_LM90_TCRIT_HYST, "hyst", 
    731       NOMAP, NOMAP, 
    732       RW, LM90_SYSCTL_HYST, VALUE(1), 0, "temp_hyst2", 3 }, 
     730    { SENSORS_LM90_LOCAL_TCRIT_HYST, "hyst1", 
     731      SENSORS_LM90_LOCAL_TCRIT, SENSORS_LM90_LOCAL_TCRIT, 
     732      RW, LM90_SYSCTL_LOCAL_HYST, VALUE(1), 0 }, 
     733    { SENSORS_LM90_REMOTE_TCRIT_HYST, "hyst2", 
     734      SENSORS_LM90_REMOTE_TCRIT, SENSORS_LM90_REMOTE_TCRIT, 
     735      R, LM90_SYSCTL_REMOTE_HYST, VALUE(1), 0 }, 
    733736    { SENSORS_LM90_ALARMS, "alarms", 
    734737      NOMAP, NOMAP, 
  • lm-sensors/trunk/lib/chips.h

    r2181 r2210  
    457457#define SENSORS_LM90_REMOTE_LOW 59 /* RW */ 
    458458#define SENSORS_LM90_REMOTE_TCRIT 60 /* RW */ 
    459 #define SENSORS_LM90_TCRIT_HYST 79 /* RW */ 
     459#define SENSORS_LM90_LOCAL_TCRIT_HYST 79 /* RW */ 
     460#define SENSORS_LM90_REMOTE_TCRIT_HYST 80 /* R, see driver source */ 
    460461#define SENSORS_LM90_ALARMS 81 /* R */ 
    461462 
  • lm-sensors/trunk/prog/sensors/chips.c

    r2197 r2210  
    45804580  free_the_label(&label); 
    45814581 
    4582   /* 2.6 tweak: 
    4583    * In 2.4 there is only one, relative hyst value, (default 10). 
    4584    * In 2.6 there are two, absolute values. 
    4585    * The library will link hyst (2.4) to temp_hyst2 (2.6) and we have 
    4586    * to compute the relative value from temp_hyst2 and temp_crit2. 
    4587    * We detect that using the following rules: 
    4588    *  - if hyst is not in the range 0..31, it is absolute (2.6); 
    4589    *  - if hyst exceeds tcrit1 or tcrit2, it is absolute (2.6); 
    4590    *  - if hyst is greater than it would be if considered absolute, 
    4591    *    it is absolute (heuristic); 
    4592    *  - else it is relative (2.4). 
    4593    * Also note that the use of low and high right below is 
    4594    * arbitrary, only to reuse previously defined variables, at the 
    4595    * admitted cost of a lower readability. 
    4596    */ 
    4597   if (!sensors_get_feature(*name, SENSORS_LM90_TCRIT_HYST, &hyst) 
    4598    && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_TCRIT, &low) 
    4599    && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_TCRIT, &high)) { 
    4600     if (hyst<=-0.5 || hyst>=31.5 || hyst>low || hyst>high || hyst>high-hyst) 
    4601       hyst = high-hyst; 
    4602   } else { 
    4603     printf("ERROR: Can't get hyst data!\n"); 
    4604     hyst = 10; 
    4605   } 
    4606  
    46074582  if (!sensors_get_label_and_valid(*name, SENSORS_LM90_LOCAL_TCRIT, 
    4608       &label, &valid)) { 
     4583      &label, &valid) 
     4584   && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_TCRIT, &high) 
     4585   && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_TCRIT_HYST, &hyst)) { 
    46094586    if (valid) { 
    46104587      print_label(label, 10); 
    4611       print_temp_info(low, low-hyst, 0, HYSTONLY, 0, 0); 
     4588      print_temp_info(high, hyst, 0, HYSTONLY, 0, 0); 
    46124589      printf("\n"); 
    46134590    } 
     
    46174594 
    46184595  if (!sensors_get_label_and_valid(*name, SENSORS_LM90_REMOTE_TCRIT, 
    4619       &label, &valid)) { 
     4596      &label, &valid) 
     4597   && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_TCRIT, &high) 
     4598   && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_TCRIT_HYST, &hyst)) { 
    46204599    if (valid) { 
    46214600      print_label(label, 10); 
    4622       print_temp_info(high, high-hyst, 0, HYSTONLY, 0, 0); 
     4601      print_temp_info(high, hyst, 0, HYSTONLY, 0, 0); 
    46234602      printf("\n"); 
    46244603    }