Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/max6690.c
Show All 12 Lines | |||||
device_printf(dev, "WARNING: No MAX6690 sensors detected!\n"); | device_printf(dev, "WARNING: No MAX6690 sensors detected!\n"); | ||||
sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct max6690_sensor), | sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct max6690_sensor), | ||||
M_MAX6690, M_WAITOK | M_ZERO); | M_MAX6690, 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, "MAX6690 Sensor Information"); | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "MAX6690 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 = max6690_fill_sensor_prop(dev); | sc->sc_nsensors = max6690_fill_sensor_prop(dev); | ||||
/* Register with powermac_thermal */ | /* Register with powermac_thermal */ | ||||
for (i = 0; i < sc->sc_nsensors; i++) | for (i = 0; i < sc->sc_nsensors; i++) | ||||
pmac_thermal_sensor_register(&sc->sc_sensors[i].therm); | pmac_thermal_sensor_register(&sc->sc_sensors[i].therm); | ||||
/* 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; | ||||
sprintf(sysctl_desc,"%s %s", sc->sc_sensors[i].therm.name, | sprintf(sysctl_desc,"%s %s", sc->sc_sensors[i].therm.name, | ||||
"(C)"); | "(C)"); | ||||
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"); | |||||
/* 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, "temp", | SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "temp", | ||||
CTLTYPE_INT | CTLFLAG_RD, dev, i % 2, | CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, dev, i % 2, | ||||
max6690_sensor_sysctl, "IK", sysctl_desc); | max6690_sensor_sysctl, "IK", sysctl_desc); | ||||
} | } | ||||
/* Dump sensor location & ID. */ | /* Dump sensor location & ID. */ | ||||
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\n", | device_printf(dev, "Location : %s ID: %d\n", | ||||
sc->sc_sensors[i].therm.name, | sc->sc_sensors[i].therm.name, | ||||
Show All 12 Lines |