Changeset 2210
- Timestamp:
- 01/09/04 22:26:54 (9 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 4 modified
-
kernel/chips/lm90.c (modified) (9 diffs)
-
lib/chips.c (modified) (1 diff)
-
lib/chips.h (modified) (1 diff)
-
prog/sensors/chips.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/lm90.c
r2192 r2210 131 131 static void lm90_remote_tcrit(struct i2c_client *client, int operation, 132 132 int ctl_name, int *nrels_mag, long *results); 133 static void lm90_hyst(struct i2c_client *client, int operation, 133 static void lm90_local_hyst(struct i2c_client *client, int operation, 134 int ctl_name, int *nrels_mag, long *results); 135 static void lm90_remote_hyst(struct i2c_client *client, int operation, 134 136 int ctl_name, int *nrels_mag, long *results); 135 137 static void lm90_alarms(struct i2c_client *client, int operation, … … 165 167 u16 remote_temp, remote_high, remote_low; /* combined */ 166 168 u8 local_crit, remote_crit; 167 u8 hyst; 169 u8 hyst; /* linked to two sysctl files (hyst1 RW, hyst2 RO) */ 168 170 u16 alarms; /* bitvector, combined */ 169 171 }; … … 180 182 #define LM90_SYSCTL_LOCAL_TCRIT 1204 181 183 #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 183 186 #define LM90_SYSCTL_ALARMS 1210 184 187 … … 204 207 {LM90_SYSCTL_REMOTE_TCRIT, "tcrit2", NULL, 0, 0644, NULL, 205 208 &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}, 208 213 {LM90_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, 209 214 &i2c_proc_real, &i2c_sysctl_real, NULL, &lm90_alarms}, … … 634 639 } 635 640 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 656 static void lm90_local_hyst(struct i2c_client *client, int operation, 637 657 int ctl_name, int *nrels_mag, long *results) 638 658 { … … 644 664 { 645 665 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); 647 668 *nrels_mag = 1; 648 669 } … … 651 672 if (*nrels_mag >= 1) 652 673 { 653 data->hyst = HYST_TO_REG( results[0]);674 data->hyst = HYST_TO_REG(data->local_crit - results[0]); 654 675 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 655 676 data->hyst); … … 658 679 } 659 680 660 static void lm90_ alarms(struct i2c_client *client, int operation,681 static void lm90_remote_hyst(struct i2c_client *client, int operation, 661 682 int ctl_name, int *nrels_mag, long *results) 662 683 { … … 668 689 { 669 690 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 697 static 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); 670 707 results[0] = data->alarms; 671 708 *nrels_mag = 1; -
lm-sensors/trunk/lib/chips.c
r2207 r2210 728 728 SENSORS_LM90_REMOTE_TEMP, SENSORS_LM90_REMOTE_TEMP, 729 729 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 }, 733 736 { SENSORS_LM90_ALARMS, "alarms", 734 737 NOMAP, NOMAP, -
lm-sensors/trunk/lib/chips.h
r2181 r2210 457 457 #define SENSORS_LM90_REMOTE_LOW 59 /* RW */ 458 458 #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 */ 460 461 #define SENSORS_LM90_ALARMS 81 /* R */ 461 462 -
lm-sensors/trunk/prog/sensors/chips.c
r2197 r2210 4580 4580 free_the_label(&label); 4581 4581 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 have4586 * 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 is4594 * arbitrary, only to reuse previously defined variables, at the4595 * 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 4607 4582 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)) { 4609 4586 if (valid) { 4610 4587 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); 4612 4589 printf("\n"); 4613 4590 } … … 4617 4594 4618 4595 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)) { 4620 4599 if (valid) { 4621 4600 print_label(label, 10); 4622 print_temp_info(high, h igh-hyst, 0, HYSTONLY, 0, 0);4601 print_temp_info(high, hyst, 0, HYSTONLY, 0, 0); 4623 4602 printf("\n"); 4624 4603 }
