From fbe9bfe3e801cbd7a2f6ec47b134d6bd782a861b Mon Sep 17 00:00:00 2001 From: anton Date: Sun, 14 Feb 2021 14:41:35 +0000 Subject: [PATCH] Postpone installation of the periodic sensor task until at least one device has connected. --- sys/dev/usb/uhidpp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/uhidpp.c b/sys/dev/usb/uhidpp.c index 12bf3da7035..28522c54ef6 100644 --- a/sys/dev/usb/uhidpp.c +++ b/sys/dev/usb/uhidpp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidpp.c,v 1.9 2021/02/14 14:40:38 anton Exp $ */ +/* $OpenBSD: uhidpp.c,v 1.10 2021/02/14 14:41:35 anton Exp $ */ /* * Copyright (c) 2021 Anton Lindqvist @@ -398,7 +398,6 @@ uhidpp_attach(struct device *parent, struct device *self, void *aux) strlcpy(sc->sc_sensdev.xname, sc->sc_hdev.sc_dev.dv_xname, sizeof(sc->sc_sensdev.xname)); sensordev_install(&sc->sc_sensdev); - sc->sc_senstsk = sensor_task_register(sc, uhidpp_refresh, 6); out: mtx_leave(&sc->sc_mtx); @@ -622,6 +621,9 @@ uhidpp_device_connect(struct uhidpp_softc *sc, struct uhidpp_device *dev) sens->value = dev->d_battery.b_nlevels; sensor_attach(&sc->sc_sensdev, sens); + if (sc->sc_senstsk == NULL) + sc->sc_senstsk = sensor_task_register(sc, uhidpp_refresh, 6); + dev->d_connected = 1; uhidpp_device_refresh(sc, dev); } -- 2.20.1