Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/ad7417.c
Show All 12 Lines | |||||
device_printf(dev, "WARNING: No AD7417 sensors detected!\n"); | device_printf(dev, "WARNING: No AD7417 sensors detected!\n"); | ||||
sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct ad7417_sensor), | sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct ad7417_sensor), | ||||
M_AD7417, M_WAITOK | M_ZERO); | M_AD7417, M_WAITOK | M_ZERO); | ||||
ctx = device_get_sysctl_ctx(dev); | ctx = device_get_sysctl_ctx(dev); | ||||
sensroot_oid = SYSCTL_ADD_NODE(ctx, | sensroot_oid = SYSCTL_ADD_NODE(ctx, | ||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor", | SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor", | ||||
CTLFLAG_RD, 0, "AD7417 Sensor Information"); | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "AD7417 Sensor Information"); | ||||
/* Now we can fill the properties into the allocated struct. */ | /* Now we can fill the properties into the allocated struct. */ | ||||
sc->sc_nsensors = ad7417_fill_sensor_prop(dev); | sc->sc_nsensors = ad7417_fill_sensor_prop(dev); | ||||
/* Add sysctls for the sensors. */ | /* Add sysctls for the sensors. */ | ||||
for (i = 0; i < sc->sc_nsensors; i++) { | for (i = 0; i < sc->sc_nsensors; i++) { | ||||
for (j = 0; j < strlen(sc->sc_sensors[i].therm.name); j++) { | for (j = 0; j < strlen(sc->sc_sensors[i].therm.name); j++) { | ||||
sysctl_name[j] = | sysctl_name[j] = | ||||
tolower(sc->sc_sensors[i].therm.name[j]); | tolower(sc->sc_sensors[i].therm.name[j]); | ||||
if (isspace(sysctl_name[j])) | if (isspace(sysctl_name[j])) | ||||
sysctl_name[j] = '_'; | sysctl_name[j] = '_'; | ||||
} | } | ||||
sysctl_name[j] = 0; | sysctl_name[j] = 0; | ||||
oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid), | oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid), | ||||
OID_AUTO, | OID_AUTO, sysctl_name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
sysctl_name, CTLFLAG_RD, 0, | "Sensor Information"); | ||||
"Sensor Information"); | |||||
if (sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR) { | if (sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR) { | ||||
unit = "temp"; | unit = "temp"; | ||||
desc = "sensor unit (C)"; | desc = "sensor unit (C)"; | ||||
} else { | } else { | ||||
unit = "volt"; | unit = "volt"; | ||||
desc = "sensor unit (mV)"; | desc = "sensor unit (mV)"; | ||||
} | } | ||||
/* I use i to pass the sensor id. */ | /* I use i to pass the sensor id. */ | ||||
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | ||||
unit, CTLTYPE_INT | CTLFLAG_RD, dev, | unit, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, dev, | ||||
i, ad7417_sensor_sysctl, | i, ad7417_sensor_sysctl, | ||||
sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR ? | sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR ? "IK" : "I", | ||||
"IK" : "I", desc); | desc); | ||||
} | } | ||||
/* Dump sensor location, ID & type. */ | /* Dump sensor location, ID & type. */ | ||||
if (bootverbose) { | if (bootverbose) { | ||||
device_printf(dev, "Sensors\n"); | device_printf(dev, "Sensors\n"); | ||||
for (i = 0; i < sc->sc_nsensors; i++) { | for (i = 0; i < sc->sc_nsensors; i++) { | ||||
device_printf(dev, "Location: %s ID: %d type: %d\n", | device_printf(dev, "Location: %s ID: %d type: %d\n", | ||||
sc->sc_sensors[i].therm.name, | sc->sc_sensors[i].therm.name, | ||||
sc->sc_sensors[i].id, | sc->sc_sensors[i].id, | ||||
Show All 12 Lines |