Page MenuHomeFreeBSD

D9254.1791170427.diff
No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None

D9254.1791170427.diff

Index: sys/dev/gpio/gpioths.c
===================================================================
--- sys/dev/gpio/gpioths.c
+++ sys/dev/gpio/gpioths.c
@@ -137,7 +137,7 @@
}
/*
- * According to specifications we need to wait no more than 18ms
+ * According to specifications we need to wait no less than 18ms
* to start data transfer
*/
DELAY(GPIOTHS_DHT_STARTCYCLE);
@@ -170,14 +170,21 @@
sc = device_get_softc(dev);
+ /*
+ * Mark thread as in critical section to avoid preemption during GPIO
+ * manipulations & measurements
+ */
+ critical_enter();
err = gpioths_dht_initread(bus,dev);
if (err) {
+ critical_exit();
device_printf(dev, "gpioths_dht_initread error = %d\n", err);
goto error;
}
err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_LOW, NULL);
if (err) {
+ critical_exit();
device_printf(dev, "err(START) = %d\n", err);
goto error;
}
@@ -187,12 +194,14 @@
err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_HIGH,
&calibrations[i]);
if (err) {
+ critical_exit();
device_printf(dev, "err(CAL, %d) = %d\n", i, err);
goto error;
}
err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_LOW,
&intervals[i]);
if (err) {
+ critical_exit();
device_printf(dev, "err(INTERVAL, %d) = %d\n", i, err);
goto error;
}
@@ -200,10 +209,11 @@
err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_OUTPUT);
if (err != 0) {
+ critical_exit();
device_printf(dev, "err(FINAL_SETFLAGS, OUT) = %d\n", err);
goto error;
}
- DELAY(1);
+ critical_exit();
/* Calculate average data calibration cycle length */
avglen = 0;
@@ -352,6 +362,16 @@
static int
gpioths_detach(device_t dev)
{
+ struct gpioths_softc *sc;
+
+ sc = device_get_softc(dev);
+ callout_drain(&sc->callout);
+
+ /*
+ * gpioths_detach process doesn't touch sysctl because they're are
+ * located under oid "dev.<driver>" and this oid has been already
+ * removed before gpioths_detach is called
+ */
return (0);
}
Index: sys/modules/gpio/Makefile
===================================================================
--- sys/modules/gpio/Makefile
+++ sys/modules/gpio/Makefile
@@ -25,7 +25,7 @@
# SUCH DAMAGE.
#
-SUBDIR = gpiobus gpioiic gpioled gpiospi
+SUBDIR = gpiobus gpioiic gpioled gpiospi gpioths
.if !empty(OPT_FDT)
SUBDIR += gpiokeys gpiopps
Index: sys/modules/gpio/gpioths/Makefile
===================================================================
--- /dev/null
+++ sys/modules/gpio/gpioths/Makefile
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2016 Michael Zhilin, <mizhka@freebsd.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer,
+# without modification.
+# 2. Redistributions in binary form must reproduce at minimum a disclaimer
+# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+# redistribution must be conditioned upon including a substantially
+# similar Disclaimer requirement for further binary redistribution.
+#
+# NO WARRANTY
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGES.
+#
+# $FreeBSD$
+#
+
+.PATH: ${.CURDIR}/../../../dev/gpio/
+
+KMOD= gpioths
+SRCS= gpioths.c bus_if.h gpiobus_if.h
+
+CFLAGS+= -I. -I${.CURDIR}/../../../dev/gpio/
+
+.include <bsd.kmod.mk>

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 5, 3:20 AM (9 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30169397
Default Alt Text
D9254.1791170427.diff (4 KB)

Event Timeline