diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-12-23 17:46:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-12-23 17:46:40 +0000 |
commit | 456453067d1414c6f4097d6aeaf996624183d72b (patch) | |
tree | b3a5f4f9a05a1aba0dd603c6eb3a6ff0cd86ee9f | |
parent | 2da4a587cf08c4fd33f160fe0f40ff89d9d3a3c3 (diff) |
adapt to new two-level sensor api; Constantine A. Murenin
52 files changed, 451 insertions, 527 deletions
diff --git a/sys/arch/i386/i386/esm.c b/sys/arch/i386/i386/esm.c index 550b017a4de..bd3e25e4c80 100644 --- a/sys/arch/i386/i386/esm.c +++ b/sys/arch/i386/i386/esm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esm.c,v 1.43 2006/11/26 11:21:55 mbalmer Exp $ */ +/* $OpenBSD: esm.c,v 1.44 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -115,6 +115,7 @@ struct esm_softc { TAILQ_HEAD(, esm_sensor) sc_sensors; struct esm_sensor *sc_nextsensor; + struct sensordev sc_sensordev; int sc_retries; volatile int sc_step; struct timeout sc_timeout; @@ -926,11 +927,13 @@ esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap, break; } + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); for (j = 0; j < nsensors; j++) { s[j].type = esm_typemap[es->es_type]; - strlcpy(s[j].device, DEVNAME(sc), sizeof(s[j].device)); - sensor_add(&s[j]); + sensor_attach(&sc->sc_sensordev, &s[j]); } + sensordev_install(&sc->sc_sensordev); es->es_sensor = s; TAILQ_INSERT_TAIL(&sc->sc_sensors, es, es_entry); diff --git a/sys/arch/macppc/dev/asms.c b/sys/arch/macppc/dev/asms.c index 17724436754..5c71f5219ec 100644 --- a/sys/arch/macppc/dev/asms.c +++ b/sys/arch/macppc/dev/asms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asms.c,v 1.3 2006/01/19 17:08:39 grange Exp $ */ +/* $OpenBSD: asms.c,v 1.4 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org> * @@ -62,6 +62,7 @@ struct asms_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ASMS_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int asms_match(struct device *, void *, void *); @@ -247,9 +248,8 @@ asms_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ASMS_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ASMS_DATA_X].type = SENSOR_INTEGER; strlcpy(sc->sc_sensor[ASMS_DATA_X].desc, "X_ACCEL", @@ -269,7 +269,8 @@ asms_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ASMS_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/arch/macppc/dev/smu.c b/sys/arch/macppc/dev/smu.c index da9c5a39b98..359ddfafa74 100644 --- a/sys/arch/macppc/dev/smu.c +++ b/sys/arch/macppc/dev/smu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smu.c,v 1.12 2006/03/20 22:40:18 kettenis Exp $ */ +/* $OpenBSD: smu.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -75,6 +75,8 @@ struct smu_softc { struct smu_sensor sc_sensors[SMU_MAXSENSORS]; int sc_num_sensors; + struct sensordev sc_sensordev; + u_int16_t sc_cpu_diode_scale; int16_t sc_cpu_diode_offset; u_int16_t sc_cpu_volt_scale; @@ -268,8 +270,6 @@ smu_attach(struct device *parent, struct device *self, void *aux) } fan = &sc->sc_fans[sc->sc_num_fans++]; - strlcpy(fan->sensor.device, sc->sc_dev.dv_xname, - sizeof(fan->sensor.device)); fan->sensor.type = SENSOR_FANRPM; fan->sensor.flags = SENSOR_FINVALID; fan->reg = reg; @@ -291,7 +291,7 @@ smu_attach(struct device *parent, struct device *self, void *aux) /* Start running fans at their "unmanaged" speed. */ smu_fan_set_rpm(sc, fan, fan->unmanaged_rpm); - sensor_add(&fan->sensor); + sensor_attach(&sc->sc_sensordev, &fan->sensor); } /* Sensors */ @@ -302,8 +302,6 @@ smu_attach(struct device *parent, struct device *self, void *aux) continue; sensor = &sc->sc_sensors[sc->sc_num_sensors++]; - strlcpy(sensor->sensor.device, sc->sc_dev.dv_xname, - sizeof(sensor->sensor.device)); sensor->sensor.flags = SENSOR_FINVALID; sensor->reg = val; @@ -321,9 +319,14 @@ smu_attach(struct device *parent, struct device *self, void *aux) strlcpy(loc, "Unknown", sizeof loc); strlcpy(sensor->sensor.desc, loc, sizeof sensor->sensor.desc); - sensor_add(&sensor->sensor); + sensor_attach(&sc->sc_sensordev, &sensor->sensor); } + /* Register sensor device with sysctl */ + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + sensordev_install(&sc->sc_sensordev); + /* CPU temperature diode calibration */ smu_get_datablock(sc, 0x18, data, sizeof data); sc->sc_cpu_diode_scale = (data[4] << 8) + data[5]; diff --git a/sys/arch/sparc64/dev/pcf8591_ofw.c b/sys/arch/sparc64/dev/pcf8591_ofw.c index bc25659b96e..2b8b661b13d 100644 --- a/sys/arch/sparc64/dev/pcf8591_ofw.c +++ b/sys/arch/sparc64/dev/pcf8591_ofw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcf8591_ofw.c,v 1.1 2006/02/10 05:28:56 djm Exp $ */ +/* $OpenBSD: pcf8591_ofw.c,v 1.2 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Damien Miller <djm@openbsd.org> @@ -38,6 +38,7 @@ struct pcfadc_softc { u_char sc_xlate[256]; u_int sc_nchan; struct pcfadc_channel sc_channels[PCF8591_CHANNELS]; + struct sensordev sc_sensordev; }; int pcfadc_match(struct device *, void *, void *); @@ -124,9 +125,6 @@ pcfadc_attach(struct device *parent, struct device *self, void *aux) for (i = 0; i < sc->sc_nchan; i++) { struct pcfadc_channel *chp = &sc->sc_channels[i]; - bzero(&chp->chan_sensor, sizeof(chp->chan_sensor)); - strlcpy(chp->chan_sensor.device, sc->sc_dev.dv_xname, - sizeof(chp->chan_sensor.device)); chp->chan_sensor.type = SENSOR_TEMP; if (cp >= desc + dlen) { @@ -172,15 +170,21 @@ pcfadc_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < sc->sc_nchan; i++) if (!(sc->sc_channels[i].chan_sensor.flags & SENSOR_FINVALID)) - sensor_add(&sc->sc_channels[i].chan_sensor); + sensor_attach(&sc->sc_sensordev, + &sc->sc_channels[i].chan_sensor); if (sensor_task_register(sc, pcfadc_refresh, 5)) { printf(": unable to register update task\n"); return; } + sensordev_install(&sc->sc_sensordev); + printf("\n"); } diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index 8b37c7fbbcc..b9f3ff7b7b8 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */ +/* $OpenBSD: acpiac.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -80,10 +80,12 @@ acpiac_attach(struct device *parent, struct device *self, void *aux) else printf(" in unknown state"); - strlcpy(sc->sens[0].device, DEVNAME(sc), sizeof(sc->sens[0].device)); - strlcpy(sc->sens[0].desc, "power supply", sizeof(sc->sens[2].desc)); + strlcpy(sc->sc_sensdev.xname, DEVNAME(sc), + sizeof(sc->sc_sensdev.xname)); + strlcpy(sc->sens[0].desc, "power supply", sizeof(sc->sens[0].desc)); sc->sens[0].type = SENSOR_INDICATOR; - sensor_add(&sc->sens[0]); + sensor_attach(&sc->sc_sensdev, &sc->sens[0]); + sensordev_install(&sc->sc_sensdev); sc->sens[0].value = sc->sc_ac_stat; } diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index ca8e76b0d8c..e20ae8f01b7 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.35 2006/12/21 19:59:02 deraadt Exp $ */ +/* $OpenBSD: acpibat.c,v 1.36 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -104,64 +104,64 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) void acpibat_monitor(struct acpibat_softc *sc) { - int i, type; + int type; /* assume _BIF and _BST have been called */ - memset(sc->sc_sens, 0, sizeof(sc->sc_sens)); - for (i = 0; i < 8; i++) - strlcpy(sc->sc_sens[i].device, DEVNAME(sc), - sizeof(sc->sc_sens[i].device)); + strlcpy(sc->sc_sensdev.xname, DEVNAME(sc), + sizeof(sc->sc_sensdev.xname)); type = sc->sc_bif.bif_power_unit ? SENSOR_AMPHOUR : SENSOR_WATTHOUR; strlcpy(sc->sc_sens[0].desc, "last full capacity", sizeof(sc->sc_sens[0].desc)); sc->sc_sens[0].type = type; - sensor_add(&sc->sc_sens[0]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[0]); sc->sc_sens[0].value = sc->sc_bif.bif_last_capacity * 1000; strlcpy(sc->sc_sens[1].desc, "warning capacity", sizeof(sc->sc_sens[1].desc)); sc->sc_sens[1].type = type; - sensor_add(&sc->sc_sens[1]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[1]); sc->sc_sens[1].value = sc->sc_bif.bif_warning * 1000; strlcpy(sc->sc_sens[2].desc, "low capacity", sizeof(sc->sc_sens[2].desc)); sc->sc_sens[2].type = type; - sensor_add(&sc->sc_sens[2]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[2]); sc->sc_sens[2].value = sc->sc_bif.bif_low * 1000; strlcpy(sc->sc_sens[3].desc, "voltage", sizeof(sc->sc_sens[3].desc)); sc->sc_sens[3].type = SENSOR_VOLTS_DC; - sensor_add(&sc->sc_sens[3]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[3]); sc->sc_sens[3].status = SENSOR_S_OK; sc->sc_sens[3].value = sc->sc_bif.bif_voltage * 1000; strlcpy(sc->sc_sens[4].desc, "battery unknown", sizeof(sc->sc_sens[4].desc)); sc->sc_sens[4].type = SENSOR_INTEGER; - sensor_add(&sc->sc_sens[4]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[4]); sc->sc_sens[4].status = SENSOR_S_UNKNOWN; sc->sc_sens[4].value = sc->sc_bst.bst_state; strlcpy(sc->sc_sens[5].desc, "rate", sizeof(sc->sc_sens[5].desc)); sc->sc_sens[5].type = SENSOR_INTEGER; - sensor_add(&sc->sc_sens[5]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[5]); sc->sc_sens[5].value = sc->sc_bst.bst_rate; strlcpy(sc->sc_sens[6].desc, "remaining capacity", sizeof(sc->sc_sens[6].desc)); sc->sc_sens[6].type = type; - sensor_add(&sc->sc_sens[6]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[6]); sc->sc_sens[6].value = sc->sc_bst.bst_capacity * 1000; strlcpy(sc->sc_sens[7].desc, "current voltage", sizeof(sc->sc_sens[7].desc)); sc->sc_sens[7].type = SENSOR_VOLTS_DC; - sensor_add(&sc->sc_sens[7]); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[7]); sc->sc_sens[7].status = SENSOR_S_OK; sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000; + + sensordev_install(&sc->sc_sensdev); } void diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index 93b4f6f1bc6..4834910f2fb 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */ +/* $OpenBSD: acpidev.h,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> @@ -258,7 +258,8 @@ struct acpiac_softc { int sc_ac_stat; - struct sensor sens[1]; /* XXX debug only */ + struct sensor sens[1]; /* XXX debug only */ + struct sensordev sc_sensdev; }; struct acpibat_softc { @@ -274,6 +275,7 @@ struct acpibat_softc { struct acpibat_bst sc_bst; volatile int sc_bat_present; - struct sensor sc_sens[8]; /* XXX debug only */ + struct sensor sc_sens[8]; /* XXX debug only */ + struct sensordev sc_sensdev; }; #endif /* __DEV_ACPI_ACPIDEV_H__ */ diff --git a/sys/dev/acpi/acpitz.c b/sys/dev/acpi/acpitz.c index 7d06407816a..2d4f9200136 100644 --- a/sys/dev/acpi/acpitz.c +++ b/sys/dev/acpi/acpitz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpitz.c,v 1.12 2006/12/21 11:23:41 deraadt Exp $ */ +/* $OpenBSD: acpitz.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> @@ -52,6 +52,7 @@ struct acpitz_softc { int sc_tc2; int sc_lasttmp; struct sensor sc_sens; + struct sensordev sc_sensdev; }; int acpitz_match(struct device *, void *, void *); @@ -128,12 +129,13 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) aml_register_notify(sc->sc_devnode->parent, NULL, acpitz_notify, sc); - memset(&sc->sc_sens, 0, sizeof(sc->sc_sens)); - strlcpy(sc->sc_sens.device, DEVNAME(sc), sizeof(sc->sc_sens.device)); + strlcpy(sc->sc_sensdev.xname, DEVNAME(sc), + sizeof(sc->sc_sensdev.xname)); strlcpy(sc->sc_sens.desc, "zone temperature", sizeof(sc->sc_sens.desc)); sc->sc_sens.type = SENSOR_TEMP; - sensor_add(&sc->sc_sens); + sensor_attach(&sc->sc_sensdev, &sc->sc_sens); + sensordev_install(&sc->sc_sensdev); sc->sc_sens.value = 0; } diff --git a/sys/dev/i2c/ad741x.c b/sys/dev/i2c/ad741x.c index 521814702e6..b78642772aa 100644 --- a/sys/dev/i2c/ad741x.c +++ b/sys/dev/i2c/ad741x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad741x.c,v 1.8 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: ad741x.c,v 1.9 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -49,6 +49,7 @@ struct adc_softc { u_int8_t sc_config; struct sensor sc_sensor[ADC_MAX_SENSORS]; + struct sensordev sc_sensordev; }; int adc_match(struct device *, void *, void *); @@ -119,31 +120,22 @@ adc_attach(struct device *parent, struct device *self, void *aux) sc->sc_config = data; /* Initialize sensor data. */ - for (i = 0; i < ADC_MAX_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADC_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADC_TEMP].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADC_TEMP].desc, "Internal", sizeof(sc->sc_sensor[ADC_TEMP].desc)); nsens = 1; if (sc->sc_chip == 7417 || sc->sc_chip == 7418) { sc->sc_sensor[ADC_ADC0].type = SENSOR_INTEGER; - strlcpy(sc->sc_sensor[ADC_ADC0].desc, "adc0", - sizeof(sc->sc_sensor[ADC_ADC0].desc)); nsens++; } if (sc->sc_chip == 7417 || sc->sc_chip == 7418) { sc->sc_sensor[ADC_ADC1].type = SENSOR_INTEGER; - strlcpy(sc->sc_sensor[ADC_ADC1].desc, "adc1", - sizeof(sc->sc_sensor[ADC_ADC1].desc)); sc->sc_sensor[ADC_ADC2].type = SENSOR_INTEGER; - strlcpy(sc->sc_sensor[ADC_ADC2].desc, "adc2", - sizeof(sc->sc_sensor[ADC_ADC2].desc)); sc->sc_sensor[ADC_ADC3].type = SENSOR_INTEGER; - strlcpy(sc->sc_sensor[ADC_ADC3].desc, "adc3", - sizeof(sc->sc_sensor[ADC_ADC3].desc)); nsens += 3; } @@ -152,12 +144,13 @@ adc_attach(struct device *parent, struct device *self, void *aux) return; } - sensor_add(&sc->sc_sensor[0]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[0]); if (sc->sc_chip == 7417 || sc->sc_chip == 7418) - sensor_add(&sc->sc_sensor[1]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[1]); if (sc->sc_chip == 7417) for (i = 2; i < nsens; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1021.c b/sys/dev/i2c/adm1021.c index bc1540c20c0..d2658649877 100644 --- a/sys/dev/i2c/adm1021.c +++ b/sys/dev/i2c/adm1021.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1021.c,v 1.24 2006/07/20 21:23:42 kettenis Exp $ */ +/* $OpenBSD: adm1021.c,v 1.25 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -46,6 +46,7 @@ struct admtemp_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMTEMP_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_noexternal; }; @@ -137,18 +138,17 @@ admtemp_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ADMTEMP_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMTEMP_EXT].type = SENSOR_TEMP; strlcpy(sc->sc_sensor[ADMTEMP_EXT].desc, - xeon ? "Xeon Temp" : "External Temp", + xeon ? "Xeon" : "External", sizeof(sc->sc_sensor[ADMTEMP_EXT].desc)); sc->sc_sensor[ADMTEMP_INT].type = SENSOR_TEMP; strlcpy(sc->sc_sensor[ADMTEMP_INT].desc, - xeon ? "Xeon Temp" : "Internal Temp", + xeon ? "Xeon" : "Internal", sizeof(sc->sc_sensor[ADMTEMP_INT].desc)); if (sensor_task_register(sc, admtemp_refresh, 5)) { @@ -157,7 +157,8 @@ admtemp_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < (sc->sc_noexternal ? 1 : ADMTEMP_NUM_SENSORS); i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1024.c b/sys/dev/i2c/adm1024.c index 997a38e22f1..0709f7af6f6 100644 --- a/sys/dev/i2c/adm1024.c +++ b/sys/dev/i2c/adm1024.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1024.c,v 1.11 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: adm1024.c,v 1.12 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -62,6 +62,7 @@ struct admlc_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMLC_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_fan1mul; int sc_fan2mul; }; @@ -130,16 +131,15 @@ admlc_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ADMLC_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMLC_INT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMLC_INT].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADMLC_INT].desc, "Internal", sizeof(sc->sc_sensor[ADMLC_INT].desc)); sc->sc_sensor[ADMLC_EXT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMLC_EXT].desc, "External Temp", + strlcpy(sc->sc_sensor[ADMLC_EXT].desc, "External", sizeof(sc->sc_sensor[ADMLC_EXT].desc)); sc->sc_sensor[ADMLC_V2_5].type = SENSOR_VOLTS_DC; @@ -167,12 +167,8 @@ admlc_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[ADMLC_Vccp2].desc)); sc->sc_sensor[ADMLC_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMLC_FAN1].desc, "Fan1", - sizeof(sc->sc_sensor[ADMLC_FAN1].desc)); sc->sc_sensor[ADMLC_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMLC_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[ADMLC_FAN2].desc)); if (sensor_task_register(sc, admlc_refresh, 5)) { @@ -181,7 +177,8 @@ admlc_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ADMLC_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1025.c b/sys/dev/i2c/adm1025.c index 5f7f45bd74f..5a59ebb2367 100644 --- a/sys/dev/i2c/adm1025.c +++ b/sys/dev/i2c/adm1025.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1025.c,v 1.22 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: adm1025.c,v 1.23 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -62,6 +62,7 @@ struct admtm_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMTM_NUM_SENSORS + SMSC_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_nsensors; int sc_model; }; @@ -131,16 +132,15 @@ admtm_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ADMTM_NUM_SENSORS + SMSC_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMTM_INT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTM_INT].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADMTM_INT].desc, "Internal", sizeof(sc->sc_sensor[ADMTM_INT].desc)); sc->sc_sensor[ADMTM_EXT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTM_EXT].desc, "External Temp", + strlcpy(sc->sc_sensor[ADMTM_EXT].desc, "External", sizeof(sc->sc_sensor[ADMTM_EXT].desc)); sc->sc_sensor[ADMTM_V2_5].type = SENSOR_VOLTS_DC; @@ -176,7 +176,7 @@ admtm_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[SMSC_V1_8].desc)); sc->sc_sensor[SMSC_TEMP2].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[SMSC_TEMP2].desc, "External2 Temp", + strlcpy(sc->sc_sensor[SMSC_TEMP2].desc, "External", sizeof(sc->sc_sensor[SMSC_TEMP2].desc)); if (sensor_task_register(sc, admtm_refresh, 5)) { @@ -185,7 +185,8 @@ admtm_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < sc->sc_nsensors; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1026.c b/sys/dev/i2c/adm1026.c index 29620347309..dc63020ab6f 100644 --- a/sys/dev/i2c/adm1026.c +++ b/sys/dev/i2c/adm1026.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1026.c,v 1.7 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: adm1026.c,v 1.8 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -79,6 +79,7 @@ struct admcts_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMCTS_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_fanmul[8]; }; @@ -161,12 +162,11 @@ admcts_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ADMCTS_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMCTS_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMCTS_TEMP].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADMCTS_TEMP].desc, "Internal", sizeof(sc->sc_sensor[ADMCTS_TEMP].desc)); sc->sc_sensor[ADMCTS_Vbat].type = SENSOR_VOLTS_DC; @@ -174,11 +174,11 @@ admcts_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[ADMCTS_Vbat].desc)); sc->sc_sensor[ADMCTS_EXT1].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMCTS_EXT1].desc, "External1 Temp", + strlcpy(sc->sc_sensor[ADMCTS_EXT1].desc, "External", sizeof(sc->sc_sensor[ADMCTS_EXT1].desc)); sc->sc_sensor[ADMCTS_EXT2].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMCTS_EXT2].desc, "External2 Temp", + strlcpy(sc->sc_sensor[ADMCTS_EXT2].desc, "External", sizeof(sc->sc_sensor[ADMCTS_EXT2].desc)); sc->sc_sensor[ADMCTS_V3_3stby].type = SENSOR_VOLTS_DC; @@ -206,36 +206,12 @@ admcts_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[ADMCTS_Vminus12].desc)); sc->sc_sensor[ADMCTS_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN1].desc, "Fan1", - sizeof(sc->sc_sensor[ADMCTS_FAN1].desc)); - sc->sc_sensor[ADMCTS_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[ADMCTS_FAN2].desc)); - - sc->sc_sensor[ADMCTS_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[ADMCTS_FAN2].desc)); - sc->sc_sensor[ADMCTS_FAN3].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN3].desc, "Fan3", - sizeof(sc->sc_sensor[ADMCTS_FAN3].desc)); - sc->sc_sensor[ADMCTS_FAN4].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN4].desc, "Fan4", - sizeof(sc->sc_sensor[ADMCTS_FAN4].desc)); - sc->sc_sensor[ADMCTS_FAN5].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN5].desc, "Fan5", - sizeof(sc->sc_sensor[ADMCTS_FAN5].desc)); - sc->sc_sensor[ADMCTS_FAN6].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN6].desc, "Fan6", - sizeof(sc->sc_sensor[ADMCTS_FAN6].desc)); - sc->sc_sensor[ADMCTS_FAN7].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMCTS_FAN7].desc, "Fan7", - sizeof(sc->sc_sensor[ADMCTS_FAN7].desc)); if (sensor_task_register(sc, admcts_refresh, 5)) { printf(", unable to register update task\n"); @@ -243,7 +219,8 @@ admcts_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ADMCTS_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1030.c b/sys/dev/i2c/adm1030.c index 0dea59aa5ed..8d09cf010af 100644 --- a/sys/dev/i2c/adm1030.c +++ b/sys/dev/i2c/adm1030.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1030.c,v 1.5 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: adm1030.c,v 1.6 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -43,6 +43,7 @@ struct admtmp_softc { int sc_fanmul; struct sensor sc_sensor[ADMTMP_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int admtmp_match(struct device *, void *, void *); @@ -88,21 +89,18 @@ admtmp_attach(struct device *parent, struct device *self, void *aux) sc->sc_fanmul = 11250/8 * (1 << ADM1024_FANC_VAL(data)) * 60; /* Initialize sensor data. */ - for (i = 0; i < ADMTMP_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMTMP_INT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTMP_INT].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADMTMP_INT].desc, "Internal", sizeof(sc->sc_sensor[ADMTMP_INT].desc)); sc->sc_sensor[ADMTMP_EXT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTMP_EXT].desc, "External Temp", + strlcpy(sc->sc_sensor[ADMTMP_EXT].desc, "External", sizeof(sc->sc_sensor[ADMTMP_EXT].desc)); sc->sc_sensor[ADMTMP_FAN].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMTMP_FAN].desc, "Fan", - sizeof(sc->sc_sensor[ADMTMP_FAN].desc)); if (sensor_task_register(sc, admtmp_refresh, 5)) { printf(", unable to register update task\n"); @@ -110,7 +108,8 @@ admtmp_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ADMTMP_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adm1031.c b/sys/dev/i2c/adm1031.c index 0b9feddf5c4..6b8149e2739 100644 --- a/sys/dev/i2c/adm1031.c +++ b/sys/dev/i2c/adm1031.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1031.c,v 1.5 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: adm1031.c,v 1.6 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -48,6 +48,7 @@ struct admtt_softc { int sc_fanmul; struct sensor sc_sensor[ADMTT_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int admtt_match(struct device *, void *, void *); @@ -92,29 +93,24 @@ admtt_attach(struct device *parent, struct device *self, void *aux) sc->sc_fanmul = 11250/8 * (1 << ADM1024_FANC_VAL(data)) * 60; /* Initialize sensor data. */ - for (i = 0; i < ADMTT_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADMTT_INT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTT_INT].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADMTT_INT].desc, "Internal", sizeof(sc->sc_sensor[ADMTT_INT].desc)); sc->sc_sensor[ADMTT_EXT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTT_EXT].desc, "External1 Temp", + strlcpy(sc->sc_sensor[ADMTT_EXT].desc, "External", sizeof(sc->sc_sensor[ADMTT_EXT].desc)); sc->sc_sensor[ADMTT_EXT2].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADMTT_EXT2].desc, "External2 Temp", + strlcpy(sc->sc_sensor[ADMTT_EXT2].desc, "External", sizeof(sc->sc_sensor[ADMTT_EXT2].desc)); sc->sc_sensor[ADMTT_FAN].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMTT_FAN].desc, "Fan1", - sizeof(sc->sc_sensor[ADMTT_FAN].desc)); sc->sc_sensor[ADMTT_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADMTT_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[ADMTT_FAN2].desc)); if (sensor_task_register(sc, admtt_refresh, 5)) { printf(", unable to register update task\n"); @@ -122,7 +118,8 @@ admtt_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ADMTT_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/adt7460.c b/sys/dev/i2c/adt7460.c index 760d4f170bd..3c4fb6e036d 100644 --- a/sys/dev/i2c/adt7460.c +++ b/sys/dev/i2c/adt7460.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adt7460.c,v 1.13 2006/04/17 06:20:00 deraadt Exp $ */ +/* $OpenBSD: adt7460.c,v 1.14 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -87,6 +87,7 @@ struct adt_softc { struct adt_chip *chip; struct sensor sc_sensor[ADT_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int adt_match(struct device *, void *, void *); @@ -166,9 +167,8 @@ adt_attach(struct device *parent, struct device *self, void *aux) printf(": %s rev 0x%02x", ia->ia_name, rev); /* Initialize sensor data. */ - for (i = 0; i < ADT_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ADT_2_5V].type = SENSOR_VOLTS_DC; strlcpy(sc->sc_sensor[ADT_2_5V].desc, "+2.5Vin", @@ -194,32 +194,21 @@ adt_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[ADT_V12].desc)); sc->sc_sensor[ADT_REM1_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADT_REM1_TEMP].desc, "Remote1 Temp", + strlcpy(sc->sc_sensor[ADT_REM1_TEMP].desc, "Remote", sizeof(sc->sc_sensor[ADT_REM1_TEMP].desc)); sc->sc_sensor[ADT_LOCAL_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADT_LOCAL_TEMP].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ADT_LOCAL_TEMP].desc, "Internal", sizeof(sc->sc_sensor[ADT_LOCAL_TEMP].desc)); sc->sc_sensor[ADT_REM2_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ADT_REM2_TEMP].desc, "Remote2 Temp", + strlcpy(sc->sc_sensor[ADT_REM2_TEMP].desc, "Remote", sizeof(sc->sc_sensor[ADT_REM2_TEMP].desc)); sc->sc_sensor[ADT_TACH1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADT_TACH1].desc, "TACH1", - sizeof(sc->sc_sensor[ADT_TACH1].desc)); - sc->sc_sensor[ADT_TACH2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADT_TACH2].desc, "TACH2", - sizeof(sc->sc_sensor[ADT_TACH2].desc)); - sc->sc_sensor[ADT_TACH3].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADT_TACH3].desc, "TACH3", - sizeof(sc->sc_sensor[ADT_TACH3].desc)); - sc->sc_sensor[ADT_TACH4].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ADT_TACH4].desc, "TACH4", - sizeof(sc->sc_sensor[ADT_TACH4].desc)); if (sensor_task_register(sc, adt_refresh, 5)) { printf(", unable to register update task\n"); @@ -228,8 +217,10 @@ adt_attach(struct device *parent, struct device *self, void *aux) for (i = 0; i < ADT_NUM_SENSORS; i++) { sc->sc_sensor[i].flags &= ~SENSOR_FINVALID; - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); } + sensordev_install(&sc->sc_sensordev); + printf("\n"); } diff --git a/sys/dev/i2c/asb100.c b/sys/dev/i2c/asb100.c index 26bd9b36486..f8770a25b8f 100644 --- a/sys/dev/i2c/asb100.c +++ b/sys/dev/i2c/asb100.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asb100.c,v 1.7 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: asb100.c,v 1.8 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Damien Miller <djm@openbsd.org> @@ -107,6 +107,7 @@ struct asbtm_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ASB100_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_fanmul[3]; int sc_satellite[2]; }; @@ -224,66 +225,37 @@ asbtm_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < ASB100_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[ASB100_SENSOR_VIN0].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN0].desc, "Vin0", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN0].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN1].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN1].desc, "Vin1", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN1].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN2].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN2].desc, "Vin2", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN2].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN3].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN3].desc, "Vin3", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN3].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN4].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN4].desc, "Vin4", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN4].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN5].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN5].desc, "Vin5", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN5].desc)); - sc->sc_sensor[ASB100_SENSOR_VIN6].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[ASB100_SENSOR_VIN6].desc, "Vin6", - sizeof(sc->sc_sensor[ASB100_SENSOR_VIN6].desc)); sc->sc_sensor[ASB100_SENSOR_FAN0].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ASB100_SENSOR_FAN0].desc, "Fan0", - sizeof(sc->sc_sensor[ASB100_SENSOR_FAN0].desc)); - sc->sc_sensor[ASB100_SENSOR_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ASB100_SENSOR_FAN1].desc, "Fan1", - sizeof(sc->sc_sensor[ASB100_SENSOR_FAN1].desc)); - sc->sc_sensor[ASB100_SENSOR_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[ASB100_SENSOR_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[ASB100_SENSOR_FAN2].desc)); sc->sc_sensor[ASB100_SENSOR_TEMP0].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP0].desc, "External Temp", + strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP0].desc, "External", sizeof(sc->sc_sensor[ASB100_SENSOR_TEMP0].desc)); sc->sc_sensor[ASB100_SENSOR_TEMP1].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP1].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP1].desc, "Internal", sizeof(sc->sc_sensor[ASB100_SENSOR_TEMP1].desc)); sc->sc_sensor[ASB100_SENSOR_TEMP2].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP2].desc, "Internal Temp", + strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP2].desc, "Internal", sizeof(sc->sc_sensor[ASB100_SENSOR_TEMP2].desc)); if (sc->sc_satellite[1] == -1) sc->sc_sensor[ASB100_SENSOR_TEMP2].flags |= SENSOR_FINVALID; sc->sc_sensor[ASB100_SENSOR_TEMP3].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP3].desc, "External Temp", + strlcpy(sc->sc_sensor[ASB100_SENSOR_TEMP3].desc, "External", sizeof(sc->sc_sensor[ASB100_SENSOR_TEMP3].desc)); if (sensor_task_register(sc, asbtm_refresh, 5)) { @@ -292,7 +264,8 @@ asbtm_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < ASB100_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/ds1631.c b/sys/dev/i2c/ds1631.c index 6d20f1411ce..184db2e6537 100644 --- a/sys/dev/i2c/ds1631.c +++ b/sys/dev/i2c/ds1631.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ds1631.c,v 1.6 2006/04/10 00:57:23 deraadt Exp $ */ +/* $OpenBSD: ds1631.c,v 1.7 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -41,6 +41,7 @@ struct maxds_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[MAXDS_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int maxds_match(struct device *, void *, void *); @@ -112,12 +113,11 @@ dostart: iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < MAXDS_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[MAXDS_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[MAXDS_TEMP].desc, "Internal Temp", + strlcpy(sc->sc_sensor[MAXDS_TEMP].desc, "Internal", sizeof(sc->sc_sensor[MAXDS_TEMP].desc)); if (sensor_task_register(sc, maxds_refresh, 5)) { @@ -126,7 +126,8 @@ dostart: } for (i = 0; i < MAXDS_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/fcu.c b/sys/dev/i2c/fcu.c index 13a0413aa18..d588f06af4e 100644 --- a/sys/dev/i2c/fcu.c +++ b/sys/dev/i2c/fcu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcu.c,v 1.3 2006/01/19 17:08:39 grange Exp $ */ +/* $OpenBSD: fcu.c,v 1.4 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -51,6 +51,7 @@ struct fcu_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[FCU_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int fcu_match(struct device *, void *, void *); @@ -87,19 +88,14 @@ fcu_attach(struct device *parent, struct device *self, void *aux) sc->sc_addr = ia->ia_addr; /* Initialize sensor data. */ - for (i = 0; i < FCU_FANS; i++) { - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < FCU_FANS; i++) sc->sc_sensor[i].type = SENSOR_FANRPM; - snprintf(sc->sc_sensor[i].desc, - sizeof(sc->sc_sensor[i].desc), "FAN%d", i); - } for (i = 0; i < FCU_PWMS; i++) { - strlcpy(sc->sc_sensor[FCU_PWM1 + i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[FCU_PWM1 + i].device)); sc->sc_sensor[FCU_PWM1 + i].type = SENSOR_FANRPM; - snprintf(sc->sc_sensor[FCU_PWM1 + i].desc, - sizeof(sc->sc_sensor[FCU_PWM1 + i].desc), "PWM%d", i); + strlcpy(sc->sc_sensor[FCU_PWM1 + i].desc, "PWM", + sizeof(sc->sc_sensor[FCU_PWM1 + i].desc)); } if (sensor_task_register(sc, fcu_refresh, 5)) { @@ -108,7 +104,8 @@ fcu_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < FCU_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/fintek.c b/sys/dev/i2c/fintek.c index bd1ad15f0b0..7d9f5ad4058 100644 --- a/sys/dev/i2c/fintek.c +++ b/sys/dev/i2c/fintek.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fintek.c,v 1.2 2006/08/26 10:42:57 kettenis Exp $ */ +/* $OpenBSD: fintek.c,v 1.3 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@openbsd.org> * @@ -39,6 +39,7 @@ struct fintek_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[F_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int fintek_match(struct device *, void *, void *); @@ -137,41 +138,22 @@ fintek_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); - for (i = 0; i < F_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[F_VCC].type = SENSOR_VOLTS_DC; strlcpy(sc->sc_sensor[F_VCC].desc, "VCC", sizeof(sc->sc_sensor[F_VCC].desc)); sc->sc_sensor[F_V1].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[F_V1].desc, "Volt1", - sizeof(sc->sc_sensor[F_V1].desc)); - sc->sc_sensor[F_V2].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[F_V2].desc, "Volt2", - sizeof(sc->sc_sensor[F_V2].desc)); - sc->sc_sensor[F_V3].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[F_V3].desc, "Volt3", - sizeof(sc->sc_sensor[F_V3].desc)); sc->sc_sensor[F_TEMP1].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[F_TEMP1].desc, "Temp1", - sizeof(sc->sc_sensor[F_TEMP1].desc)); - sc->sc_sensor[F_TEMP2].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[F_TEMP2].desc, "Temp2", - sizeof(sc->sc_sensor[F_TEMP2].desc)); sc->sc_sensor[F_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[F_FAN1].desc, "Fan1", - sizeof(sc->sc_sensor[F_FAN1].desc)); - sc->sc_sensor[F_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[F_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[F_FAN2].desc)); if (sensor_task_register(sc, fintek_refresh, 5)) { printf(", unable to register update task\n"); @@ -180,8 +162,9 @@ fintek_attach(struct device *parent, struct device *self, void *aux) for (i = 0; i < F_NUM_SENSORS; i++) { sc->sc_sensor[i].flags &= ~SENSOR_FINVALID; - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); } + sensordev_install(&sc->sc_sensordev); printf("\n"); return; diff --git a/sys/dev/i2c/gl518sm.c b/sys/dev/i2c/gl518sm.c index a8d53f9dba0..fb674283ff1 100644 --- a/sys/dev/i2c/gl518sm.c +++ b/sys/dev/i2c/gl518sm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gl518sm.c,v 1.3 2006/01/26 22:25:34 kettenis Exp $ */ +/* $OpenBSD: gl518sm.c,v 1.4 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Mark Kettenis @@ -60,6 +60,7 @@ struct glenv_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[GLENV_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_fan1_div, sc_fan2_div; }; @@ -141,25 +142,16 @@ glenv_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < GLENV_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[GLENV_VIN3].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[GLENV_VIN3].desc, "Vin3", - sizeof(sc->sc_sensor[GLENV_VIN3].desc)); sc->sc_sensor[GLENV_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[GLENV_TEMP].desc, "Temp", - sizeof(sc->sc_sensor[GLENV_TEMP].desc)); sc->sc_sensor[GLENV_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[GLENV_FAN1].desc, "Fan1", - sizeof(sc->sc_sensor[GLENV_FAN1].desc)); sc->sc_sensor[GLENV_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[GLENV_FAN2].desc, "Fan2", - sizeof(sc->sc_sensor[GLENV_FAN2].desc)); if (sc->sc_fan2_div == -1) sc->sc_sensor[GLENV_FAN2].flags |= SENSOR_FINVALID; @@ -169,7 +161,8 @@ glenv_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < GLENV_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/lm75.c b/sys/dev/i2c/lm75.c index 45d91d936ac..92f99fd4d54 100644 --- a/sys/dev/i2c/lm75.c +++ b/sys/dev/i2c/lm75.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm75.c,v 1.13 2006/08/19 15:55:47 deraadt Exp $ */ +/* $OpenBSD: lm75.c,v 1.14 2006/12/23 17:46:39 deraadt Exp $ */ /* $NetBSD: lm75.c,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */ /* * Copyright (c) 2006 Theo de Raadt <deraadt@openbsd.org> @@ -62,6 +62,7 @@ struct lmtemp_softc { int sc_bits; struct sensor sc_sensor; + struct sensordev sc_sensordev; }; int lmtemp_match(struct device *, void *, void *); @@ -203,13 +204,14 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux) printf("\n"); /* Initialize sensor data */ - strlcpy(sc->sc_sensor.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor.device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor.type = SENSOR_TEMP; - strlcpy(sc->sc_sensor.desc, "Temp", sizeof(sc->sc_sensor.desc)); /* Hook into the hw.sensors sysctl */ - sensor_add(&sc->sc_sensor); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + sensordev_install(&sc->sc_sensordev); + sensor_task_register(sc, lmtemp_refresh_sensor_data, LM_POLLTIME); } diff --git a/sys/dev/i2c/lm87.c b/sys/dev/i2c/lm87.c index 4c24ed72061..3eeced4bda1 100644 --- a/sys/dev/i2c/lm87.c +++ b/sys/dev/i2c/lm87.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm87.c,v 1.16 2006/04/09 21:06:33 deraadt Exp $ */ +/* $OpenBSD: lm87.c,v 1.17 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -62,6 +62,7 @@ struct lmenv_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[LMENV_NUM_SENSORS]; + struct sensordev sc_sensordev; int sc_fan1_div, sc_fan2_div; int sc_family; }; @@ -169,16 +170,15 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ - for (i = 0; i < LMENV_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[LMENV_2_5V].type = SENSOR_VOLTS_DC; strlcpy(sc->sc_sensor[LMENV_2_5V].desc, "+2.5Vin", sizeof(sc->sc_sensor[LMENV_2_5V].desc)); sc->sc_sensor[LMENV_VCCP1].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[LMENV_VCCP1].desc, "Vccp1", + strlcpy(sc->sc_sensor[LMENV_VCCP1].desc, "Vccp", sizeof(sc->sc_sensor[LMENV_VCCP1].desc)); sc->sc_sensor[LMENV_VCC].type = SENSOR_VOLTS_DC; @@ -194,17 +194,17 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[LMENV_12V].desc)); sc->sc_sensor[LMENV_VCCP2].type = SENSOR_VOLTS_DC; - strlcpy(sc->sc_sensor[LMENV_VCCP2].desc, "Vccp2", + strlcpy(sc->sc_sensor[LMENV_VCCP2].desc, "Vccp", sizeof(sc->sc_sensor[LMENV_VCCP2].desc)); sc->sc_sensor[LMENV_EXT_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[LMENV_EXT_TEMP].desc, "External Temp", + strlcpy(sc->sc_sensor[LMENV_EXT_TEMP].desc, "External", sizeof(sc->sc_sensor[LMENV_EXT_TEMP].desc)); if (sc->sc_family == 81) sc->sc_sensor[LMENV_EXT_TEMP].flags |= SENSOR_FINVALID; sc->sc_sensor[LMENV_INT_TEMP].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[LMENV_INT_TEMP].desc, "Internal Temp", + strlcpy(sc->sc_sensor[LMENV_INT_TEMP].desc, "Internal", sizeof(sc->sc_sensor[LMENV_INT_TEMP].desc)); if (channel & LM87_CHANNEL_AIN1) { @@ -213,8 +213,6 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[LMENV_FAN1].desc)); } else { sc->sc_sensor[LMENV_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[LMENV_FAN1].desc, "FAN1", - sizeof(sc->sc_sensor[LMENV_FAN1].desc)); } if (channel & LM87_CHANNEL_AIN2) { @@ -223,8 +221,6 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sc_sensor[LMENV_FAN2].desc)); } else { sc->sc_sensor[LMENV_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_sensor[LMENV_FAN2].desc, "FAN2", - sizeof(sc->sc_sensor[LMENV_FAN2].desc)); } if (sensor_task_register(sc, lmenv_refresh, 5)) { @@ -233,7 +229,8 @@ lmenv_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < LMENV_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/maxim6690.c b/sys/dev/i2c/maxim6690.c index 8ad97b4eaae..80031bd0768 100644 --- a/sys/dev/i2c/maxim6690.c +++ b/sys/dev/i2c/maxim6690.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maxim6690.c,v 1.12 2006/11/20 21:53:02 kettenis Exp $ */ +/* $OpenBSD: maxim6690.c,v 1.13 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -55,6 +55,7 @@ struct maxtmp_softc { u_int8_t sc_temp2_mask; struct sensor sc_sensor[MAXTMP_NUM_SENSORS]; + struct sensordev sc_sensordev; }; int maxtmp_match(struct device *, void *, void *); @@ -120,16 +121,15 @@ maxtmp_attach(struct device *parent, struct device *self, void *aux) printf(": %s", ia->ia_name); /* Initialize sensor data. */ - for (i = 0; i < MAXTMP_NUM_SENSORS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor[MAXTMP_INT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[MAXTMP_INT].desc, "Internal Temp", + strlcpy(sc->sc_sensor[MAXTMP_INT].desc, "Internal", sizeof(sc->sc_sensor[MAXTMP_INT].desc)); sc->sc_sensor[MAXTMP_EXT].type = SENSOR_TEMP; - strlcpy(sc->sc_sensor[MAXTMP_EXT].desc, "External Temp", + strlcpy(sc->sc_sensor[MAXTMP_EXT].desc, "External", sizeof(sc->sc_sensor[MAXTMP_EXT].desc)); if (sensor_task_register(sc, maxtmp_refresh, 5)) { @@ -138,7 +138,8 @@ maxtmp_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < MAXTMP_NUM_SENSORS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/pca9554.c b/sys/dev/i2c/pca9554.c index 52f00312cbe..237c78d97ef 100644 --- a/sys/dev/i2c/pca9554.c +++ b/sys/dev/i2c/pca9554.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pca9554.c,v 1.8 2006/06/27 20:29:48 deraadt Exp $ */ +/* $OpenBSD: pca9554.c,v 1.9 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -46,6 +46,7 @@ struct pcagpio_softc { gpio_pin_t sc_gpio_pins[PCAGPIO_NPINS]; struct sensor sc_sensor[PCAGPIO_NPINS]; + struct sensordev sc_sensordev; }; int pcagpio_match(struct device *, void *, void *); @@ -113,9 +114,8 @@ pcagpio_attach(struct device *parent, struct device *self, void *aux) } /* Initialize sensor data. */ - for (i = 0; i < PCAGPIO_NPINS; i++) - strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor[i].device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); for (i = 0; i < PCAGPIO_NPINS; i++) { sc->sc_sensor[i].type = SENSOR_INTEGER; @@ -136,7 +136,8 @@ pcagpio_attach(struct device *parent, struct device *self, void *aux) #if 0 for (i = 0; i < PCAGPIO_NPINS; i++) - sensor_add(&sc->sc_sensor[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + sensordev_install(&sc->sc_sensordev); #endif printf(":"); diff --git a/sys/dev/i2c/tsl2560.c b/sys/dev/i2c/tsl2560.c index 28ea49cd4a9..e5dd30ba1a6 100644 --- a/sys/dev/i2c/tsl2560.c +++ b/sys/dev/i2c/tsl2560.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tsl2560.c,v 1.3 2006/01/19 17:08:39 grange Exp $ */ +/* $OpenBSD: tsl2560.c,v 1.4 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -41,6 +41,7 @@ struct tsl_softc { i2c_addr_t sc_addr; struct sensor sc_sensor; + struct sensordev sc_sensordev; }; int tsl_match(struct device *, void *, void *); @@ -115,17 +116,17 @@ tsl_attach(struct device *parent, struct device *self, void *aux) } /* Initialize sensor data. */ - strlcpy(sc->sc_sensor.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor.device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor.type = SENSOR_LUX; - strlcpy(sc->sc_sensor.desc, "LUX", sizeof(sc->sc_sensor.desc)); if (sensor_task_register(sc, tsl_refresh, 5)) { printf(": unable to register update task\n"); return; } - sensor_add(&sc->sc_sensor); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + sensordev_install(&sc->sc_sensordev); printf("\n"); } diff --git a/sys/dev/i2c/w83l784r.c b/sys/dev/i2c/w83l784r.c index 39fcc0bd5cf..ee4c7cac726 100644 --- a/sys/dev/i2c/w83l784r.c +++ b/sys/dev/i2c/w83l784r.c @@ -1,4 +1,4 @@ -/* $OpenBSD: w83l784r.c,v 1.9 2006/11/14 20:26:01 kettenis Exp $ */ +/* $OpenBSD: w83l784r.c,v 1.10 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Mark Kettenis @@ -79,6 +79,7 @@ struct wbenv_softc { u_int8_t sc_chip_id; struct sensor sc_sensors[WBENV_MAX_SENSORS]; + struct sensordev sc_sensordev; struct wbenv_sensor *sc_wbenv_sensors; int sc_numsensors; }; @@ -113,11 +114,11 @@ struct wbenv_sensor w83l784r_sensors[] = { "VBAT", SENSOR_VOLTS_DC, W83L784R_VBAT, w83l784r_refresh_volt, RFACT(232, 99) }, { "+3.3V", SENSOR_VOLTS_DC, W83L784R_3_3V, w83l784r_refresh_volt, RFACT_NONE }, { "+5V", SENSOR_VOLTS_DC, W83L784R_VCC, w83l784r_refresh_volt, RFACT(50, 34) }, - { "Temp1", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, w83l784r_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, w83l784r_refresh_temp }, - { "Fan1", SENSOR_FANRPM, W83L784R_FAN1, w83l784r_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, W83L784R_FAN2, w83l784r_refresh_fanrpm }, + { "", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, + { "", SENSOR_TEMP, 1, w83l784r_refresh_temp }, + { "", SENSOR_TEMP, 2, w83l784r_refresh_temp }, + { "", SENSOR_FANRPM, W83L784R_FAN1, w83l784r_refresh_fanrpm }, + { "", SENSOR_FANRPM, W83L784R_FAN2, w83l784r_refresh_fanrpm }, { NULL } }; @@ -128,17 +129,17 @@ struct wbenv_sensor w83l785r_sensors[] = { "+2.5V", SENSOR_VOLTS_DC, W83L785R_2_5V, w83l785r_refresh_volt, RFACT(100, 100) }, { "+1.5V", SENSOR_VOLTS_DC, W83L785R_1_5V, w83l785r_refresh_volt, RFACT_NONE }, { "+3.3V", SENSOR_VOLTS_DC, W83L785R_VCC, w83l785r_refresh_volt, RFACT(20, 40) }, - { "Temp1", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, - { "Temp2", SENSOR_TEMP, W83L785R_TEMP2, wbenv_refresh_temp }, - { "Fan1", SENSOR_FANRPM, W83L784R_FAN1, w83l785r_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, W83L784R_FAN2, w83l785r_refresh_fanrpm }, + { "", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, + { "", SENSOR_TEMP, W83L785R_TEMP2, wbenv_refresh_temp }, + { "", SENSOR_FANRPM, W83L784R_FAN1, w83l785r_refresh_fanrpm }, + { "", SENSOR_FANRPM, W83L784R_FAN2, w83l785r_refresh_fanrpm }, { NULL } }; struct wbenv_sensor w83l785ts_l_sensors[] = { - { "Temp", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, + { "", SENSOR_TEMP, W83L784R_TEMP1, wbenv_refresh_temp }, { NULL } }; @@ -230,7 +231,8 @@ wbenv_attach(struct device *parent, struct device *self, void *aux) /* Add sensors */ for (i = 0; i < sc->sc_numsensors; ++i) - sensor_add(&sc->sc_sensors[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]); + sensordev_install(&sc->sc_sensordev); } void @@ -238,9 +240,10 @@ wbenv_setup_sensors(struct wbenv_softc *sc, struct wbenv_sensor *sensors) { int i; + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + for (i = 0; sensors[i].desc; i++) { - strlcpy(sc->sc_sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensors[i].device)); sc->sc_sensors[i].type = sensors[i].type; strlcpy(sc->sc_sensors[i].desc, sensors[i].desc, sizeof(sc->sc_sensors[i].desc)); diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index 3d45012fe09..b437229ca41 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.174 2006/11/28 23:59:45 dlg Exp $ */ +/* $OpenBSD: ami.c,v 1.175 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -2448,6 +2448,9 @@ ami_create_sensors(struct ami_softc *sc) return (1); bzero(sc->sc_sensors, sizeof(struct sensor) * sc->sc_nunits); + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < sc->sc_nunits; i++) { if (ssc->sc_link[i][0] == NULL) goto bad; @@ -2457,12 +2460,10 @@ ami_create_sensors(struct ami_softc *sc) sc->sc_sensors[i].type = SENSOR_DRIVE; sc->sc_sensors[i].status = SENSOR_S_UNKNOWN; - strlcpy(sc->sc_sensors[i].device, DEVNAME(sc), - sizeof(sc->sc_sensors[i].device)); strlcpy(sc->sc_sensors[i].desc, dev->dv_xname, sizeof(sc->sc_sensors[i].desc)); - sensor_add(&sc->sc_sensors[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]); } sc->sc_bd = malloc(sizeof(*sc->sc_bd), M_DEVBUF, M_WAITOK); @@ -2472,13 +2473,13 @@ ami_create_sensors(struct ami_softc *sc) if (sensor_task_register(sc, ami_refresh_sensors, 10) != 0) goto freebd; + sensordev_install(&sc->sc_sensordev); + return (0); freebd: free(sc->sc_bd, M_DEVBUF); bad: - while (--i >= 0) - sensor_del(&sc->sc_sensors[i]); free(sc->sc_sensors, M_DEVBUF); return (1); diff --git a/sys/dev/ic/amivar.h b/sys/dev/ic/amivar.h index 02a37bacc5b..c0152037f7d 100644 --- a/sys/dev/ic/amivar.h +++ b/sys/dev/ic/amivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amivar.h,v 1.49 2006/06/28 08:26:00 dlg Exp $ */ +/* $OpenBSD: amivar.h,v 1.50 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -27,6 +27,8 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/sensors.h> + struct ami_mem { bus_dmamap_t am_map; bus_dma_segment_t am_seg; @@ -140,6 +142,7 @@ struct ami_softc { struct ami_rawsoftc *sc_rawsoftcs; struct sensor *sc_sensors; + struct sensordev sc_sensordev; struct ami_big_diskarray *sc_bd; }; diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c index 36993173f27..a5ef97d113a 100644 --- a/sys/dev/ic/ciss.c +++ b/sys/dev/ic/ciss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss.c,v 1.22 2006/11/28 23:59:45 dlg Exp $ */ +/* $OpenBSD: ciss.c,v 1.23 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -425,11 +425,12 @@ ciss_attach(struct ciss_softc *sc) M_DEVBUF, M_NOWAIT); if (sc->sensors) { bzero(sc->sensors, sizeof(struct sensor) * sc->maxunits); - for (i = 0; i < sc->maxunits; sensor_add(&sc->sensors[i++])) { + strlcpy(sc->sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sensordev.xname)); + for (i = 0; i < sc->maxunits; + sensor_attach(&sc->sensordev, &sc->sensors[i++])) { sc->sensors[i].type = SENSOR_DRIVE; sc->sensors[i].status = SENSOR_S_UNKNOWN; - strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sensors[i].device)); strlcpy(sc->sensors[i].desc, ((struct device *) scsibus->sc_link[i][0]->device_softc)->dv_xname, sizeof(sc->sensors[i].desc)); @@ -437,11 +438,10 @@ ciss_attach(struct ciss_softc *sc) scsibus->sc_link[i][0]->device_softc)->dv_xname, sizeof(sc->sc_lds[i]->xname)); } - if (sensor_task_register(sc, ciss_sensors, 10)) { - for (i = sc->maxunits; i--; ) - sensor_del(&sc->sensors[i]); + if (sensor_task_register(sc, ciss_sensors, 10)) free(sc->sensors, M_DEVBUF); - } + else + sensordev_install(&sc->sensordev); } #endif diff --git a/sys/dev/ic/cissvar.h b/sys/dev/ic/cissvar.h index f8eca716790..c776adee065 100644 --- a/sys/dev/ic/cissvar.h +++ b/sys/dev/ic/cissvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cissvar.h,v 1.5 2006/08/31 23:19:35 krw Exp $ */ +/* $OpenBSD: cissvar.h,v 1.6 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -17,7 +17,7 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -struct sensor; +#include <sys/sensors.h> struct ciss_ld { struct ciss_blink bling; /* a copy of blink state */ @@ -36,6 +36,7 @@ struct ciss_softc { struct proc *sc_thread; int sc_flush; struct sensor *sensors; + struct sensordev sensordev; u_int sc_flags; #define CISS_BIO 0x0001 diff --git a/sys/dev/ic/lm78.c b/sys/dev/ic/lm78.c index 577032ba7a5..db4075a266c 100644 --- a/sys/dev/ic/lm78.c +++ b/sys/dev/ic/lm78.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78.c,v 1.10 2006/06/19 14:40:23 kettenis Exp $ */ +/* $OpenBSD: lm78.c,v 1.11 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -88,12 +88,12 @@ struct lm_sensor lm78_sensors[] = { { "-5V", SENSOR_VOLTS_DC, 0, 0x26, lm_refresh_volt, NRFACT(100, 60) }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, { NULL } }; @@ -111,14 +111,14 @@ struct lm_sensor w83627hf_sensors[] = { { "VBAT", SENSOR_VOLTS_DC, 5, 0x51, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, { NULL } }; @@ -134,14 +134,14 @@ struct lm_sensor w83637hf_sensors[] = { { "VBAT", SENSOR_VOLTS_DC, 5, 0x51, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, { NULL } }; @@ -158,12 +158,12 @@ struct lm_sensor w83697hf_sensors[] = { { "VBAT", SENSOR_VOLTS_DC, 5, 0x51, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, { NULL } }; @@ -184,14 +184,14 @@ struct lm_sensor w83781d_sensors[] = { { "-5V", SENSOR_VOLTS_DC, 0, 0x26, lm_refresh_volt, NRFACT(909, 604) }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, { NULL } }; @@ -209,14 +209,14 @@ struct lm_sensor w83782d_sensors[] = { { "VBAT", SENSOR_VOLTS_DC, 5, 0x51, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 2, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, { NULL } }; @@ -231,13 +231,13 @@ struct lm_sensor w83783s_sensors[] = { { "-5V", SENSOR_VOLTS_DC, 0, 0x26, wb_refresh_nvolt, RFACT(120, 56) }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, { NULL } }; @@ -256,16 +256,16 @@ struct lm_sensor w83791d_sensors[] = { { "VINR1", SENSOR_VOLTS_DC, 0, 0xb2, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 0, 0xc0, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 0, 0xc8, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 0, 0xc0, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0xc8, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, - { "Fan4", SENSOR_FANRPM, 0, 0xba, wb_refresh_fanrpm }, - { "Fan5", SENSOR_FANRPM, 0, 0xbb, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xba, wb_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xbb, wb_refresh_fanrpm }, { NULL } }; @@ -283,18 +283,18 @@ struct lm_sensor w83792d_sensors[] = { { "VBAT", SENSOR_VOLTS_DC, 0, 0xb1, lm_refresh_volt, RFACT_NONE }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 0, 0xc0, wb_refresh_temp }, - { "Temp3", SENSOR_TEMP, 0, 0xc8, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 0, 0xc0, wb_refresh_temp }, + { "", SENSOR_TEMP, 0, 0xc8, wb_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, wb_w83792d_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, wb_w83792d_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, wb_w83792d_refresh_fanrpm }, - { "Fan4", SENSOR_FANRPM, 0, 0xb8, wb_w83792d_refresh_fanrpm }, - { "Fan5", SENSOR_FANRPM, 0, 0xb9, wb_w83792d_refresh_fanrpm }, - { "Fan6", SENSOR_FANRPM, 0, 0xba, wb_w83792d_refresh_fanrpm }, - { "Fan7", SENSOR_FANRPM, 0, 0xbe, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xb8, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xb9, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xba, wb_w83792d_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0xbe, wb_w83792d_refresh_fanrpm }, { NULL } }; @@ -310,14 +310,14 @@ struct lm_sensor as99127f_sensors[] = { { "-5V", SENSOR_VOLTS_DC, 0, 0x26, wb_refresh_nvolt, RFACT(120, 56) }, /* Temperature */ - { "Temp1", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, - { "Temp2", SENSOR_TEMP, 1, 0x50, as_refresh_temp }, - { "Temp3", SENSOR_TEMP, 2, 0x50, as_refresh_temp }, + { "", SENSOR_TEMP, 0, 0x27, lm_refresh_temp }, + { "", SENSOR_TEMP, 1, 0x50, as_refresh_temp }, + { "", SENSOR_TEMP, 2, 0x50, as_refresh_temp }, /* Fans */ - { "Fan1", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, - { "Fan2", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, - { "Fan3", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x28, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x29, lm_refresh_fanrpm }, + { "", SENSOR_FANRPM, 0, 0x2a, lm_refresh_fanrpm }, { NULL } }; @@ -347,7 +347,8 @@ lm_attach(struct lm_softc *sc) /* Add sensors */ for (i = 0; i < sc->numsensors; ++i) - sensor_add(&sc->sensors[i]); + sensor_attach(&sc->sensordev, &sc->sensors[i]); + sensordev_install(&sc->sensordev); } int @@ -356,8 +357,9 @@ lm_detach(struct lm_softc *sc) int i; /* Remove sensors */ + sensordev_deinstall(&sc->sensordev); for (i = 0; i < sc->numsensors; i++) - sensor_del(&sc->sensors[i]); + sensor_detach(&sc->sensordev, &sc->sensors[i]); sensor_task_unregister(sc); @@ -498,9 +500,10 @@ lm_setup_sensors(struct lm_softc *sc, struct lm_sensor *sensors) { int i; + strlcpy(sc->sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sensordev.xname)); + for (i = 0; sensors[i].desc; i++) { - strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sensors[i].device)); sc->sensors[i].type = sensors[i].type; strlcpy(sc->sensors[i].desc, sensors[i].desc, sizeof(sc->sensors[i].desc)); diff --git a/sys/dev/ic/lm78var.h b/sys/dev/ic/lm78var.h index 08b285d71fc..2d446100747 100644 --- a/sys/dev/ic/lm78var.h +++ b/sys/dev/ic/lm78var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78var.h,v 1.6 2006/05/07 17:45:16 kettenis Exp $ */ +/* $OpenBSD: lm78var.h,v 1.7 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -131,6 +131,7 @@ struct lm_softc { struct device sc_dev; struct sensor sensors[WB_MAX_SENSORS]; + struct sensordev sensordev; struct lm_sensor *lm_sensors; u_int numsensors; void (*refresh_sensor_data) (struct lm_softc *); diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index f17197b551b..acadedde045 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */ +/* $OpenBSD: mfi.c,v 1.67 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -1794,6 +1794,9 @@ mfi_create_sensors(struct mfi_softc *sc) return (1); bzero(sc->sc_sensors, sizeof(struct sensor) * sc->sc_ld_cnt); + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < sc->sc_ld_cnt; i++) { if (ssc->sc_link[i][0] == NULL) goto bad; @@ -1803,22 +1806,20 @@ mfi_create_sensors(struct mfi_softc *sc) sc->sc_sensors[i].type = SENSOR_DRIVE; sc->sc_sensors[i].status = SENSOR_S_UNKNOWN; - strlcpy(sc->sc_sensors[i].device, DEVNAME(sc), - sizeof(sc->sc_sensors[i].device)); strlcpy(sc->sc_sensors[i].desc, dev->dv_xname, sizeof(sc->sc_sensors[i].desc)); - sensor_add(&sc->sc_sensors[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]); } if (sensor_task_register(sc, mfi_refresh_sensors, 10) != 0) goto bad; + sensordev_install(&sc->sc_sensordev); + return (0); bad: - while (--i >= 0) - sensor_del(&sc->sc_sensors[i]); free(sc->sc_sensors, M_DEVBUF); return (1); diff --git a/sys/dev/ic/mfivar.h b/sys/dev/ic/mfivar.h index ef7388b06be..f001f80f1f8 100644 --- a/sys/dev/ic/mfivar.h +++ b/sys/dev/ic/mfivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfivar.h,v 1.28 2006/08/31 18:18:46 marco Exp $ */ +/* $OpenBSD: mfivar.h,v 1.29 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -15,6 +15,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/sensors.h> + #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) /* #define MFI_DEBUG */ @@ -143,6 +145,7 @@ struct mfi_softc { struct mfi_ccb_list sc_ccb_freeq; struct sensor *sc_sensors; + struct sensordev sc_sensordev; }; int mfi_attach(struct mfi_softc *sc); diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c index 1727acd1d58..5b741030663 100644 --- a/sys/dev/ipmi.c +++ b/sys/dev/ipmi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipmi.c,v 1.51 2006/12/23 17:36:59 deraadt Exp $ */ +/* $OpenBSD: ipmi.c,v 1.52 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave @@ -1485,8 +1485,6 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count, psensor->stype = sensor_type; psensor->etype = ext_type; psensor->i_sensor.type = typ; - strlcpy(psensor->i_sensor.device, DEVNAME(sc), - sizeof(psensor->i_sensor.device)); if (count > 1) snprintf(psensor->i_sensor.desc, sizeof(psensor->i_sensor.desc), @@ -1501,7 +1499,7 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count, psensor->i_sensor.desc); if (read_sensor(sc, psensor) == 0) { SLIST_INSERT_HEAD(&ipmi_sensor_list, psensor, list); - sensor_add(&psensor->i_sensor); + sensor_attach(&sc->sc_sensordev, &psensor->i_sensor); dbg_printf(5, " reading: %lld [%s]\n", psensor->i_sensor.value, psensor->i_sensor.desc); @@ -1711,6 +1709,10 @@ ipmi_attach(struct device *parent, struct device *self, void *aux) /* Setup threads */ kthread_create_deferred(ipmi_create_thread, sc); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + sensordev_install(&sc->sc_sensordev); + printf(": version %d.%d interface %s %sbase 0x%x/%x spacing %d", ia->iaa_if_rev >> 4, ia->iaa_if_rev & 0xF, sc->sc_if->name, ia->iaa_if_iotype == 'i' ? "io" : "mem", ia->iaa_if_iobase, diff --git a/sys/dev/ipmivar.h b/sys/dev/ipmivar.h index 7644f25ed4f..713ddde65b8 100644 --- a/sys/dev/ipmivar.h +++ b/sys/dev/ipmivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ipmivar.h,v 1.16 2006/07/28 20:46:12 marco Exp $ */ +/* $OpenBSD: ipmivar.h,v 1.17 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave @@ -32,6 +32,7 @@ #include <sys/timeout.h> #include <sys/rwlock.h> +#include <sys/sensors.h> #define IPMI_IF_KCS 1 #define IPMI_IF_SMIC 2 @@ -103,6 +104,7 @@ struct ipmi_softc { struct ipmi_bmc_args *sc_iowait_args; struct ipmi_sensor *current_sensor; + struct sensordev sc_sensordev; }; struct ipmi_thread { diff --git a/sys/dev/isa/aps.c b/sys/dev/isa/aps.c index 0fb04c3ed4b..aa9ccd05527 100644 --- a/sys/dev/isa/aps.c +++ b/sys/dev/isa/aps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aps.c,v 1.8 2006/06/19 14:43:54 kettenis Exp $ */ +/* $OpenBSD: aps.c,v 1.9 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> * @@ -157,12 +157,8 @@ aps_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sensors[APS_SENSOR_YACCEL].desc), "Y_ACCEL"); sc->sensors[APS_SENSOR_TEMP1].type = SENSOR_TEMP; - snprintf(sc->sensors[APS_SENSOR_TEMP1].desc, - sizeof(sc->sensors[APS_SENSOR_TEMP1].desc), "Temp 1"); sc->sensors[APS_SENSOR_TEMP2].type = SENSOR_TEMP; - snprintf(sc->sensors[APS_SENSOR_TEMP2].desc, - sizeof(sc->sensors[APS_SENSOR_TEMP2].desc), "Temp 2"); sc->sensors[APS_SENSOR_XVAR].type = SENSOR_INTEGER; snprintf(sc->sensors[APS_SENSOR_XVAR].desc, @@ -189,11 +185,12 @@ aps_attach(struct device *parent, struct device *self, void *aux) sizeof(sc->sensors[APS_SENSOR_LIDOPEN].desc), "Lid Open"); /* stop hiding and report to the authorities */ + strlcpy(sc->sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sensordev.xname)); for (i = 0; i < sc->numsensors; i++) { - strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sensors[i].device)); - sensor_add(&sc->sensors[i]); + sensor_attach(&sc->sensordev, &sc->sensors[i]); } + sensordev_install(&sc->sensordev); powerhook_establish(aps_power, (void *)sc); diff --git a/sys/dev/isa/apsvar.h b/sys/dev/isa/apsvar.h index 99d7a813551..7feb3c3f7b7 100644 --- a/sys/dev/isa/apsvar.h +++ b/sys/dev/isa/apsvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apsvar.h,v 1.1 2005/08/05 03:52:32 jsg Exp $ */ +/* $OpenBSD: apsvar.h,v 1.2 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> * @@ -35,6 +35,7 @@ struct aps_softc { bus_space_handle_t aps_ioh; struct sensor sensors[APS_NUM_SENSORS]; + struct sensordev sensordev; u_int numsensors; void (*refresh_sensor_data)(struct aps_softc *); diff --git a/sys/dev/isa/it.c b/sys/dev/isa/it.c index 00e17c9b911..578c0cd0488 100644 --- a/sys/dev/isa/it.c +++ b/sys/dev/isa/it.c @@ -1,4 +1,4 @@ -/* $OpenBSD: it.c,v 1.20 2006/06/24 13:42:45 kettenis Exp $ */ +/* $OpenBSD: it.c,v 1.21 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2003 Julien Bordet <zejames@greyhats.org> @@ -167,11 +167,11 @@ it_attach(struct device *parent, struct device *self, void *aux) it_writereg(sc, ITD_CONFIG, cr); /* Initialize sensors */ - for (i = 0; i < sc->numsensors; ++i) { - strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sensors[i].device)); - sensor_add(&sc->sensors[i]); - } + strlcpy(sc->sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sensordev.xname)); + for (i = 0; i < sc->numsensors; ++i) + sensor_attach(&sc->sensordev, &sc->sensors[i]); + sensordev_install(&sc->sensordev); } u_int8_t @@ -222,12 +222,8 @@ it_setup_temp(struct it_softc *sc, int start, int n) { int i; - for (i = 0; i < n; ++i) { + for (i = 0; i < n; ++i) sc->sensors[start + i].type = SENSOR_TEMP; - snprintf(sc->sensors[start + i].desc, - sizeof(sc->sensors[start + i].desc), - "Temp %d", i + 1); - } } void @@ -235,12 +231,8 @@ it_setup_fan(struct it_softc *sc, int start, int n) { int i; - for (i = 0; i < n; ++i) { + for (i = 0; i < n; ++i) sc->sensors[start + i].type = SENSOR_FANRPM; - snprintf(sc->sensors[start + i].desc, - sizeof(sc->sensors[start + i].desc), - "Fan%d", i + 1); - } } void diff --git a/sys/dev/isa/itvar.h b/sys/dev/isa/itvar.h index 868204e805b..509c8e23697 100644 --- a/sys/dev/isa/itvar.h +++ b/sys/dev/isa/itvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: itvar.h,v 1.2 2003/11/05 20:57:10 grange Exp $ */ +/* $OpenBSD: itvar.h,v 1.3 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2003 Julien Bordet <zejames@greyhats.org> @@ -81,6 +81,7 @@ struct it_softc { bus_space_handle_t it_ioh; struct sensor sensors[IT_NUM_SENSORS]; + struct sensordev sensordev; u_int numsensors; void (*refresh_sensor_data)(struct it_softc *); diff --git a/sys/dev/isa/nsclpcsio_isa.c b/sys/dev/isa/nsclpcsio_isa.c index 9e895e5cfaf..3159c4158e5 100644 --- a/sys/dev/isa/nsclpcsio_isa.c +++ b/sys/dev/isa/nsclpcsio_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nsclpcsio_isa.c,v 1.9 2006/06/26 17:47:34 kettenis Exp $ */ +/* $OpenBSD: nsclpcsio_isa.c,v 1.10 2006/12/23 17:46:39 deraadt Exp $ */ /* $NetBSD: nsclpcsio_isa.c,v 1.5 2002/10/22 16:18:26 drochner Exp $ */ /* @@ -177,6 +177,7 @@ struct nsclpcsio_softc { /* TMS and VLM */ struct sensor sensors[SIO_NUM_SENSORS]; + struct sensordev sensordev; }; #define GPIO_READ(sc, reg) \ @@ -324,15 +325,16 @@ nsclpcsio_isa_attach(struct device *parent, struct device *self, void *aux) nsclpcsio_vlm_init(sc); /* Hook into hw.sensors sysctl */ + strlcpy(sc->sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sensordev.xname)); for (i = 0; i < SIO_NUM_SENSORS; i++) { if (i < SIO_VLM_OFF && !sc->sc_ld_en[SIO_LDN_TMS]) continue; if (i >= SIO_VLM_OFF && !sc->sc_ld_en[SIO_LDN_VLM]) continue; - strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sensors[i].device)); - sensor_add(&sc->sensors[i]); + sensor_attach(&sc->sensordev, &sc->sensors[i]); } + sensordev_install(&sc->sensordev); if (sc->sc_ld_en[SIO_LDN_TMS] || sc->sc_ld_en[SIO_LDN_VLM]) { timeout_set(&nsclpcsio_timeout, nsclpcsio_refresh, sc); timeout_add(&nsclpcsio_timeout, (20 * hz) / 10); diff --git a/sys/dev/isa/viasio.c b/sys/dev/isa/viasio.c index 1e8d738790b..6dca69d62d1 100644 --- a/sys/dev/isa/viasio.c +++ b/sys/dev/isa/viasio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viasio.c,v 1.7 2006/06/26 17:33:35 kettenis Exp $ */ +/* $OpenBSD: viasio.c,v 1.8 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org> * @@ -53,6 +53,7 @@ struct viasio_softc { bus_space_handle_t sc_hm_ioh; int sc_hm_clock; struct sensor sc_hm_sensors[VT1211_HM_NSENSORS]; + struct sensordev sc_sensordev; struct timeout sc_hm_timo; /* Watchdog timer */ @@ -275,15 +276,8 @@ viasio_hm_init(struct viasio_softc *sc) sc->sc_hm_clock = vt1211_hm_clock[reg0 & 0x07]; DPRINTF((", PWMCS 0x%02x, %dHz", reg0, sc->sc_hm_clock)); - /* Initialize sensors */ - for (i = 0; i < VT1211_HM_NSENSORS; i++) - strlcpy(sc->sc_hm_sensors[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_hm_sensors[i].device)); - /* Temperature reading 1 */ sc->sc_hm_sensors[VT1211_HMS_TEMP1].type = SENSOR_TEMP; - strlcpy(sc->sc_hm_sensors[VT1211_HMS_TEMP1].desc, "Temp", - sizeof(sc->sc_hm_sensors[VT1211_HMS_TEMP1].desc)); /* Universal channels (UCH) 1-5 */ reg0 = bus_space_read_1(sc->sc_iot, sc->sc_hm_ioh, VT1211_HM_UCHCONF); @@ -309,15 +303,14 @@ viasio_hm_init(struct viasio_softc *sc) /* FAN reading 1, 2 */ sc->sc_hm_sensors[VT1211_HMS_FAN1].type = SENSOR_FANRPM; - strlcpy(sc->sc_hm_sensors[VT1211_HMS_FAN1].desc, "FAN1", - sizeof(sc->sc_hm_sensors[VT1211_HMS_FAN1].desc)); sc->sc_hm_sensors[VT1211_HMS_FAN2].type = SENSOR_FANRPM; - strlcpy(sc->sc_hm_sensors[VT1211_HMS_FAN2].desc, "FAN2", - sizeof(sc->sc_hm_sensors[VT1211_HMS_FAN2].desc)); /* Start sensors */ + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); for (i = 0; i < VT1211_HM_NSENSORS; i++) - sensor_add(&sc->sc_hm_sensors[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_hm_sensors[i]); + sensordev_install(&sc->sc_sensordev); timeout_set(&sc->sc_hm_timo, viasio_hm_refresh, sc); timeout_add(&sc->sc_hm_timo, hz); } diff --git a/sys/dev/onewire/owid.c b/sys/dev/onewire/owid.c index 38d2b1fe72b..26711ee23a9 100644 --- a/sys/dev/onewire/owid.c +++ b/sys/dev/onewire/owid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: owid.c,v 1.2 2006/06/23 06:27:11 miod Exp $ */ +/* $OpenBSD: owid.c,v 1.3 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -38,6 +38,7 @@ struct owid_softc { u_int64_t sc_rom; struct sensor sc_sensor; + struct sensordev sc_sensordev; int sc_dying; }; @@ -80,12 +81,13 @@ owid_attach(struct device *parent, struct device *self, void *aux) sc->sc_rom = oa->oa_rom; /* Initialize sensor */ - strlcpy(sc->sc_sensor.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor.device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor.type = SENSOR_INTEGER; strlcpy(sc->sc_sensor.desc, "ID", sizeof(sc->sc_sensor.desc)); sc->sc_sensor.value = ONEWIRE_ROM_SN(sc->sc_rom); - sensor_add(&sc->sc_sensor); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + sensordev_install(&sc->sc_sensordev); printf("\n"); } @@ -95,7 +97,7 @@ owid_detach(struct device *self, int flags) { struct owid_softc *sc = (struct owid_softc *)self; - sensor_del(&sc->sc_sensor); + sensordev_deinstall(&sc->sc_sensordev); return (0); } diff --git a/sys/dev/onewire/owtemp.c b/sys/dev/onewire/owtemp.c index cd561a54c69..a470b841279 100644 --- a/sys/dev/onewire/owtemp.c +++ b/sys/dev/onewire/owtemp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: owtemp.c,v 1.5 2006/12/20 14:46:59 grange Exp $ */ +/* $OpenBSD: owtemp.c,v 1.6 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -52,6 +52,7 @@ struct owtemp_softc { u_int64_t sc_rom; struct sensor sc_sensor; + struct sensordev sc_sensordev; struct rwlock sc_lock; }; @@ -95,16 +96,16 @@ owtemp_attach(struct device *parent, struct device *self, void *aux) sc->sc_rom = oa->oa_rom; /* Initialize sensor */ - strlcpy(sc->sc_sensor.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensor.device)); + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); sc->sc_sensor.type = SENSOR_TEMP; - strlcpy(sc->sc_sensor.desc, "Temp", sizeof(sc->sc_sensor.desc)); if (sensor_task_register(sc, owtemp_update, 5)) { printf(": unable to register update task\n"); return; } - sensor_add(&sc->sc_sensor); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + sensordev_install(&sc->sc_sensordev); rw_init(&sc->sc_lock, sc->sc_dev.dv_xname); printf("\n"); @@ -116,7 +117,7 @@ owtemp_detach(struct device *self, int flags) struct owtemp_softc *sc = (struct owtemp_softc *)self; rw_enter_write(&sc->sc_lock); - sensor_del(&sc->sc_sensor); + sensordev_deinstall(&sc->sc_sensordev); sensor_task_unregister(sc); rw_exit_write(&sc->sc_lock); diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c index 60479ad5d45..f2c15cacdfc 100644 --- a/sys/dev/pci/arc.c +++ b/sys/dev/pci/arc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc.c,v 1.56 2006/12/22 22:55:36 deraadt Exp $ */ +/* $OpenBSD: arc.c,v 1.57 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -385,6 +385,7 @@ struct arc_softc { volatile int sc_talking; struct sensor *sc_sensors; + struct sensordev sc_sensordev; int sc_nsensors; }; #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) @@ -1573,6 +1574,9 @@ arc_create_sensors(void *xsc, void *arg) return; bzero(sc->sc_sensors, sizeof(struct sensor) * sc->sc_nsensors); + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < sc->sc_nsensors; i++) { bzero(&bv, sizeof(bv)); bv.bv_volid = i; @@ -1582,22 +1586,20 @@ arc_create_sensors(void *xsc, void *arg) sc->sc_sensors[i].type = SENSOR_DRIVE; sc->sc_sensors[i].status = SENSOR_S_UNKNOWN; - strlcpy(sc->sc_sensors[i].device, DEVNAME(sc), - sizeof(sc->sc_sensors[i].device)); strlcpy(sc->sc_sensors[i].desc, bv.bv_dev, sizeof(sc->sc_sensors[i].desc)); - sensor_add(&sc->sc_sensors[i]); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]); } if (sensor_task_register(sc, arc_refresh_sensors, 120) != 0) goto bad; + sensordev_install(&sc->sc_sensordev); + return; bad: - while (--i >= 0) - sensor_del(&sc->sc_sensors[i]); free(sc->sc_sensors, M_DEVBUF); } diff --git a/sys/dev/pci/mbg.c b/sys/dev/pci/mbg.c index 4d3941a5c19..7b185e59401 100644 --- a/sys/dev/pci/mbg.c +++ b/sys/dev/pci/mbg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbg.c,v 1.6 2006/12/22 09:04:42 mbalmer Exp $ */ +/* $OpenBSD: mbg.c,v 1.7 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org> @@ -39,6 +39,7 @@ struct mbg_softc { struct sensor sc_timedelta; struct sensor sc_signal; + struct sensordev sc_sensordev; u_int8_t sc_status; }; @@ -153,26 +154,28 @@ mbg_attach(struct device *parent, struct device *self, void *aux) printf("invalid\n"); sc->sc_status = tframe.status; } - strlcpy(sc->sc_timedelta.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_timedelta.device)); + + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + sc->sc_timedelta.type = SENSOR_TIMEDELTA; sc->sc_timedelta.status = SENSOR_S_UNKNOWN; sc->sc_timedelta.value = 0LL; sc->sc_timedelta.flags = 0; strlcpy(sc->sc_timedelta.desc, "DCF77", sizeof(sc->sc_timedelta.desc)); - sensor_add(&sc->sc_timedelta); + sensor_attach(&sc->sc_sensordev, &sc->sc_timedelta); - strlcpy(sc->sc_signal.device, sc->sc_dev.dv_xname, - sizeof(sc->sc_signal.device)); sc->sc_signal.type = SENSOR_PERCENT; sc->sc_signal.status = SENSOR_S_UNKNOWN; sc->sc_signal.value = 0LL; sc->sc_signal.flags = 0; strlcpy(sc->sc_signal.desc, "Signal strength", sizeof(sc->sc_signal.desc)); - sensor_add(&sc->sc_signal); + sensor_attach(&sc->sc_sensordev, &sc->sc_signal); sensor_task_register(sc, mbg_task, 10); + + sensordev_install(&sc->sc_sensordev); } void diff --git a/sys/dev/pci/viaenv.c b/sys/dev/pci/viaenv.c index 9f7a16fb672..04d389b86d1 100644 --- a/sys/dev/pci/viaenv.c +++ b/sys/dev/pci/viaenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viaenv.c,v 1.8 2006/06/19 14:43:54 kettenis Exp $ */ +/* $OpenBSD: viaenv.c,v 1.9 2006/12/23 17:46:39 deraadt Exp $ */ /* $NetBSD: viaenv.c,v 1.9 2002/10/02 16:51:59 thorpej Exp $ */ /* @@ -70,6 +70,7 @@ struct viaenv_softc { int sc_fan_div[2]; /* fan RPM divisor */ struct sensor sc_data[VIANUMSENSORS]; + struct sensordev sc_sensordev; }; int viaenv_match(struct device *, void *, void *); @@ -283,25 +284,13 @@ viaenv_attach(struct device * parent, struct device * self, void *aux) goto nohwm; } - /* Initialize sensors */ - for (i = 0; i < VIANUMSENSORS; ++i) { - strlcpy(sc->sc_data[i].device, sc->sc_dev.dv_xname, - sizeof(sc->sc_data[i].device)); - sensor_add(&sc->sc_data[i]); - } - for (i = 0; i <= 2; i++) { sc->sc_data[i].type = SENSOR_TEMP; } - strlcpy(sc->sc_data[0].desc, "TSENS1", sizeof(sc->sc_data[0].desc)); - strlcpy(sc->sc_data[1].desc, "TSENS2", sizeof(sc->sc_data[1].desc)); - strlcpy(sc->sc_data[2].desc, "TSENS3", sizeof(sc->sc_data[2].desc)); for (i = 3; i <= 4; i++) { sc->sc_data[i].type = SENSOR_FANRPM; } - strlcpy(sc->sc_data[3].desc, "FAN1", sizeof(sc->sc_data[3].desc)); - strlcpy(sc->sc_data[4].desc, "FAN2", sizeof(sc->sc_data[4].desc)); for (i = 5; i <= 9; ++i) { sc->sc_data[i].type = SENSOR_VOLTS_DC; @@ -320,6 +309,13 @@ viaenv_attach(struct device * parent, struct device * self, void *aux) /* Get initial set of sensor values. */ viaenv_refresh_sensor_data(sc); + /* Register sensors with sysctl */ + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < VIANUMSENSORS; ++i) + sensor_attach(&sc->sc_sensordev, &sc->sc_data[i]); + sensordev_install(&sc->sc_sensordev); + /* Refresh sensors data every 1.5 seconds */ timeout_set(&viaenv_timeout, viaenv_refresh, sc); timeout_add(&viaenv_timeout, (15 * hz) / 10); diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c index fd44cfa9041..df04ee36814 100644 --- a/sys/dev/usb/udcf.c +++ b/sys/dev/usb/udcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udcf.c,v 1.27 2006/12/10 16:47:44 mbalmer Exp $ */ +/* $OpenBSD: udcf.c,v 1.28 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org> @@ -102,6 +102,7 @@ struct udcf_softc { #ifdef UDCF_DEBUG struct sensor sc_skew; /* recv vs local skew */ #endif + struct sensordev sc_sensordev; }; /* @@ -194,25 +195,28 @@ USB_ATTACH(udcf) sc->sc_last = 0L; sc->sc_last_tv.tv_sec = 0L; - strlcpy(sc->sc_sensor.device, USBDEVNAME(sc->sc_dev), - sizeof(sc->sc_sensor.device)); + strlcpy(sc->sc_sensordev.xname, USBDEVNAME(sc->sc_dev), + sizeof(sc->sc_sensordev.xname)); + sc->sc_sensor.type = SENSOR_TIMEDELTA; sc->sc_sensor.status = SENSOR_S_UNKNOWN; sc->sc_sensor.value = 0LL; sc->sc_sensor.flags = 0; strlcpy(sc->sc_sensor.desc, "Unknown", sizeof(sc->sc_sensor.desc)); - sensor_add(&sc->sc_sensor); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + #ifdef UDCF_DEBUG - strlcpy(sc->sc_skew.device, USBDEVNAME(sc->sc_dev), - sizeof(sc->sc_skew.device)); sc->sc_skew.type = SENSOR_TIMEDELTA; sc->sc_skew.status = SENSOR_S_UNKNOWN; sc->sc_skew.value = 0LL; sc->sc_skew.flags = 0; strlcpy(sc->sc_skew.desc, "local clock skew", sizeof(sc->sc_skew.desc)); - sensor_add(&sc->sc_skew); + sensor_attach(&sc->sc_sensordev, &sc->sc_skew); #endif + + sensordev_install(&sc->sc_sensordev); + /* Prepare the USB request to probe the value */ sc->sc_req.bmRequestType = UDCF_READ_REQ; sc->sc_req.bRequest = 1; @@ -320,10 +324,7 @@ USB_DETACH(udcf) timeout_del(&sc->sc_ct_to); /* Unregister the clock with the kernel */ - sensor_del(&sc->sc_sensor); -#ifdef UDCF_DEBUG - sensor_del(&sc->sc_skew); -#endif + sensordev_deinstall(&sc->sc_sensordev); usb_rem_task(sc->sc_udev, &sc->sc_task); usb_rem_task(sc->sc_udev, &sc->sc_bv_task); usb_rem_task(sc->sc_udev, &sc->sc_mg_task); diff --git a/sys/kern/tty_nmea.c b/sys/kern/tty_nmea.c index 4e965bd964a..f8b789a679b 100644 --- a/sys/kern/tty_nmea.c +++ b/sys/kern/tty_nmea.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_nmea.c,v 1.15 2006/12/23 08:29:39 mbalmer Exp $ */ +/* $OpenBSD: tty_nmea.c,v 1.16 2006/12/23 17:46:38 deraadt Exp $ */ /* * Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org> @@ -52,6 +52,7 @@ struct nmea { #ifdef NMEA_DEBUG struct sensor skew; /* soft to tty timestamp skew */ #endif + struct sensordev timedev; struct timespec ts; /* soft timestamp */ struct timeval tv; /* tty timestamp */ int64_t last; /* last time rcvd */ @@ -86,19 +87,19 @@ nmeaopen(dev_t dev, struct tty *tp) return (error); np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK); bzero(np, sizeof(*np)); - snprintf(np->time.device, sizeof(np->time.device), "nmea%d", + snprintf(np->timedev.xname, sizeof(np->timedev.xname), "nmea%d", nmea_count++); np->time.status = SENSOR_S_UNKNOWN; np->time.type = SENSOR_TIMEDELTA; np->time.flags = SENSOR_FINVALID; + sensor_attach(&np->timedev, &np->time); #ifdef NMEA_DEBUG - snprintf(np->skew.device, sizeof(np->skew.device), "skew%d", - nmea_count - 1); snprintf(np->skew.desc, sizeof(np->skew.desc), "nmea%d timestamp skew", nmea_count - 1); np->skew.status = SENSOR_S_UNKNOWN; np->skew.type = SENSOR_TIMEDELTA; np->skew.flags = SENSOR_FINVALID; + sensor_attach(&np->timedev, &np->skew); #endif np->sync = 1; tp->t_sc = (caddr_t)np; @@ -107,12 +108,8 @@ nmeaopen(dev_t dev, struct tty *tp) if (error) { free(np, M_DEVBUF); tp->t_sc = NULL; - } else { - sensor_add(&np->time); -#ifdef NMEA_DEBUG - sensor_add(&np->skew); -#endif - } + } else + sensordev_install(&np->timedev); return (error); } @@ -122,10 +119,7 @@ nmeaclose(struct tty *tp, int flags) struct nmea *np = (struct nmea *)tp->t_sc; tp->t_line = TTYDISC; /* switch back to termios */ - sensor_del(&np->time); -#ifdef NMEA_DEBUG - sensor_del(&np->skew); -#endif + sensordev_deinstall(&np->timedev); free(np, M_DEVBUF); tp->t_sc = NULL; nmea_count--; diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c index 4bc8d19a91a..f3c2335b193 100644 --- a/sys/scsi/safte.c +++ b/sys/scsi/safte.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safte.c,v 1.31 2006/11/28 16:56:50 dlg Exp $ */ +/* $OpenBSD: safte.c,v 1.32 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> @@ -71,6 +71,7 @@ struct safte_softc { int sc_nsensors; struct safte_sensor *sc_sensors; + struct sensordev sc_sensordev; int sc_celsius; int sc_ntemps; @@ -185,7 +186,9 @@ safte_attach(struct device *parent, struct device *self, void *aux) free(sc->sc_sensors, M_DEVBUF); } else { for (i = 0; i < sc->sc_nsensors; i++) - sensor_add(&sc->sc_sensors[i].se_sensor); + sensor_attach(&sc->sc_sensordev, + &sc->sc_sensors[i].se_sensor); + sensordev_install(&sc->sc_sensordev); } #if NBIO > 0 @@ -219,10 +222,12 @@ safte_detach(struct device *self, int flags) #endif if (sc->sc_nsensors > 0) { + sensordev_deinstall(&sc->sc_sensordev); sensor_task_unregister(sc); for (i = 0; i < sc->sc_nsensors; i++) - sensor_del(&sc->sc_sensors[i].se_sensor); + sensor_detach(&sc->sc_sensordev, + &sc->sc_sensors[i].se_sensor); free(sc->sc_sensors, M_DEVBUF); } @@ -290,6 +295,9 @@ safte_read_config(struct safte_softc *sc) return (1); } + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + memset(sc->sc_sensors, 0, sc->sc_nsensors * sizeof(struct safte_sensor)); s = sc->sc_sensors; @@ -354,8 +362,6 @@ safte_read_config(struct safte_softc *sc) s->se_type = SAFTE_T_TEMP; s->se_field = (u_int8_t *)(sc->sc_encbuf + j + i); s->se_sensor.type = SENSOR_TEMP; - snprintf(s->se_sensor.desc, sizeof(s->se_sensor.desc), - "Temp%d", i); s++; } @@ -363,10 +369,6 @@ safte_read_config(struct safte_softc *sc) sc->sc_temperrs = (u_int16_t *)(sc->sc_encbuf + j); - for (i = 0; i < sc->sc_nsensors; i++) - strlcpy(sc->sc_sensors[i].se_sensor.device, DEVNAME(sc), - sizeof(sc->sc_sensors[i].se_sensor.device)); - return (0); } diff --git a/sys/scsi/ses.c b/sys/scsi/ses.c index 7ad1f6d7418..0f2adcdad1c 100644 --- a/sys/scsi/ses.c +++ b/sys/scsi/ses.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ses.c,v 1.41 2006/11/28 16:56:50 dlg Exp $ */ +/* $OpenBSD: ses.c,v 1.42 2006/12/23 17:46:39 deraadt Exp $ */ /* * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> @@ -83,6 +83,7 @@ struct ses_softc { TAILQ_HEAD(, ses_slot) sc_slots; #endif TAILQ_HEAD(, ses_sensor) sc_sensors; + struct sensordev sc_sensordev; }; struct cfattach ses_ca = { @@ -178,7 +179,8 @@ ses_attach(struct device *parent, struct device *self, void *aux) } } else { TAILQ_FOREACH(sensor, &sc->sc_sensors, se_entry) - sensor_add(&sensor->se_sensor); + sensor_attach(&sc->sc_sensordev, &sensor->se_sensor); + sensordev_install(&sc->sc_sensordev); } #if NBIO > 0 @@ -226,11 +228,12 @@ ses_detach(struct device *self, int flags) #endif if (!TAILQ_EMPTY(&sc->sc_sensors)) { + sensordev_deinstall(&sc->sc_sensordev); sensor_task_unregister(sc); while (!TAILQ_EMPTY(&sc->sc_sensors)) { sensor = TAILQ_FIRST(&sc->sc_sensors); - sensor_del(&sensor->se_sensor); + sensor_detach(&sc->sc_sensordev, &sensor->se_sensor); TAILQ_REMOVE(&sc->sc_sensors, sensor, se_entry); free(sensor, M_DEVBUF); } @@ -384,16 +387,13 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes) #endif enum sensor_type stype; char *fmt; - int *typecnt; int i, j; if (ses_read_status(sc) != 0) return (1); - typecnt = malloc(sizeof(int) * SES_NUM_TYPES, M_TEMP, M_NOWAIT); - if (typecnt == NULL) - return (1); - memset(typecnt, 0, sizeof(int) * SES_NUM_TYPES); + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); TAILQ_INIT(&sc->sc_sensors); #if NBIO > 0 @@ -437,17 +437,17 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes) case SES_T_POWERSUPPLY: stype = SENSOR_INDICATOR; - fmt = "PSU%d"; + fmt = "PSU"; break; case SES_T_COOLING: stype = SENSOR_PERCENT; - fmt = "Fan%d"; + fmt = "Fan"; break; case SES_T_TEMP: stype = SENSOR_TEMP; - fmt = "Temp%d"; + fmt = ""; break; default: @@ -463,11 +463,8 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes) sensor->se_type = types[i].type; sensor->se_stat = status; sensor->se_sensor.type = stype; - strlcpy(sensor->se_sensor.device, DEVNAME(sc), - sizeof(sensor->se_sensor.device)); - snprintf(sensor->se_sensor.desc, - sizeof(sensor->se_sensor.desc), fmt, - typecnt[types[i].type]++); + strlcpy(sensor->se_sensor.desc, fmt, + sizeof(sensor->se_sensor.desc)); TAILQ_INSERT_TAIL(&sc->sc_sensors, sensor, se_entry); } @@ -476,7 +473,6 @@ ses_make_sensors(struct ses_softc *sc, struct ses_type_desc *types, int ntypes) status++; } - free(typecnt, M_TEMP); return (0); error: #if NBIO > 0 @@ -491,7 +487,6 @@ error: TAILQ_REMOVE(&sc->sc_sensors, sensor, se_entry); free(sensor, M_DEVBUF); } - free(typecnt, M_TEMP); return (1); } |