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 /sys/arch | |
parent | 2da4a587cf08c4fd33f160fe0f40ff89d9d3a3c3 (diff) |
adapt to new two-level sensor api; Constantine A. Murenin
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/i386/i386/esm.c | 9 | ||||
-rw-r--r-- | sys/arch/macppc/dev/asms.c | 11 | ||||
-rw-r--r-- | sys/arch/macppc/dev/smu.c | 17 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/pcf8591_ofw.c | 14 |
4 files changed, 31 insertions, 20 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"); } |