sensor: Add ECC sensor type
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 13 May 2015 11:24:03 +0000 (19:24 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 13 May 2015 11:24:03 +0000 (19:24 +0800)
sbin/sysctl/sysctl.c
sys/dev/misc/ecc/ecc_e5.c
sys/sys/sensors.h
usr.sbin/sensorsd/sensorsd.c

index 59afd0b..47bf8bb 100644 (file)
@@ -400,6 +400,7 @@ S_sensor(int l2, void *p)
                case SENSOR_INDICATOR:
                        printf("%s", s->value ? "On" : "Off");
                        break;
+               case SENSOR_ECC:
                case SENSOR_INTEGER:
                        printf("%jd", (intmax_t)s->value);
                        break;
index c64b586..74a3bc0 100644 (file)
@@ -289,7 +289,7 @@ ecc_e5_attach(device_t dev)
                ksnprintf(sens->desc, sizeof(sens->desc),
                    "node%d chan%d DIMM%d ecc",
                    sc->ecc_node, sc->ecc_chan->chan_ext, dimm);
-               sens->type = SENSOR_INTEGER;
+               sens->type = SENSOR_ECC;
                sensor_set(sens, 0, SENSOR_S_OK);
                dimm_sensor_attach(dimm_sc->dimm_softc, sens);
 
index d9984de..a73bec7 100644 (file)
@@ -49,6 +49,13 @@ enum sensor_type {
        SENSOR_LUX,                     /* illuminance (mulx) */
        SENSOR_DRIVE,                   /* disk */
        SENSOR_TIMEDELTA,               /* system time error (nSec) */
+       SENSOR_ECC,                     /* memory ecc */
+       SENSOR_RESERVED_A,              /* reserved */
+       SENSOR_RESERVED_B,              /* reserved */
+       SENSOR_RESERVED_C,              /* reserved */
+       SENSOR_RESERVED_D,              /* reserved */
+       SENSOR_RESERVED_E,              /* reserved */
+       SENSOR_RESERVED_F,              /* reserved */
        SENSOR_MAX_TYPES
 };
 
@@ -68,6 +75,13 @@ static const char * const sensor_type_s[SENSOR_MAX_TYPES + 1] = {
        "illuminance",
        "drive",
        "timedelta",
+       "ecc",
+       "reserved_a"
+       "reserved_b"
+       "reserved_c"
+       "reserved_d"
+       "reserved_e"
+       "reserved_f"
        "undefined"
 };
 
index 7422124..a01b880 100644 (file)
@@ -636,6 +636,7 @@ print_sensor(enum sensor_type type, int64_t value)
        case SENSOR_INDICATOR:
                snprintf(fbuf, RFBUFSIZ, "%s", value? "On" : "Off");
                break;
+       case SENSOR_ECC:
        case SENSOR_INTEGER:
                snprintf(fbuf, RFBUFSIZ, "%"PRId64, value);
                break;
@@ -751,6 +752,7 @@ get_val(char *buf, int upper, enum sensor_type type)
        case SENSOR_PERCENT:
                rval = val * 1000.0;
                break;
+       case SENSOR_ECC:
        case SENSOR_INDICATOR:
        case SENSOR_INTEGER:
        case SENSOR_DRIVE: