From e836047a83b5930335f2debcf20c9e3b53101e51 Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sun, 14 Oct 2001 15:18:37 +0000 Subject: [PATCH] merge it87 separate alarms_* /proc entries to single alarms entry to standardize git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1202 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/it87.c | 60 ++++++++-------------------------------- kernel/include/sensors.h | 26 ++++++++--------- lib/chips.c | 8 ++---- lib/chips.h | 1 + prog/sensors/chips.c | 55 +++++++++++++----------------------- 5 files changed, 45 insertions(+), 105 deletions(-) diff --git a/kernel/chips/it87.c b/kernel/chips/it87.c index 3c6bebe3..7a8bcc6a 100644 --- a/kernel/chips/it87.c +++ b/kernel/chips/it87.c @@ -65,7 +65,7 @@ static unsigned int normal_isa[] = { 0x0290, SENSORS_ISA_END }; static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; /* Insmod parameters */ -SENSORS_INSMOD_1(it87); +SENSORS_INSMOD_4(it87, it8705, it8712, sis950); /* Update battery voltage after every reading if true */ @@ -232,9 +232,7 @@ struct it87_data { u8 temp_low[3]; /* Register value */ u8 fan_div[3]; /* Register encoding, shifted right */ u8 vid; /* Register encoding, combined */ - u8 alarms_fan; /* Register value */ - u8 alarms_vin; /* Register value */ - u8 alarms_temp; /* Register value */ + u32 alarms; /* Register encoding, combined */ }; @@ -270,11 +268,7 @@ static void it87_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void it87_vid(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); -static void it87_alarms_fan(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results); -static void it87_alarms_vin(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results); -static void it87_alarms_temp(struct i2c_client *client, int operation, +static void it87_alarms(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void it87_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); @@ -336,12 +330,8 @@ static ctl_table it87_dir_table_template[] = { &i2c_sysctl_real, NULL, &it87_vid}, {IT87_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &it87_fan_div}, - {IT87_SYSCTL_ALARMS_FAN, "alarms_fan", NULL, 0, 0444, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &it87_alarms_fan}, - {IT87_SYSCTL_ALARMS_VIN, "alarms_vin", NULL, 0, 0444, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &it87_alarms_vin}, - {IT87_SYSCTL_ALARMS_TEMP, "alarms_temp", NULL, 0, 0444, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &it87_alarms_temp}, + {IT87_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real, + &i2c_sysctl_real, NULL, &it87_alarms}, {0} }; @@ -727,12 +717,10 @@ void it87_update_client(struct i2c_client *client) data->fan_div[1] = (i >> 3) & 0x07; data->fan_div[2] = 1; - data->alarms_fan = - it87_read_value(client, IT87_REG_ALARM1) & 0x7; - data->alarms_vin = - it87_read_value(client, IT87_REG_ALARM2) & 0xff; - data->alarms_temp = - it87_read_value(client, IT87_REG_ALARM3) & 0x7; + data->alarms = + it87_read_value(client, IT87_REG_ALARM1) | + (it87_read_value(client, IT87_REG_ALARM2) << 8) | + (it87_read_value(client, IT87_REG_ALARM3) << 16); data->last_updated = jiffies; data->valid = 1; @@ -855,7 +843,7 @@ void it87_vid(struct i2c_client *client, int operation, int ctl_name, } } -void it87_alarms_fan(struct i2c_client *client, int operation, +void it87_alarms(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { struct it87_data *data = client->data; @@ -863,33 +851,7 @@ void it87_alarms_fan(struct i2c_client *client, int operation, *nrels_mag = 0; else if (operation == SENSORS_PROC_REAL_READ) { it87_update_client(client); - results[0] = ALARMS_FROM_REG(data->alarms_fan); - *nrels_mag = 1; - } -} - -void it87_alarms_vin(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results) -{ - struct it87_data *data = client->data; - if (operation == SENSORS_PROC_REAL_INFO) - *nrels_mag = 0; - else if (operation == SENSORS_PROC_REAL_READ) { - it87_update_client(client); - results[0] = ALARMS_FROM_REG(data->alarms_vin); - *nrels_mag = 1; - } -} - -void it87_alarms_temp(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results) -{ - struct it87_data *data = client->data; - if (operation == SENSORS_PROC_REAL_INFO) - *nrels_mag = 0; - else if (operation == SENSORS_PROC_REAL_READ) { - it87_update_client(client); - results[0] = ALARMS_FROM_REG(data->alarms_temp); + results[0] = ALARMS_FROM_REG(data->alarms); *nrels_mag = 1; } } diff --git a/kernel/include/sensors.h b/kernel/include/sensors.h index ea7ea572..ebd6fcab 100644 --- a/kernel/include/sensors.h +++ b/kernel/include/sensors.h @@ -487,24 +487,22 @@ #define IT87_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ #define IT87_SYSCTL_VID 1300 /* Volts * 100 */ #define IT87_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define IT87_SYSCTL_ALARMS_FAN 2001 /* bitvector */ -#define IT87_SYSCTL_ALARMS_VIN 2002 /* bitvector */ -#define IT87_SYSCTL_ALARMS_TEMP 2003 /* bitvector */ +#define IT87_SYSCTL_ALARMS 2004 /* bitvector */ -#define IT87_ALARM_IN0 0x0001 -#define IT87_ALARM_IN1 0x0002 -#define IT87_ALARM_IN2 0x0004 -#define IT87_ALARM_IN3 0x0008 -#define IT87_ALARM_IN4 0x0010 -#define IT87_ALARM_IN5 0x0020 -#define IT87_ALARM_IN6 0x0040 -#define IT87_ALARM_IN7 0x0080 +#define IT87_ALARM_IN0 0x000100 +#define IT87_ALARM_IN1 0x000200 +#define IT87_ALARM_IN2 0x000400 +#define IT87_ALARM_IN3 0x000800 +#define IT87_ALARM_IN4 0x001000 +#define IT87_ALARM_IN5 0x002000 +#define IT87_ALARM_IN6 0x004000 +#define IT87_ALARM_IN7 0x008000 #define IT87_ALARM_FAN1 0x0001 #define IT87_ALARM_FAN2 0x0002 #define IT87_ALARM_FAN3 0x0004 -#define IT87_ALARM_TEMP1 0x0001 -#define IT87_ALARM_TEMP2 0x0002 -#define IT87_ALARM_TEMP3 0x0004 +#define IT87_ALARM_TEMP1 0x00010000 +#define IT87_ALARM_TEMP2 0x00020000 +#define IT87_ALARM_TEMP3 0x00040000 #define FSCPOS_SYSCTL_VOLT0 1000 /* 12 volt supply */ #define FSCPOS_SYSCTL_VOLT1 1001 /* 5 volt supply */ diff --git a/lib/chips.c b/lib/chips.c index 9bfd394b..268c3a30 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -2227,12 +2227,8 @@ static sensors_chip_feature it87_features[] = { SENSORS_IT87_FAN3_DIV, "fan3_div", SENSORS_IT87_FAN3, SENSORS_NO_MAPPING, SENSORS_MODE_R, IT87_SYSCTL_FAN_DIV, VALUE(3), 0 }, - { SENSORS_IT87_ALARMS_FAN, "alarms_fan", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, IT87_SYSCTL_ALARMS_FAN, VALUE(1), 0 }, - { SENSORS_IT87_ALARMS_VIN, "alarms_vin", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, IT87_SYSCTL_ALARMS_VIN, VALUE(1), 0 }, - { SENSORS_IT87_ALARMS_TEMP, "alarms_temp", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, IT87_SYSCTL_ALARMS_TEMP, VALUE(1), 0 }, + { SENSORS_IT87_ALARMS, "alarms", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, IT87_SYSCTL_ALARMS, VALUE(1), 0 }, { 0 } }; diff --git a/lib/chips.h b/lib/chips.h index 2cc1ecf6..9b9502ea 100644 --- a/lib/chips.h +++ b/lib/chips.h @@ -1020,6 +1020,7 @@ #define SENSORS_IT87_ALARMS_FAN 81 /* R */ #define SENSORS_IT87_ALARMS_VIN 82 /* R */ #define SENSORS_IT87_ALARMS_TEMP 83 /* R */ +#define SENSORS_IT87_ALARMS 84 /* R */ /* fsc poseidon chip */ diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 2046686c..84e77158 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -2430,33 +2430,16 @@ void print_it87(const sensors_chip_name *name) { char *label = NULL; double cur, min, max, fdiv; - int alarms_fan, alarms_vin, alarms_temp, valid; + int alarms, valid; - if (!sensors_get_feature(*name,SENSORS_IT87_ALARMS_FAN, &cur)) { - alarms_fan = cur + 0.5; + if (!sensors_get_feature(*name,SENSORS_IT87_ALARMS, &cur)) { + alarms = cur + 0.5; } else { - printf("ERROR: Can't get fan alarm data!\n"); - alarms_fan = 0; + printf("ERROR: Can't get alarm data!\n"); + alarms = 0; } - if (!sensors_get_feature(*name,SENSORS_IT87_ALARMS_VIN, &cur)) { - alarms_vin = cur + 0.5; - } - else { - printf("ERROR: Can't get vin alarm data!\n"); - alarms_vin = 0; - } - - if (!sensors_get_feature(*name,SENSORS_IT87_ALARMS_TEMP, &cur)) { - alarms_temp = cur + 0.5; - } - else { - printf("ERROR: Can't get temp alarm data!\n"); - alarms_temp = 0; - } - - if (!sensors_get_label_and_valid(*name,SENSORS_IT87_IN0,&label,&valid) && !sensors_get_feature(*name,SENSORS_IT87_IN0,&cur) && !sensors_get_feature(*name,SENSORS_IT87_IN0_MIN,&min) && @@ -2464,7 +2447,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN0?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN0?"ALARM":""); } } else printf("ERROR: Can't get IN0 data!\n"); @@ -2476,7 +2459,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN1?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN1?"ALARM":""); } } else printf("ERROR: Can't get IN1 data!\n"); @@ -2488,7 +2471,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN2?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN2?"ALARM":""); } } else printf("ERROR: Can't get IN2 data!\n"); @@ -2500,7 +2483,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN3?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN3?"ALARM":""); } } else printf("ERROR: Can't get IN3 data!\n"); @@ -2512,7 +2495,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN4?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN4?"ALARM":""); } } else printf("ERROR: Can't get IN4 data!\n"); @@ -2524,7 +2507,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN5?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN5?"ALARM":""); } } else printf("ERROR: Can't get IN5 data!\n"); @@ -2536,7 +2519,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN6?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN6?"ALARM":""); } } else printf("ERROR: Can't get IN6 data!\n"); @@ -2548,7 +2531,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", - cur,min,max,alarms_vin&IT87_ALARM_IN7?"ALARM":""); + cur,min,max,alarms&IT87_ALARM_IN7?"ALARM":""); } } else printf("ERROR: Can't get IN7 data!\n"); @@ -2570,7 +2553,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%4.0f RPM (min = %4.0f RPM, div = %1.0f) %s\n", - cur,min,fdiv, alarms_fan&IT87_ALARM_FAN1?"ALARM":""); + cur,min,fdiv, alarms&IT87_ALARM_FAN1?"ALARM":""); } } else printf("ERROR: Can't get FAN1 data!\n"); @@ -2582,7 +2565,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%4.0f RPM (min = %4.0f RPM, div = %1.0f) %s\n", - cur,min,fdiv, alarms_fan&IT87_ALARM_FAN2?"ALARM":""); + cur,min,fdiv, alarms&IT87_ALARM_FAN2?"ALARM":""); } } else printf("ERROR: Can't get FAN2 data!\n"); @@ -2594,7 +2577,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); printf("%4.0f RPM (min = %4.0f RPM, div = %1.0f) %s\n", - cur,min,fdiv, alarms_fan&IT87_ALARM_FAN3?"ALARM":""); + cur,min,fdiv, alarms&IT87_ALARM_FAN3?"ALARM":""); } } else printf("ERROR: Can't get FAN3 data!\n"); @@ -2607,7 +2590,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); print_temp_info( cur, max, min, MINMAX, 0, 0); - printf( " %s\n", alarms_temp & IT87_ALARM_TEMP1 ? "ALARM" : "" ); + printf( " %s\n", alarms & IT87_ALARM_TEMP1 ? "ALARM" : "" ); } } else printf("ERROR: Can't get TEMP1 data!\n"); @@ -2619,7 +2602,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); print_temp_info( cur, max, min, MINMAX, 0, 0); - printf( " %s\n", alarms_temp & IT87_ALARM_TEMP2 ? "ALARM" : "" ); + printf( " %s\n", alarms & IT87_ALARM_TEMP2 ? "ALARM" : "" ); } } else printf("ERROR: Can't get TEMP2 data!\n"); @@ -2631,7 +2614,7 @@ void print_it87(const sensors_chip_name *name) if (valid) { print_label(label,10); print_temp_info( cur, max, min, MINMAX, 0, 0); - printf( " %s\n", alarms_temp & IT87_ALARM_TEMP3 ? "ALARM" : "" ); + printf( " %s\n", alarms & IT87_ALARM_TEMP3 ? "ALARM" : "" ); } } else printf("ERROR: Can't get TEMP3 data!\n");