Exemple #1
0
void
owctr_attach(struct device *parent, struct device *self, void *aux)
{
	struct owctr_softc *sc = (struct owctr_softc *)self;
	struct onewire_attach_args *oa = aux;

	sc->sc_onewire = oa->oa_onewire;
	sc->sc_rom = oa->oa_rom;

	/* Initialize counter sensors */
	strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
		sizeof(sc->sc_sensordev.xname));
	sc->sc_counterA.type = SENSOR_INTEGER;
	snprintf(sc->sc_counterA.desc, sizeof(sc->sc_counterA.desc),
		"Counter A sn %012llx", ONEWIRE_ROM_SN(oa->oa_rom));
	sensor_attach(&sc->sc_sensordev, &sc->sc_counterA);
	sc->sc_counterB.type = SENSOR_INTEGER;
	snprintf(sc->sc_counterB.desc, sizeof(sc->sc_counterB.desc),
		"Counter B sn %012llx", ONEWIRE_ROM_SN(oa->oa_rom));
	sensor_attach(&sc->sc_sensordev, &sc->sc_counterB);

	sc->sc_sensortask = sensor_task_register(sc, owctr_update, 10);
	if (sc->sc_sensortask == NULL) {
		printf(": unable to register update task\n");
		return;
	}

	sensordev_install(&sc->sc_sensordev);

	rw_init(&sc->sc_lock, sc->sc_dev.dv_xname);
	printf("\n");
}
Exemple #2
0
void
owid_attach(struct device *parent, struct device *self, void *aux)
{
	struct owid_softc *sc = (struct owid_softc *)self;
	struct onewire_attach_args *oa = aux;

	sc->sc_onewire = oa->oa_onewire;
	sc->sc_rom = oa->oa_rom;

	/* Initialize sensor */
	strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
	    sizeof(sc->sc_sensordev.xname));
	sc->sc_sensor.type = SENSOR_INTEGER;
	sc->sc_sensor.value = ONEWIRE_ROM_SN(sc->sc_rom);
	sensor_attach(&sc->sc_sensordev, &sc->sc_sensor);
	sensordev_install(&sc->sc_sensordev);

	printf("\n");
}