CVS commit: src
Module Name:src Committed By: brad Date: Fri Nov 24 15:13:36 UTC 2023 Modified Files: src/share/man/man4: gpiosim.4 src/sys/dev/gpio: gpiosim.c Log Message: Style changes. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/gpiosim.4 cvs rdiff -u -r1.25 -r1.26 src/sys/dev/gpio/gpiosim.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/gpiosim.4 diff -u src/share/man/man4/gpiosim.4:1.7 src/share/man/man4/gpiosim.4:1.8 --- src/share/man/man4/gpiosim.4:1.7 Wed Nov 8 23:46:54 2023 +++ src/share/man/man4/gpiosim.4 Fri Nov 24 15:13:35 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpiosim.4,v 1.7 2023/11/08 23:46:54 brad Exp $ +.\" $NetBSD: gpiosim.4,v 1.8 2023/11/24 15:13:35 brad Exp $ .\" .\" Copyright (c) 2009, 2013 Marc Balmer .\" All rights reserved. @@ -38,7 +38,8 @@ variable, where "" denotes the number .Nm instance. .Pp -Both edge and level interrupts are simulated. The "hw.gpiosim.ms" +Both edge and level interrupts are simulated. +The "hw.gpiosim.ms" .Xr sysctl 8 variable will change the amount of time between .Xr callout 9 Index: src/sys/dev/gpio/gpiosim.c diff -u src/sys/dev/gpio/gpiosim.c:1.25 src/sys/dev/gpio/gpiosim.c:1.26 --- src/sys/dev/gpio/gpiosim.c:1.25 Wed Nov 8 23:46:54 2023 +++ src/sys/dev/gpio/gpiosim.c Fri Nov 24 15:13:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: gpiosim.c,v 1.25 2023/11/08 23:46:54 brad Exp $ */ +/* $NetBSD: gpiosim.c,v 1.26 2023/11/24 15:13:35 brad Exp $ */ /* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */ /* @@ -76,7 +76,7 @@ static void * gpiosim_intr_establish(v static void gpiosim_intr_disestablish(void *, void *); static bool gpiosim_gpio_intrstr(void *, int, int, char *, size_t); -voidgpiosim_wq(struct work *,void *); +voidgpiosim_wq(struct work *, void *); voidgpiosim_co(void *); CFATTACH_DECL_NEW(gpiosim, sizeof(struct gpiosim_softc), gpiosim_match, @@ -149,7 +149,8 @@ gpiosim_attach(device_t parent, device_t sc->sc_gpio_irqs[i].sc_gpio_irqtriggered = false; /* read initial state */ - sc->sc_gpio_pins[i].pin_flags = GPIO_PIN_INPUT;} + sc->sc_gpio_pins[i].pin_flags = GPIO_PIN_INPUT; + } sc->sc_state = 0; sc->sc_ms = GPIOSIM_MS; @@ -200,14 +201,20 @@ gpiosim_attach(device_t parent, device_t gpiosim_ms_sysctl, 0, >sc_ms, 0, CTL_CREATE, CTL_EOL); - error = workqueue_create(>sc_wq,"gsimwq",gpiosim_wq,sc,PRI_NONE,IPL_VM,WQ_MPSAFE); + error = workqueue_create(>sc_wq, + "gsimwq", + gpiosim_wq, + sc, + PRI_NONE, + IPL_VM, + WQ_MPSAFE); if (error != 0) { aprint_error(": can't create workqueue for interrupts\n"); return; } - callout_init(>sc_co,CALLOUT_MPSAFE); - callout_setfunc(>sc_co,gpiosim_co, sc); + callout_init(>sc_co, CALLOUT_MPSAFE); + callout_setfunc(>sc_co, gpiosim_co, sc); sc->sc_co_running = false; sc->sc_co_init = true; @@ -242,7 +249,7 @@ gpiosim_detach(device_t self, int flags) /* Destroy any callouts */ if (sc->sc_co_init) { - callout_halt(>sc_co,NULL); + callout_halt(>sc_co, NULL); callout_destroy(>sc_co); } return 0; @@ -308,7 +315,7 @@ gpiosim_sysctl(SYSCTLFN_ARGS) mutex_exit(>sc_intr_mutex); if (t > 0) { - workqueue_enqueue(sc->sc_wq,(struct work *)_work,NULL); + workqueue_enqueue(sc->sc_wq, (struct work *)_work, NULL); } return 0; @@ -327,6 +334,7 @@ gpiosim_ms_sysctl(SYSCTLFN_ARGS) if (error || newp == NULL) return (error); + /* Make sure that this can not be zero */ if (t < 1) return (EINVAL); @@ -389,7 +397,7 @@ gpiosim_intr_establish(void *vsc, int pi if (((irqmode & GPIO_INTR_HIGH_LEVEL) || (irqmode & GPIO_INTR_LOW_LEVEL)) && (sc->sc_co_running == false)) { - callout_schedule(>sc_co,mstohz(sc->sc_ms)); + callout_schedule(>sc_co, mstohz(sc->sc_ms)); sc->sc_co_running = true; } @@ -488,7 +496,7 @@ gpiosim_co(void *arg) mutex_exit(>sc_intr_mutex); if (sc->sc_co_running == true) { - callout_schedule(>sc_co,mstohz(sc->sc_ms)); + callout_schedule(>sc_co, mstohz(sc->sc_ms)); } } @@ -497,7 +505,7 @@ MODULE(MODULE_CLASS_DRIVER, gpiosim, "gp #ifdef _MODULE static const struct cfiattrdata gpiobus_iattrdata = { - "gpiobus", 0, { { NULL, NULL, 0 },} + "gpiobus", 0, { { NULL, NULL, 0 }, } }; static const struct cfiattrdata *const gpiosim_attrs[] = { _iattrdata, NULL
CVS commit: src
Module Name:src Committed By: brad Date: Fri Nov 24 15:13:36 UTC 2023 Modified Files: src/share/man/man4: gpiosim.4 src/sys/dev/gpio: gpiosim.c Log Message: Style changes. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/gpiosim.4 cvs rdiff -u -r1.25 -r1.26 src/sys/dev/gpio/gpiosim.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/gpio
Module Name:src Committed By: brad Date: Fri Nov 10 13:17:17 UTC 2023 Modified Files: src/sys/dev/gpio: gpioirq.c Log Message: For /dev/ reads against gpioirq(4) implement the following: o O_NONBLOCK on reads o Add a d_poll function and associated sel[init|notify|record|destroy] calls to the driver so that select(2) and poll(2) work as expected. With these in place async use cases work against /dev/gpioirqN To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/gpio/gpioirq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/gpio
Module Name:src Committed By: brad Date: Fri Nov 10 13:17:17 UTC 2023 Modified Files: src/sys/dev/gpio: gpioirq.c Log Message: For /dev/ reads against gpioirq(4) implement the following: o O_NONBLOCK on reads o Add a d_poll function and associated sel[init|notify|record|destroy] calls to the driver so that select(2) and poll(2) work as expected. With these in place async use cases work against /dev/gpioirqN To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/gpio/gpioirq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/gpio/gpioirq.c diff -u src/sys/dev/gpio/gpioirq.c:1.2 src/sys/dev/gpio/gpioirq.c:1.3 --- src/sys/dev/gpio/gpioirq.c:1.2 Mon Nov 6 00:35:05 2023 +++ src/sys/dev/gpio/gpioirq.c Fri Nov 10 13:17:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioirq.c,v 1.2 2023/11/06 00:35:05 brad Exp $ */ +/* $NetBSD: gpioirq.c,v 1.3 2023/11/10 13:17:17 brad Exp $ */ /* * Copyright (c) 2016, 2023 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v 1.2 2023/11/06 00:35:05 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v 1.3 2023/11/10 13:17:17 brad Exp $"); /* * GPIO driver that uses interrupts and can send that fact to userland. @@ -34,6 +34,9 @@ __KERNEL_RCSID(0, "$NetBSD: gpioirq.c,v #include #include #include +#include +#include +#include #include @@ -67,6 +70,7 @@ struct gpioirq_softc { kcondvar_t sc_cond_dying; pool_cache_tsc_readpool; char*sc_readpoolname; + struct selinfo sc_rsel; SIMPLEQ_HEAD(,gpioirq_read_q) sc_read_queue; }; @@ -97,6 +101,7 @@ extern struct cfdriver gpioirq_cd; static dev_type_open(gpioirq_open); static dev_type_read(gpioirq_read); static dev_type_close(gpioirq_close); +static dev_type_poll(gpioirq_poll); const struct cdevsw gpioirq_cdevsw = { .d_open = gpioirq_open, .d_close = gpioirq_close, @@ -105,7 +110,7 @@ const struct cdevsw gpioirq_cdevsw = { .d_ioctl = noioctl, .d_stop = nostop, .d_tty = notty, - .d_poll = nopoll, + .d_poll = gpioirq_poll, .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, @@ -189,6 +194,7 @@ gpioirq_attach(device_t parent, device_t sc->sc_readpool = pool_cache_init(sizeof(struct gpioirq_read_q),0,0,0,sc->sc_readpoolname,NULL,IPL_VM,NULL,NULL,NULL); pool_cache_sethiwat(sc->sc_readpool,100); SIMPLEQ_INIT(>sc_read_queue); + selinit(>sc_rsel); for(int apin = 0; apin < sc->sc_npins; apin++) { if (!gpio_intr_str(sc->sc_gpio, >sc_map, apin, irqmode, @@ -263,6 +269,7 @@ gpioirq_intr(void *arg) q->parentunit = is->i_parentunit; q->theval = val; SIMPLEQ_INSERT_TAIL(>sc_read_queue,q,read_q); + selnotify(>sc_rsel, POLLIN|POLLRDNORM, NOTE_SUBMIT); cv_signal(>sc_condreadready); } else { aprint_error("Could not allocate memory for read pool\n"); @@ -304,6 +311,10 @@ gpioirq_read(dev_t dev, struct uio *uio, if (!sc) return (ENXIO); + if (sc->sc_dying) { + return EIO; + } + while (uio->uio_resid > 0) { any = 0; error = 0; @@ -316,7 +327,11 @@ gpioirq_read(dev_t dev, struct uio *uio, any = 1; break; } else { -error = cv_wait_sig(>sc_condreadready,>sc_read_mutex); +if (flags & IO_NDELAY) { + error = EWOULDBLOCK; +} else { + error = cv_wait_sig(>sc_condreadready,>sc_read_mutex); +} if (sc->sc_dying) error = EIO; if (error == 0) @@ -358,6 +373,10 @@ gpioirq_close(dev_t dev, int flags, int sc = device_lookup_private(_cd, minor(dev)); + if (sc->sc_dying) { + return(0); + } + mutex_enter(>sc_lock); while ((q = SIMPLEQ_FIRST(>sc_read_queue)) != NULL) { SIMPLEQ_REMOVE_HEAD(>sc_read_queue, read_q); @@ -369,6 +388,31 @@ gpioirq_close(dev_t dev, int flags, int return(0); } +static int +gpioirq_poll(dev_t dev, int events, struct lwp *l) +{ +struct gpioirq_softc *sc; +int revents = 0; + +sc = device_lookup_private(_cd, minor(dev)); + + mutex_enter(>sc_read_mutex); + if (sc->sc_dying) { +mutex_exit(>sc_read_mutex); +return POLLHUP; +} + + if ((events & (POLLIN | POLLRDNORM)) != 0) { +if (!SIMPLEQ_EMPTY(>sc_read_queue)) +revents |= events & (POLLIN | POLLRDNORM); +else +selrecord(l, >sc_rsel); +} + + mutex_exit(>sc_read_mutex); +return revents; +} + int gpioirq_detach(device_t self, int flags) { @@ -413,6 +457,7 @@ gpioirq_detach(device_t self, int flags) mutex_destroy(>sc_read_mutex); mutex_destroy(>sc_lock); + seldestroy(>sc_rsel); return (0); }
CVS commit: src
Module Name:src Committed By: brad Date: Wed Nov 8 23:46:55 UTC 2023 Modified Files: src/doc: CHANGES src/share/man/man4: gpiosim.4 src/sys/dev/gpio: gpiosim.c Log Message: Simple simulated interrupts for the simulated GPIO device gpiosim(4) To generate a diff of this commit: cvs rdiff -u -r1.3016 -r1.3017 src/doc/CHANGES cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/gpiosim.4 cvs rdiff -u -r1.24 -r1.25 src/sys/dev/gpio/gpiosim.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.3016 src/doc/CHANGES:1.3017 --- src/doc/CHANGES:1.3016 Mon Nov 6 00:35:06 2023 +++ src/doc/CHANGES Wed Nov 8 23:46:54 2023 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3016 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3017 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -261,3 +261,5 @@ Changes from NetBSD 10.0 to NetBSD 11.0: gpioirq(4): allow multiple pins per gpioirq instance, add the ability to use a /dev/gpioirqN device to get pin interrupts into userland. [brad 20231105] + gpiosim(4): Simulated interrupts + [brad 20231108] Index: src/share/man/man4/gpiosim.4 diff -u src/share/man/man4/gpiosim.4:1.6 src/share/man/man4/gpiosim.4:1.7 --- src/share/man/man4/gpiosim.4:1.6 Mon Jul 3 21:30:58 2017 +++ src/share/man/man4/gpiosim.4 Wed Nov 8 23:46:54 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpiosim.4,v 1.6 2017/07/03 21:30:58 wiz Exp $ +.\" $NetBSD: gpiosim.4,v 1.7 2023/11/08 23:46:54 brad Exp $ .\" .\" Copyright (c) 2009, 2013 Marc Balmer .\" All rights reserved. @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd May 20, 2013 +.Dd November 8, 2013 .Dt GPIOSIM 4 .Os .Sh NAME @@ -37,12 +37,21 @@ For this purpose, access the "hw.gpiosim variable, where "" denotes the number of the .Nm instance. +.Pp +Both edge and level interrupts are simulated. The "hw.gpiosim.ms" +.Xr sysctl 8 +variable will change the amount of time between +.Xr callout 9 +ticks for simulated level interrupts. .Sh SEE ALSO .Xr gpio 4 , +.Xr gpioirq 4 , .Xr sysctl 8 .Sh AUTHORS .An -nosplit The .Nm driver was written by -.An Marc Balmer Aq Mt m...@msys.ch . +.An Marc Balmer Aq Mt m...@msys.ch +Simulated interrupts added by +.An Brad Spencer Aq Mt b...@anduin.eldar.org . Index: src/sys/dev/gpio/gpiosim.c diff -u src/sys/dev/gpio/gpiosim.c:1.24 src/sys/dev/gpio/gpiosim.c:1.25 --- src/sys/dev/gpio/gpiosim.c:1.24 Wed May 10 00:09:39 2023 +++ src/sys/dev/gpio/gpiosim.c Wed Nov 8 23:46:54 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: gpiosim.c,v 1.24 2023/05/10 00:09:39 riastradh Exp $ */ +/* $NetBSD: gpiosim.c,v 1.25 2023/11/08 23:46:54 brad Exp $ */ /* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */ /* @@ -29,34 +29,65 @@ #include #include #include +#include +#include #include "gpiosim.h" #include "ioconf.h" #define GPIOSIM_NPINS 64 +struct gpiosim_irq { + int (*sc_gpio_irqfunc)(void *); + void *sc_gpio_irqarg; + int sc_gpio_irqmode; + bool sc_gpio_irqtriggered; +}; + struct gpiosim_softc { device_t sc_dev; device_t sc_gdev; /* gpio that attaches here */ uint64_t sc_state; struct gpio_chipset_tag sc_gpio_gc; gpio_pin_t sc_gpio_pins[GPIOSIM_NPINS]; +struct gpiosim_irq sc_gpio_irqs[GPIOSIM_NPINS]; struct sysctllog *sc_log; +struct workqueue*sc_wq; +callout_t sc_co; +boolsc_co_init; + bool sc_co_running; +int sc_ms; +kmutex_t sc_intr_mutex; }; static int gpiosim_match(device_t, cfdata_t, void *); static void gpiosim_attach(device_t, device_t, void *); static int gpiosim_detach(device_t, int); static int gpiosim_sysctl(SYSCTLFN_PROTO); +static int gpiosim_ms_sysctl(SYSCTLFN_PROTO); static int gpiosim_pin_read(void *, int); static void gpiosim_pin_write(void *, int, int); static void gpiosim_pin_ctl(void *, int, int); +static void * gpiosim_intr_establish(void *, int, int, int, +int (*)(void *), void *); +static void gpiosim_intr_disestablish(void *, void *); +static bool gpiosim_gpio_intrstr(void *, int, int, char *, size_t); + +voidgpiosim_wq(struct work *,void *); +voidgpiosim_co(void *); + CFATTACH_DECL_NEW(gpiosim, sizeof(struct gpiosim_softc), gpiosim_match, gpiosim_attach, gpiosim_detach, NULL); +int gpiosim_work; + +#ifndef GPIOSIM_MS +#define GPIOSIM_MS 1000 +#endif + static int gpiosim_match(device_t parent, cfdata_t match, void *aux) { @@ -90,6 +121,7 @@ gpiosim_attach(device_t parent, device_t struct gpiobus_attach_args gba; con
CVS commit: src
Module Name:src Committed By: brad Date: Wed Nov 8 23:46:55 UTC 2023 Modified Files: src/doc: CHANGES src/share/man/man4: gpiosim.4 src/sys/dev/gpio: gpiosim.c Log Message: Simple simulated interrupts for the simulated GPIO device gpiosim(4) To generate a diff of this commit: cvs rdiff -u -r1.3016 -r1.3017 src/doc/CHANGES cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/gpiosim.4 cvs rdiff -u -r1.24 -r1.25 src/sys/dev/gpio/gpiosim.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Mon Nov 6 00:35:06 UTC 2023 Modified Files: src/doc: CHANGES src/etc: MAKEDEV.tmpl src/share/man/man4: gpioirq.4 src/sys/conf: majors src/sys/dev/gpio: gpio.c gpioirq.c gpiovar.h Log Message: gpioirq(4) version 2 This update makes this driver more than just an example and allows for: o More than one pin to be attached to a gpioirq instance. That is, the mask parameter can be greater than 0x01 now. o A /dev/gpioirqN device that allows GPIO pin interrupts to be transported into userland. This is a device that can be opened for reading with a simple fixed output indicating the device unit, pin number and current pin state. This update was used as part of a physical intrusion detection system where multiple switches (i.e. window magnetic reed switches and etc.) are tied to a bunch of GPIO inputs with userland software that reacts to the pins changing state. To generate a diff of this commit: cvs rdiff -u -r1.3015 -r1.3016 src/doc/CHANGES cvs rdiff -u -r1.233 -r1.234 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/gpioirq.4 cvs rdiff -u -r1.102 -r1.103 src/sys/conf/majors cvs rdiff -u -r1.72 -r1.73 src/sys/dev/gpio/gpio.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/gpio/gpioirq.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/gpio/gpiovar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.3015 src/doc/CHANGES:1.3016 --- src/doc/CHANGES:1.3015 Sun Nov 5 18:32:01 2023 +++ src/doc/CHANGES Mon Nov 6 00:35:06 2023 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3015 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3016 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -258,3 +258,6 @@ Changes from NetBSD 10.0 to NetBSD 11.0: machines. [tsutsui 20231104] ena(4): MP-enable always, add RSS support, and reliability fixes. [jdolecek 20231105] + gpioirq(4): allow multiple pins per gpioirq instance, add the ability + to use a /dev/gpioirqN device to get pin interrupts into userland. + [brad 20231105] Index: src/etc/MAKEDEV.tmpl diff -u src/etc/MAKEDEV.tmpl:1.233 src/etc/MAKEDEV.tmpl:1.234 --- src/etc/MAKEDEV.tmpl:1.233 Wed Dec 28 19:23:02 2022 +++ src/etc/MAKEDEV.tmpl Mon Nov 6 00:35:05 2023 @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: MAKEDEV.tmpl,v 1.233 2022/12/28 19:23:02 jakllsch Exp $ +# $NetBSD: MAKEDEV.tmpl,v 1.234 2023/11/06 00:35:05 brad Exp $ # # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -232,6 +232,7 @@ # dtv* Digital TV interface # fb* PMAX generic framebuffer pseudo-device # fd file descriptors +# gpioirq* Interrupts on GPIO pins # gpiopps* 1PPS signals on GPIO pins # grf* graphics frame buffer device # hdaudio* High Definition audio control device @@ -830,7 +831,7 @@ all) makedev srt0 srt1 srt2 srt3 makedev tap tap0 tap1 tap2 tap3 makedev gpio gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 - makedev gpiopps0 + makedev gpioirq0 gpiopps0 makedev pad pad0 pad1 pad2 pad3 makedev bthub makedev putter @@ -873,6 +874,10 @@ gpio) lndev gpio0 gpio ;; +gpioirq) + makedev gpioirq0 + ;; + gpiopps) makedev gpiopps0 lndev gpiopps0 gpiopps @@ -1547,6 +1552,11 @@ gpio[0-9]*) mkdev gpio$unit c %gpio_chr% $unit 664 $g_gpio ;; +gpioirq[0-9]*) + unit=${i#gpioirq} + mkdev gpioirq$unit c %gpioirq_chr% $unit 444 $g_gpio + ;; + gpiopps[0-9]*) unit=${i#gpiopps} mkdev gpiopps$unit c %gpiopps_chr% $unit 664 $g_gpio Index: src/share/man/man4/gpioirq.4 diff -u src/share/man/man4/gpioirq.4:1.3 src/share/man/man4/gpioirq.4:1.4 --- src/share/man/man4/gpioirq.4:1.3 Tue Aug 1 20:39:15 2023 +++ src/share/man/man4/gpioirq.4 Mon Nov 6 00:35:05 2023 @@ -1,6 +1,6 @@ -.\" $NetBSD: gpioirq.4,v 1.3 2023/08/01 20:39:15 andvar Exp $ +.\" $NetBSD: gpioirq.4,v 1.4 2023/11/06 00:35:05 brad Exp $ .\" -.\" Copyright (c) 2016 Brad Spencer +.\" Copyright (c) 2016, 2023 Brad Spencer .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -14,25 +14,26 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd May 11, 2018 +.Dd November 5, 2023 .Dt GPIOIRQ 4 .Os .Sh NAME .Nm gpioirq -.Nd Install an interrupt handler on a GPIO pin +.Nd Install an interrupt handler on GPIO pins .Sh SYNOPSIS .Cd "gpioirq* at gpio? offset 0 mask 0x1 flag 0x00" .Sh DESCRIPTION The .Nm -driver attaches an interrupt handler to a single GPIO pin. +driver attaches an interrupt handler to a one or more GPIO pins. .Pp -The pin number is specified in the kernel configuration fil
CVS commit: src
Module Name:src Committed By: brad Date: Mon Nov 6 00:35:06 UTC 2023 Modified Files: src/doc: CHANGES src/etc: MAKEDEV.tmpl src/share/man/man4: gpioirq.4 src/sys/conf: majors src/sys/dev/gpio: gpio.c gpioirq.c gpiovar.h Log Message: gpioirq(4) version 2 This update makes this driver more than just an example and allows for: o More than one pin to be attached to a gpioirq instance. That is, the mask parameter can be greater than 0x01 now. o A /dev/gpioirqN device that allows GPIO pin interrupts to be transported into userland. This is a device that can be opened for reading with a simple fixed output indicating the device unit, pin number and current pin state. This update was used as part of a physical intrusion detection system where multiple switches (i.e. window magnetic reed switches and etc.) are tied to a bunch of GPIO inputs with userland software that reacts to the pins changing state. To generate a diff of this commit: cvs rdiff -u -r1.3015 -r1.3016 src/doc/CHANGES cvs rdiff -u -r1.233 -r1.234 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/gpioirq.4 cvs rdiff -u -r1.102 -r1.103 src/sys/conf/majors cvs rdiff -u -r1.72 -r1.73 src/sys/dev/gpio/gpio.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/gpio/gpioirq.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/gpio/gpiovar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: brad Date: Sun Apr 16 17:16:45 UTC 2023 Modified Files: src/sys/dev/ic: bmx280.c Log Message: Do not create the sysctl tree if the initial setup of the chip fails. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/bmx280.c diff -u src/sys/dev/ic/bmx280.c:1.1 src/sys/dev/ic/bmx280.c:1.2 --- src/sys/dev/ic/bmx280.c:1.1 Sat Dec 3 01:04:43 2022 +++ src/sys/dev/ic/bmx280.c Sun Apr 16 17:16:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.1 2022/12/03 01:04:43 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.2 2023/04/16 17:16:45 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.1 2022/12/03 01:04:43 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.2 2023/04/16 17:16:45 brad Exp $"); /* * Common driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -444,11 +444,6 @@ bmx280_attach(struct bmx280_sc *sc) sc->sc_has_humidity = true; } - if ((error = bmx280_sysctl_init(sc)) != 0) { - aprint_error_dev(sc->sc_dev, "Can't setup sysctl tree (%d)\n", error); - goto out; - } - uint8_t raw_blob_tp[24]; reg = BMX280_REGISTER_DIG_T1; error = (*(sc->sc_func_read_register))(sc, reg, raw_blob_tp, 24); @@ -500,6 +495,11 @@ bmx280_attach(struct bmx280_sc *sc) goto out; } + if ((error = bmx280_sysctl_init(sc)) != 0) { + aprint_error_dev(sc->sc_dev, "Can't setup sysctl tree (%d)\n", error); + goto out; + } + for (i = 0; i < sc->sc_numsensors; i++) { if (sc->sc_has_humidity == false && bmx280_sensors[i].type == ENVSYS_SRELHUMIDITY) {
CVS commit: src/sys/dev/ic
Module Name:src Committed By: brad Date: Sun Apr 16 17:16:45 UTC 2023 Modified Files: src/sys/dev/ic: bmx280.c Log Message: Do not create the sysctl tree if the initial setup of the chip fails. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Sat Dec 3 01:04:43 UTC 2022 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/modules: mi src/share/man/man4: bmx280thp.4 spi.4 src/sys/conf: files src/sys/dev/i2c: files.i2c src/sys/dev/spi: files.spi src/sys/modules: Makefile src/sys/modules/bmx280thp: Makefile bmx280thp.ioconf Added Files: src/sys/dev/i2c: bmx280thpi2c.c src/sys/dev/ic: bmx280.c bmx280reg.h bmx280var.h src/sys/dev/spi: bmx280thpspi.c src/sys/modules/bmx280thpi2c: Makefile bmx280thpi2c.ioconf Removed Files: src/sys/dev/i2c: bmx280.c bmx280reg.h bmx280var.h Log Message: Split the BMP280 / BME280 driver into common code and create I2C and SPI attachments. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.156 -r1.157 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/bmx280thp.4 cvs rdiff -u -r1.12 -r1.13 src/share/man/man4/spi.4 cvs rdiff -u -r1.1303 -r1.1304 src/sys/conf/files cvs rdiff -u -r1.6 -r0 src/sys/dev/i2c/bmx280.c cvs rdiff -u -r1.1 -r0 src/sys/dev/i2c/bmx280reg.h cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/bmx280thpi2c.c cvs rdiff -u -r1.2 -r0 src/sys/dev/i2c/bmx280var.h cvs rdiff -u -r1.125 -r1.126 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/bmx280.c src/sys/dev/ic/bmx280reg.h \ src/sys/dev/ic/bmx280var.h cvs rdiff -u -r0 -r1.1 src/sys/dev/spi/bmx280thpspi.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/spi/files.spi cvs rdiff -u -r1.273 -r1.274 src/sys/modules/Makefile cvs rdiff -u -r1.1 -r1.2 src/sys/modules/bmx280thp/Makefile \ src/sys/modules/bmx280thp/bmx280thp.ioconf cvs rdiff -u -r0 -r1.1 src/sys/modules/bmx280thpi2c/Makefile \ src/sys/modules/bmx280thpi2c/bmx280thpi2c.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/module.mi diff -u src/distrib/sets/lists/debug/module.mi:1.22 src/distrib/sets/lists/debug/module.mi:1.23 --- src/distrib/sets/lists/debug/module.mi:1.22 Mon Nov 21 21:24:01 2022 +++ src/distrib/sets/lists/debug/module.mi Sat Dec 3 01:04:43 2022 @@ -1,4 +1,4 @@ -# $NetBSD: module.mi,v 1.22 2022/11/21 21:24:01 brad Exp $ +# $NetBSD: module.mi,v 1.23 2022/12/03 01:04:43 brad Exp $ ./usr/libdata/debug/@MODULEDIR@ modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/accf_dataready modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/accf_dataready/accf_dataready.kmod.debug modules-base-kernel kmod,debug @@ -24,6 +24,8 @@ ./usr/libdata/debug/@MODULEDIR@/blowfish/blowfish.kmod.debug modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/bmx280thpmodules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/bmx280thp/bmx280thp.kmod.debug modules-base-kernel kmod,debug +./usr/libdata/debug/@MODULEDIR@/bmx280thpi2cmodules-base-kernel kmod,debug +./usr/libdata/debug/@MODULEDIR@/bmx280thpi2c/bmx280thpi2c.kmod.debug modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/bpfmodules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/bpf/bpf.kmod.debug modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/bpf_filter modules-base-kernel kmod,debug Index: src/distrib/sets/lists/modules/mi diff -u src/distrib/sets/lists/modules/mi:1.156 src/distrib/sets/lists/modules/mi:1.157 --- src/distrib/sets/lists/modules/mi:1.156 Mon Nov 21 21:24:01 2022 +++ src/distrib/sets/lists/modules/mi Sat Dec 3 01:04:43 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.156 2022/11/21 21:24:01 brad Exp $ +# $NetBSD: mi,v 1.157 2022/12/03 01:04:43 brad Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -33,6 +33,8 @@ ./@MODULEDIR@/blowfish/blowfish.kmod modules-base-kernel kmod ./@MODULEDIR@/bmx280thpmodules-base-kernel kmod ./@MODULEDIR@/bmx280thp/bmx280thp.kmod modules-base-kernel kmod +./@MODULEDIR@/bmx280thpi2c modules-base-kernel kmod +./@MODULEDIR@/bmx280thpi2c/bmx280thpi2c.kmod modules-base-kernel kmod ./@MODULEDIR@/bpfmodules-base-kernel kmod ./@MODULEDIR@/bpf/bpf.kmod modules-base-kernel kmod ./@MODULEDIR@/bpf_filter modules-base-kernel kmod Index: src/share/man/man4/bmx280thp.4 diff -u src/share/man/man4/bmx280thp.4:1.4 src/share/man/man4/bmx280thp.4:1.5 --- src/share/man/man4/bmx280thp.4:1.4 Wed Nov 23 23:49:23 2022 +++ src/share/man/man4/bmx280thp.4 Sat Dec 3 01:04:42 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: bmx280thp.4,v 1.4 2022/11/23 23:49:23 wiz Exp $ +.\" $NetBSD: bmx280thp.4,v 1.5 2022/12/03 01:04:42 brad Exp $ .\" .\" Copyright (c) 2022 Brad Spencer .\" @@ -23,6 +23,9 @@ .Sh SYNOPSIS .Cd "bmx280thp* at iic? addr 0x76" .Cd "bmx280thp* at iic? addr 0x77" + +.Cd "bmx280thp* at spi? slave 0" +.Cd "
CVS commit: src
Module Name:src Committed By: brad Date: Sat Dec 3 01:04:43 UTC 2022 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/modules: mi src/share/man/man4: bmx280thp.4 spi.4 src/sys/conf: files src/sys/dev/i2c: files.i2c src/sys/dev/spi: files.spi src/sys/modules: Makefile src/sys/modules/bmx280thp: Makefile bmx280thp.ioconf Added Files: src/sys/dev/i2c: bmx280thpi2c.c src/sys/dev/ic: bmx280.c bmx280reg.h bmx280var.h src/sys/dev/spi: bmx280thpspi.c src/sys/modules/bmx280thpi2c: Makefile bmx280thpi2c.ioconf Removed Files: src/sys/dev/i2c: bmx280.c bmx280reg.h bmx280var.h Log Message: Split the BMP280 / BME280 driver into common code and create I2C and SPI attachments. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.156 -r1.157 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/bmx280thp.4 cvs rdiff -u -r1.12 -r1.13 src/share/man/man4/spi.4 cvs rdiff -u -r1.1303 -r1.1304 src/sys/conf/files cvs rdiff -u -r1.6 -r0 src/sys/dev/i2c/bmx280.c cvs rdiff -u -r1.1 -r0 src/sys/dev/i2c/bmx280reg.h cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/bmx280thpi2c.c cvs rdiff -u -r1.2 -r0 src/sys/dev/i2c/bmx280var.h cvs rdiff -u -r1.125 -r1.126 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/bmx280.c src/sys/dev/ic/bmx280reg.h \ src/sys/dev/ic/bmx280var.h cvs rdiff -u -r0 -r1.1 src/sys/dev/spi/bmx280thpspi.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/spi/files.spi cvs rdiff -u -r1.273 -r1.274 src/sys/modules/Makefile cvs rdiff -u -r1.1 -r1.2 src/sys/modules/bmx280thp/Makefile \ src/sys/modules/bmx280thp/bmx280thp.ioconf cvs rdiff -u -r0 -r1.1 src/sys/modules/bmx280thpi2c/Makefile \ src/sys/modules/bmx280thpi2c/bmx280thpi2c.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Dec 1 02:29:37 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Use a better choice for the print format string. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/bmx280.c diff -u src/sys/dev/i2c/bmx280.c:1.5 src/sys/dev/i2c/bmx280.c:1.6 --- src/sys/dev/i2c/bmx280.c:1.5 Thu Dec 1 00:47:51 2022 +++ src/sys/dev/i2c/bmx280.c Thu Dec 1 02:29:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.5 2022/12/01 00:47:51 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.6 2022/12/01 02:29:37 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.5 2022/12/01 00:47:51 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.6 2022/12/01 02:29:37 brad Exp $"); /* Driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -1065,10 +1065,10 @@ bmx280_refresh(struct sysmon_envsys * sm uint64_t q; q = (uint64_t)comp_hum * 100; - DPRINTF(sc, 1, ("%s: Refresh humidity Q 1: %lld\n", __func__, q)); + DPRINTF(sc, 1, ("%s: Refresh humidity Q 1: %jd\n", __func__, (uintmax_t)q)); q = q / 1024; - DPRINTF(sc, 1, ("%s: Refresh humidity Q 2: %lld\n", __func__, q)); + DPRINTF(sc, 1, ("%s: Refresh humidity Q 2: %jd\n", __func__, (uintmax_t)q)); edata->value_cur = (uint32_t) q; edata->state = ENVSYS_SVALID;
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Dec 1 02:29:37 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Use a better choice for the print format string. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Dec 1 00:47:51 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Correct the humidity conversion for the BME280 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/bmx280.c diff -u src/sys/dev/i2c/bmx280.c:1.4 src/sys/dev/i2c/bmx280.c:1.5 --- src/sys/dev/i2c/bmx280.c:1.4 Thu Nov 24 21:07:05 2022 +++ src/sys/dev/i2c/bmx280.c Thu Dec 1 00:47:51 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.4 2022/11/24 21:07:05 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.5 2022/12/01 00:47:51 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.4 2022/11/24 21:07:05 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.5 2022/12/01 00:47:51 brad Exp $"); /* Driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -277,8 +277,7 @@ bmx280_store_raw_blob_h(struct bmx280_sc sc->sc_cal_blob.dig_H2 = (int16_t)b[2] << 8; sc->sc_cal_blob.dig_H2 = sc->sc_cal_blob.dig_H2 | (int16_t)b[1]; sc->sc_cal_blob.dig_H3 = (uint8_t)b[3]; - sc->sc_cal_blob.dig_H4 = ((int16_t)b[5] & 0x000f) << 8; - sc->sc_cal_blob.dig_H4 = sc->sc_cal_blob.dig_H4 | (int16_t)b[4]; + sc->sc_cal_blob.dig_H4 = ((int16_t)((b[4] << 4) | (b[5] & 0x0F))); sc->sc_cal_blob.dig_H5 = (int16_t)b[6] << 4; sc->sc_cal_blob.dig_H5 = sc->sc_cal_blob.dig_H5 | (((int16_t)b[5] & 0x00f0) >> 4); sc->sc_cal_blob.dig_H6 = (int8_t)b[7]; @@ -566,6 +565,13 @@ bmx280_attach(device_t parent, device_t error); } + if (sc->sc_bmx280debug > 0) { + for(int _d = 0;_d < 24;_d++) { + DPRINTF(sc, 0, ("%s: %d %02x\n", + device_xname(sc->sc_dev), _d, raw_blob_tp[_d])); + } + } + bmx280_store_raw_blob_tp(sc,raw_blob_tp); if (sc->sc_has_humidity) { @@ -585,6 +591,13 @@ bmx280_attach(device_t parent, device_t error); } + if (sc->sc_bmx280debug > 0) { + for(int _d = 0;_d < 8;_d++) { +DPRINTF(sc, 0, ("%s: %d %02x\n", +device_xname(sc->sc_dev), _d, raw_blob_h[_d])); + } + } + bmx280_store_raw_blob_h(sc,raw_blob_h); } @@ -1049,15 +1062,15 @@ bmx280_refresh(struct sysmon_envsys * sm DPRINTF(sc, 2, ("%s: Refresh compensated humidity: %d\n", device_xname(sc->sc_dev), comp_hum)); - uint32_t q; + uint64_t q; - q = comp_hum; + q = (uint64_t)comp_hum * 100; + DPRINTF(sc, 1, ("%s: Refresh humidity Q 1: %lld\n", __func__, q)); q = q / 1024; - q = q * 100; /* XXX - this probably is not correct */ - DPRINTF(sc, 1, ("%s: Refresh humidity Q: %d\n", __func__, q)); + DPRINTF(sc, 1, ("%s: Refresh humidity Q 2: %lld\n", __func__, q)); - edata->value_cur = q; + edata->value_cur = (uint32_t) q; edata->state = ENVSYS_SVALID; } }
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Dec 1 00:47:51 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Correct the humidity conversion for the BME280 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Nov 24 21:07:05 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Mention where in the datasheet the compensation algorithms came from. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/bmx280.c diff -u src/sys/dev/i2c/bmx280.c:1.3 src/sys/dev/i2c/bmx280.c:1.4 --- src/sys/dev/i2c/bmx280.c:1.3 Wed Nov 23 23:45:29 2022 +++ src/sys/dev/i2c/bmx280.c Thu Nov 24 21:07:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.3 2022/11/23 23:45:29 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.4 2022/11/24 21:07:05 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.3 2022/11/23 23:45:29 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.4 2022/11/24 21:07:05 brad Exp $"); /* Driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -643,8 +643,13 @@ out: sc->sc_sme = NULL; } -/* The conversion algorithms are taken from the Bosch datasheet for - * the BMX280 and adapted to the envsys infrastructure. +/* The conversion algorithms are taken from the BMP280 datasheet. The + * same algorithms are used with the BME280. + * + * https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf + * + * Section 3.11.3, page 21 + * */ static int32_t
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Thu Nov 24 21:07:05 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Mention where in the datasheet the compensation algorithms came from. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/i2c
Taylor R Campbell writes: [snip] > The issue here isn't the duration of the delay -- just the mechanism. > Sleeping for 35ms with kpause(9) is fine, but busy-waiting on the CPU > for 35ms with delay(9) is not (unless HZ is set to something absurdly > low like 10 instead of the usual 100, but I doubt that's an important > use-case to consider here). > > In this case, you should use: > > kpause("bmx280", /*intr*/false, MAX(1, mstohz(35)), NULL); All understood.. the above, however, was not quite right either. That delay is related to the over sampling that is set and wasn't a fixed value. I made adjustments to scale the amount of time actually needed to wait with the over sampling setting. This is the proper thing that needed to be done in this case. I do agree that kpause is a better thing to use here too.. no doubt.. There wasn't any real documentation about this, but it clearly was something that needed to be considered. The only reference was a single table that listed some of the typical and max durations for just *SOME* of the over sampling setting (worse, yet, this table was removed from later versions of the docs). It left out a lot and did not include any sort of formula. Though some experimentation I can up with one that should be workable and allowed for some tuning if it wasn't quite right. >> was, as one might say, a "surprising development" as the documentation >> really does not hint that this sort of thing goes on (or was even >> possible to do). > > Can you put a link to the documentation in the source code, and cite > the sections where you get the complicated formulas like in > bmx280_compensate_P_int64? Ya, I can do that. The three compensation formulas are pulled mostly literally from the docs. All I really did was changed the types to match the kernel names and unglobal'ed some of the variables for the factory calibration settings. Peeking at Adafruit's Ardunio code, they did the same thing. -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
CVS commit: src
Module Name:src Committed By: brad Date: Wed Nov 23 23:45:30 UTC 2022 Modified Files: src/share/man/man4: bmx280thp.4 src/sys/dev/i2c: bmx280.c bmx280var.h Log Message: Use kpause() instead of delay() in the measurement cycle. Try and derive the proper wait delay for the measurement based upon the over sampling setting and allow the wait factor multiplier to be adjusted. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/bmx280thp.4 cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/bmx280.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/bmx280var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/bmx280thp.4 diff -u src/share/man/man4/bmx280thp.4:1.2 src/share/man/man4/bmx280thp.4:1.3 --- src/share/man/man4/bmx280thp.4:1.2 Mon Nov 21 23:51:10 2022 +++ src/share/man/man4/bmx280thp.4 Wed Nov 23 23:45:30 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: bmx280thp.4,v 1.2 2022/11/21 23:51:10 wiz Exp $ +.\" $NetBSD: bmx280thp.4,v 1.3 2022/11/23 23:45:30 brad Exp $ .\" .\" Copyright (c) 2022 Brad Spencer .\" @@ -55,6 +55,15 @@ IRR is a filter that can be used to redu measurement. The value values are 1 (or off), 2, 5, 11 and 22 samples to reach >= 75% of the step response. +.It Li hw.bmx280thp0.waitfactor.t +.It Li hw.bmx280thp0.waitfactor.p +.It Li hw.bmx280thp0.waitfactor.h +These control the wait multiplication factor for a measurement cycle. +This factor is different for temperature, pressure and humidity and +is based upon the values of osrs_t, osrs_p and osrs_h. If the chip +does not return the correct measurements for a given over sampling +then the wait factors can be adjusted to allow more time for the +measurement to complete successfully. .It Li hw.bmx280thp0.debug .It Li hw.bmx280thp0.dump_calibration If the driver is compiled with Index: src/sys/dev/i2c/bmx280.c diff -u src/sys/dev/i2c/bmx280.c:1.2 src/sys/dev/i2c/bmx280.c:1.3 --- src/sys/dev/i2c/bmx280.c:1.2 Tue Nov 22 19:40:31 2022 +++ src/sys/dev/i2c/bmx280.c Wed Nov 23 23:45:29 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.2 2022/11/22 19:40:31 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.3 2022/11/23 23:45:29 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.2 2022/11/22 19:40:31 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.3 2022/11/23 23:45:29 brad Exp $"); /* Driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -31,6 +31,7 @@ __KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1 #include #include #include +#include #include #include @@ -349,7 +350,7 @@ bmx280_sysctl_init(struct bmx280_sc *sc) { int error; const struct sysctlnode *cnode; - int sysctlroot_num; + int sysctlroot_num, sysctlwait_num; if ((error = sysctl_createv(>sc_bmx280log, 0, NULL, , 0, CTLTYPE_NODE, device_xname(sc->sc_dev), @@ -414,6 +415,36 @@ bmx280_sysctl_init(struct bmx280_sc *sc) 0, CTL_HW, sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) return error; + if ((error = sysctl_createv(>sc_bmx280log, 0, NULL, , + 0, CTLTYPE_NODE, "waitfactor", + SYSCTL_DESCR("bmx280 wait factors"), NULL, 0, NULL, 0, CTL_HW, + sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + sysctlwait_num = cnode->sysctl_num; + + if ((error = sysctl_createv(>sc_bmx280log, 0, NULL, , + CTLFLAG_READWRITE, CTLTYPE_INT, "t", + SYSCTL_DESCR("Temperature wait multiplier"), + bmx280_verify_sysctl, 0, >sc_waitfactor_t, + 0, CTL_HW, sysctlroot_num, sysctlwait_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + + if ((error = sysctl_createv(>sc_bmx280log, 0, NULL, , + CTLFLAG_READWRITE, CTLTYPE_INT, "p", + SYSCTL_DESCR("Pressure wait multiplier"), + bmx280_verify_sysctl, 0, >sc_waitfactor_p, + 0, CTL_HW, sysctlroot_num, sysctlwait_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + + if (sc->sc_has_humidity) { + if ((error = sysctl_createv(>sc_bmx280log, 0, NULL, , + CTLFLAG_READWRITE, CTLTYPE_INT, "h", + SYSCTL_DESCR("Humidity wait multiplier"), + bmx280_verify_sysctl, 0, >sc_waitfactor_h, + 0, CTL_HW, sysctlroot_num, sysctlwait_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + } + return 0; } @@ -472,6 +503,9 @@ bmx280_attach(device_t parent, device_t sc->sc_osrs_h = 1; sc->sc_irr_samples = 1; sc->sc_previous_irr = 0xff; + sc->sc_waitfactor_t = 6; + sc->sc_waitfactor_p = 2; + sc->sc_waitfactor_h = 2; sc->sc_sme = NULL; aprint_normal("\n"); @@ -718,11 +752,24 @@ bmx280_set_control_and_trigger(struct bm error = EINVAL; } - /* Hmm... this delay is not documented well.. mostly just a guess... - * If it is too short, you
CVS commit: src
Module Name:src Committed By: brad Date: Wed Nov 23 23:45:30 UTC 2022 Modified Files: src/share/man/man4: bmx280thp.4 src/sys/dev/i2c: bmx280.c bmx280var.h Log Message: Use kpause() instead of delay() in the measurement cycle. Try and derive the proper wait delay for the measurement based upon the over sampling setting and allow the wait factor multiplier to be adjusted. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/bmx280thp.4 cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/bmx280.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/bmx280var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/i2c
Simon Burge writes: > Hi Brad, > >> Module Name: src >> Committed By:brad >> Date:Tue Nov 22 19:40:31 UTC 2022 >> >> Modified Files: >> >> src/sys/dev/i2c: bmx280.c >> >> Log Message: >> >> Read the datasheet more closely and put in some delays. The chip will >> just return junk if the wait is not long enough to allow a measurement >> to start. > > > + /* Hmm... this delay is not documented well.. mostly just a guess... > +* If it is too short, you will get junk returned as it is possible > to try > +* to ask for the data before the chip has even started... it seems... > +*/ > + delay(35000); > > This will spin for 35 milliseconds (per sensor read if I read this > correctly). Can you please look at using kpause(9) for this delay? > See some other i2c drivers for examples of this. > > Cheers, > Simon. Probably possible, may be a couple of days before I can get to it (or not, depends on how holiday prep goes)... I have used some of the cv_timedwait stuff in the past and didn't know about kpause which seems to be suited to what I need to do. Almost all sensor chips require some sort of wait after a command is sent, but this one was particularly frustrating about it. To give out too much information, all of the other sensors I have worked with NACK the I2C bus during the measurement cycle. This one, and probably all of Bosch's chips, do not do that. You have to read back a status register and check to see if it is busy doing something or other. If you just go ahead and read the data registers when it is busy you get junk with no hint that it is junk. But a big "however" is that it is possible (even for a RPI) to read the status register BEFORE the chip has even started to do its measurements, get a positive response (i.e. not busy) and then read the data registers and get junk. This was, as one might say, a "surprising development" as the documentation really does not hint that this sort of thing goes on (or was even possible to do). -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Tue Nov 22 19:40:31 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Read the datasheet more closely and put in some delays. The chip will just return junk if the wait is not long enough to allow a measurement to start. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/bmx280.c diff -u src/sys/dev/i2c/bmx280.c:1.1 src/sys/dev/i2c/bmx280.c:1.2 --- src/sys/dev/i2c/bmx280.c:1.1 Mon Nov 21 21:24:01 2022 +++ src/sys/dev/i2c/bmx280.c Tue Nov 22 19:40:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bmx280.c,v 1.1 2022/11/21 21:24:01 brad Exp $ */ +/* $NetBSD: bmx280.c,v 1.2 2022/11/22 19:40:31 brad Exp $ */ /* * Copyright (c) 2022 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.1 2022/11/21 21:24:01 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.2 2022/11/22 19:40:31 brad Exp $"); /* Driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and @@ -501,7 +501,7 @@ bmx280_attach(device_t parent, device_t error); } - delay(100); + delay(3); reg = BMX280_REGISTER_ID; error = bmx280_read_register(sc->sc_tag, sc->sc_addr, , _id, 1); @@ -510,7 +510,7 @@ bmx280_attach(device_t parent, device_t error); } - delay(100); + delay(1000); DPRINTF(sc, 2, ("%s: read ID value: %02x\n", device_xname(sc->sc_dev), chip_id)); @@ -718,6 +718,12 @@ bmx280_set_control_and_trigger(struct bm error = EINVAL; } + /* Hmm... this delay is not documented well.. mostly just a guess... + * If it is too short, you will get junk returned as it is possible to try + * to ask for the data before the chip has even started... it seems... + */ + delay(35000); + return error; } @@ -731,7 +737,7 @@ bmx280_wait_for_data(struct bmx280_sc *s reg = BMX280_REGISTER_STATUS; do { - delay(10); + delay(1000); ierror = bmx280_read_register(sc->sc_tag, sc->sc_addr, , , 1); if (ierror) { DPRINTF(sc, 2, ("%s: Refresh failed to read back status: %d\n",
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Tue Nov 22 19:40:31 UTC 2022 Modified Files: src/sys/dev/i2c: bmx280.c Log Message: Read the datasheet more closely and put in some delays. The chip will just return junk if the wait is not long enough to allow a measurement to start. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/bmx280.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Mon Nov 21 21:29:33 UTC 2022 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 Log Message: Mention the driver for the Bosch BMP280/BME280 To generate a diff of this commit: cvs rdiff -u -r1.2931 -r1.2932 src/doc/CHANGES cvs rdiff -u -r1.34 -r1.35 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2931 src/doc/CHANGES:1.2932 --- src/doc/CHANGES:1.2931 Thu Nov 17 20:43:39 2022 +++ src/doc/CHANGES Mon Nov 21 21:29:32 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2931 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2932 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -735,3 +735,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: as documented and in POSIX. [riastradh 20221105] aht20temp(4): Driver for the Aosong AHT20 temperature and humidity sensor [brad 20221117] + bmx280thp(4): Driver for the Bosch BMP280/BME280 temperature, + humidity and pressure sensor [brad 20221121] Index: src/share/man/man4/iic.4 diff -u src/share/man/man4/iic.4:1.34 src/share/man/man4/iic.4:1.35 --- src/share/man/man4/iic.4:1.34 Thu Nov 17 20:43:39 2022 +++ src/share/man/man4/iic.4 Mon Nov 21 21:29:32 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: iic.4,v 1.34 2022/11/17 20:43:39 brad Exp $ +.\" $NetBSD: iic.4,v 1.35 2022/11/21 21:29:32 brad Exp $ .\" $OpenBSD: iic.4,v 1.74 2008/09/10 16:13:43 reyk Exp $ .\" .\" Copyright (c) 2004, 2006 Alexander Yurchenko @@ -183,6 +183,8 @@ Analog Devices ADM1021 temperature senso Aosong AHT20 humidity/temperature sensors .It Xr am2315temp 4 Aosong AM2315 humidity/temperature sensors +.It Xr bmx280thp 4 +Bosch BMP280/BME280 humidity/temperature/pressure sensors .It Xr ddc 4 VESA Display Data Channel V2 devices .It Xr dbcool 4
CVS commit: src
Module Name:src Committed By: brad Date: Mon Nov 21 21:29:33 UTC 2022 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 Log Message: Mention the driver for the Bosch BMP280/BME280 To generate a diff of this commit: cvs rdiff -u -r1.2931 -r1.2932 src/doc/CHANGES cvs rdiff -u -r1.34 -r1.35 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
IDITY, /* relative humidity */ ENVSYS_LUX, /* illuminance in lux */ + ENVSYS_PRESSURE, /* pressure in hPa */ ENVSYS_NSENSORS }; Index: src/usr.sbin/envstat/envstat.8 diff -u src/usr.sbin/envstat/envstat.8:1.66 src/usr.sbin/envstat/envstat.8:1.67 --- src/usr.sbin/envstat/envstat.8:1.66 Sat Nov 14 20:07:13 2020 +++ src/usr.sbin/envstat/envstat.8 Mon Nov 21 21:24:02 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: envstat.8,v 1.66 2020/11/14 20:07:13 wiz Exp $ +.\" $NetBSD: envstat.8,v 1.67 2022/11/21 21:24:02 brad Exp $ .\" .\" Copyright (c) 2000, 2007, 2008, 2009, 2014 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -190,6 +190,8 @@ Watts Watt-hours .It %rH relative Humidity +.It hPa +Hectopascals .El .Sh EXAMPLES To display the Index: src/usr.sbin/envstat/envstat.c diff -u src/usr.sbin/envstat/envstat.c:1.102 src/usr.sbin/envstat/envstat.c:1.103 --- src/usr.sbin/envstat/envstat.c:1.102 Sat May 28 10:36:24 2022 +++ src/usr.sbin/envstat/envstat.c Mon Nov 21 21:24:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: envstat.c,v 1.102 2022/05/28 10:36:24 andvar Exp $ */ +/* $NetBSD: envstat.c,v 1.103 2022/11/21 21:24:02 brad Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -27,7 +27,7 @@ #include #ifndef lint -__RCSID("$NetBSD: envstat.c,v 1.102 2022/05/28 10:36:24 andvar Exp $"); +__RCSID("$NetBSD: envstat.c,v 1.103 2022/11/21 21:24:02 brad Exp $"); #endif /* not lint */ #include @@ -1174,6 +1174,53 @@ do { \ if (!nflag) (void)printf(" %*s", (int)ilen - 3, stype); + /* Pressure */ + } else if (strcmp(sensor->type, "pressure") == 0) { + stype = "hPa"; + + (void)printf("%s%*.3f", sep, flen, + sensor->cur_value / 1.0); + + ilen = 8; + if (statistics) { +/* show statistics if flag set */ +(void)printf(" %.3f %.3f %.3f", +stats->max / 1.0, stats->min / 1.0, stats->avg / 1.0); +ilen += 2; + } else if (!nflag) { +if (sensor->critmax_value) { + (void)printf(" %*u", (int)ilen, + sensor->critmax_value); + ilen = 8; +} else + ilen += 9; + +if (sensor->warnmax_value) { + (void)printf(" %*u", (int)ilen, + sensor->warnmax_value); + ilen = 8; +} else + ilen += 9; + +if (sensor->warnmin_value) { + (void)printf(" %*u", (int)ilen, + sensor->warnmin_value); + ilen = 8; +} else + ilen += 9; + +if (sensor->critmin_value) { + (void)printf( " %*u", (int)ilen, + sensor->critmin_value); + ilen = 8; +} else + ilen += 9; + + } + + if (!nflag) +(void)printf(" %*s", (int)ilen - 3, stype); + /* everything else */ } else { if (strcmp(sensor->type, "Voltage DC") == 0) Added files: Index: src/share/man/man4/bmx280thp.4 diff -u /dev/null src/share/man/man4/bmx280thp.4:1.1 --- /dev/null Mon Nov 21 21:24:02 2022 +++ src/share/man/man4/bmx280thp.4 Mon Nov 21 21:24:00 2022 @@ -0,0 +1,89 @@ +.\" $NetBSD: bmx280thp.4,v 1.1 2022/11/21 21:24:00 brad Exp $ +.\" +.\" Copyright (c) 2022 Brad Spencer +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd November 19, 2022 +.Dt BMX280THP 4 +.Os +.Sh NAME +.Nm bmx280thp +.Nd Driver for Bosch BMP280/BME280 sensor chip via I2C bus +.Sh SYNOPSIS +.Cd "bmx280thp* at iic? addr 0x76" +.Cd "bmx280thp* at iic? addr 0x77" +.Sh DESCRIPTION +The +.Nm +driver provides measurements from the BMP280 and BME280 temperature, +humidity and barometric pressure sensors via the +.Xr envsys 4 +framework. +The +.Nm +.Ar addr +argument selects the address at the +.Xr iic 4 +bus. +The percision of the measurement can be changed through +.Xr sysctl 8 +nodes. +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 3 +variables are provided: +.Bl -tag -width indent +.It Li hw.bmx280thp0.osrs_t +.It Li hw.bmx280thp0.osrs_p +.It Li hw.bmx280thp0.osrs_h +These control oversampling of temperature, pressure and humidity. The +valid values are 1, 2, 4, 8, and 16 times oversample. Humidity is only +available
CVS commit: src
Module Name:src Committed By: brad Date: Mon Nov 21 21:24:02 UTC 2022 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/share/man/man4: Makefile src/sys/dev/i2c: files.i2c src/sys/dev/sysmon: sysmon_envsys_tables.c src/sys/modules: Makefile src/sys/sys: envsys.h src/usr.sbin/envstat: envstat.8 envstat.c Added Files: src/share/man/man4: bmx280thp.4 src/sys/dev/i2c: bmx280.c bmx280reg.h bmx280var.h src/sys/modules/bmx280thp: Makefile bmx280thp.ioconf Log Message: A driver for the Bosch BMP280 / BME280 temperature, humidity and atmospheric pressure sensor. This is an inexpensive to moderately expensive chip available from a large number of places. The driver supports all aspects of the two chips, except for the repeating read mode which would allow for sub-second queries, such as fall detection or perhaps even as an altimeter. This driver also only supports the I2C interface and not the SPI interface. The BME280, the one with humidity, is not fully tested at this point, awaiting upon a breakout board and may not show proper humidity. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.1755 -r1.1756 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.155 -r1.156 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.729 -r1.730 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/bmx280thp.4 cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/bmx280.c src/sys/dev/i2c/bmx280reg.h \ src/sys/dev/i2c/bmx280var.h cvs rdiff -u -r1.124 -r1.125 src/sys/dev/i2c/files.i2c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/sysmon/sysmon_envsys_tables.c cvs rdiff -u -r1.272 -r1.273 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/bmx280thp/Makefile \ src/sys/modules/bmx280thp/bmx280thp.ioconf cvs rdiff -u -r1.38 -r1.39 src/sys/sys/envsys.h cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/envstat/envstat.8 cvs rdiff -u -r1.102 -r1.103 src/usr.sbin/envstat/envstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Thu Nov 17 20:43:39 UTC 2022 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 Log Message: Mention the AHT20 driver To generate a diff of this commit: cvs rdiff -u -r1.2930 -r1.2931 src/doc/CHANGES cvs rdiff -u -r1.33 -r1.34 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2930 src/doc/CHANGES:1.2931 --- src/doc/CHANGES:1.2930 Sun Nov 13 21:22:13 2022 +++ src/doc/CHANGES Thu Nov 17 20:43:39 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2930 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2931 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -733,3 +733,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: tzdata: updated to 2022f (using the 2022fgtz fork) [kre 20221030] regerror(3): Allow null errbuf if errbuf_size is zero, as documented and in POSIX. [riastradh 20221105] + aht20temp(4): Driver for the Aosong AHT20 temperature and + humidity sensor [brad 20221117] Index: src/share/man/man4/iic.4 diff -u src/share/man/man4/iic.4:1.33 src/share/man/man4/iic.4:1.34 --- src/share/man/man4/iic.4:1.33 Tue Dec 7 17:50:27 2021 +++ src/share/man/man4/iic.4 Thu Nov 17 20:43:39 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: iic.4,v 1.33 2021/12/07 17:50:27 brad Exp $ +.\" $NetBSD: iic.4,v 1.34 2022/11/17 20:43:39 brad Exp $ .\" $OpenBSD: iic.4,v 1.74 2008/09/10 16:13:43 reyk Exp $ .\" .\" Copyright (c) 2004, 2006 Alexander Yurchenko @@ -179,6 +179,8 @@ A wide list of slaves are supported, amo Analog Devices ADM1026 complete thermal system management controller .It Xr admtemp 4 Analog Devices ADM1021 temperature sensor +.It Xr aht20temp 4 +Aosong AHT20 humidity/temperature sensors .It Xr am2315temp 4 Aosong AM2315 humidity/temperature sensors .It Xr ddc 4
CVS commit: src
Module Name:src Committed By: brad Date: Thu Nov 17 20:43:39 UTC 2022 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 Log Message: Mention the AHT20 driver To generate a diff of this commit: cvs rdiff -u -r1.2930 -r1.2931 src/doc/CHANGES cvs rdiff -u -r1.33 -r1.34 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
solete" instead. # @@ -13,6 +13,8 @@ ./@MODULEDIR@/adosfs/adosfs.kmod modules-base-kernel kmod ./@MODULEDIR@/adiantummodules-base-kernel kmod ./@MODULEDIR@/adiantum/adiantum.kmod modules-base-kernel kmod +./@MODULEDIR@/aht20tempmodules-base-kernel kmod +./@MODULEDIR@/aht20temp/aht20temp.kmod modules-base-kernel kmod ./@MODULEDIR@/aiomodules-base-kernel kmod ./@MODULEDIR@/aio/aio.kmod modules-base-kernel kmod ./@MODULEDIR@/am2315temp modules-base-kernel kmod Index: src/share/man/man4/Makefile diff -u src/share/man/man4/Makefile:1.728 src/share/man/man4/Makefile:1.729 --- src/share/man/man4/Makefile:1.728 Fri Aug 12 11:15:41 2022 +++ src/share/man/man4/Makefile Thu Nov 17 19:20:05 2022 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.728 2022/08/12 11:15:41 riastradh Exp $ +# $NetBSD: Makefile,v 1.729 2022/11/17 19:20:05 brad Exp $ # @(#)Makefile 8.1 (Berkeley) 6/18/93 MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \ adbbt.4 adbkbd.4 adbms.4 \ adc.4 adm1026hm.4 admtemp.4 adv.4 adw.4 age.4 agp.4 agr.4 ahb.4 ahc.4 \ - ahcisata.4 ahd.4 aibs.4 alc.4 ale.4 alipm.4 altmem.4 altq.4 \ + ahcisata.4 ahd.4 aht20temp.4 aibs.4 alc.4 ale.4 alipm.4 altmem.4 altq.4 \ am2315temp.4 amdpm.4 amdtemp.4 amhphy.4 amr.4 aps.4 asus.4 \ an.4 aq.4 arcmsr.4 arcofi.4 aria.4 artsata.4 ata.4 atalk.4 ataraid.4 \ ath.4 athn.4 atphy.4 atppc.4 attimer.4 atw.4 \ Index: src/sys/dev/i2c/files.i2c diff -u src/sys/dev/i2c/files.i2c:1.123 src/sys/dev/i2c/files.i2c:1.124 --- src/sys/dev/i2c/files.i2c:1.123 Wed Jul 20 10:01:11 2022 +++ src/sys/dev/i2c/files.i2c Thu Nov 17 19:20:06 2022 @@ -1,4 +1,4 @@ -# $NetBSD: files.i2c,v 1.123 2022/07/20 10:01:11 riastradh Exp $ +# $NetBSD: files.i2c,v 1.124 2022/11/17 19:20:06 brad Exp $ obsolete defflag opt_i2cbus.h I2C_SCAN define i2cbus { } @@ -430,3 +430,8 @@ file dev/i2c/pcf8574.c pcf8574io # Sparkfun Serial motor controller attach scmd at iic with scmdi2c file dev/i2c/scmdi2c.c scmdi2c + +# Aosong AHT20 Temperature and Humidity sensor +device aht20temp +attach aht20temp at iic +file dev/i2c/aht20.caht20temp Index: src/sys/modules/Makefile diff -u src/sys/modules/Makefile:1.271 src/sys/modules/Makefile:1.272 --- src/sys/modules/Makefile:1.271 Wed Sep 7 11:26:23 2022 +++ src/sys/modules/Makefile Thu Nov 17 19:20:05 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.271 2022/09/07 11:26:23 martin Exp $ +# $NetBSD: Makefile,v 1.272 2022/11/17 19:20:05 brad Exp $ .include @@ -25,6 +25,7 @@ SUBDIR+= accf_dataready SUBDIR+= accf_httpready SUBDIR+= adosfs SUBDIR+= adiantum +SUBDIR+= aht20temp SUBDIR+= aio SUBDIR+= audio SUBDIR+= autofs Added files: Index: src/share/man/man4/aht20temp.4 diff -u /dev/null src/share/man/man4/aht20temp.4:1.1 --- /dev/null Thu Nov 17 19:20:06 2022 +++ src/share/man/man4/aht20temp.4 Thu Nov 17 19:20:05 2022 @@ -0,0 +1,76 @@ +.\" $NetBSD: aht20temp.4,v 1.1 2022/11/17 19:20:05 brad Exp $ +.\" +.\" Copyright (c) 2022 Brad Spencer +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd November 15, 2022 +.Dt AHT20TEMP 4 +.Os +.Sh NAME +.Nm aht20temp +.Nd Driver for Guangzhou Aosong AHT20 sensor chip via I2C bus +.Sh SYNOPSIS +.Cd "aht20temp* at iic? addr 0x38" +.Sh DESCRIPTION +The +.Nm +driver provides measurements from the AHT20 humidity/temperature +sensors via the +.Xr envsys 4 +framework. +The +.Nm +.Ar addr +argument selects the address at the +.Xr iic 4 +bus. +The crc validity can be changed through +.Xr sysctl 8 +nodes. +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 3 +variables are provided: +.Bl -tag -width indent +.It Li hw.aht20temp0.ignorecrc +If set, the crc calculation for %RH and temperature will be ignored. +.It Li hw.aht20temp0.debug +If the driver is compiled with +.Dv AHT20_DEBUG , +this node will appear and can be used to set the debugging level. +.It Li hw.aht20temp0.readattempts +To read %RH or temperature the chip requires that the command be sent, +then a delay must be observed before a read can be done to get the values +back. +The delays are documented in the datasheet for the chip. +The driver will attempt to read back the values readattempts number of +times. +The default is 10 which should be more th
CVS commit: src
Module Name:src Committed By: brad Date: Thu Nov 17 19:20:06 UTC 2022 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/share/man/man4: Makefile src/sys/dev/i2c: files.i2c src/sys/modules: Makefile Added Files: src/share/man/man4: aht20temp.4 src/sys/dev/i2c: aht20.c aht20reg.h aht20var.h src/sys/modules/aht20temp: Makefile aht20temp.ioconf Log Message: A driver for the Aosong AHT20 temperature and humidity sensor. While slow for an I2C sensor it is inexpensive and should work well enough in most indoor conditions. All features of the chip are supported. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.1754 -r1.1755 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.154 -r1.155 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.728 -r1.729 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/aht20temp.4 cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/aht20.c src/sys/dev/i2c/aht20reg.h \ src/sys/dev/i2c/aht20var.h cvs rdiff -u -r1.123 -r1.124 src/sys/dev/i2c/files.i2c cvs rdiff -u -r1.271 -r1.272 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/aht20temp/Makefile \ src/sys/modules/aht20temp/aht20temp.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man4
Module Name:src Committed By: brad Date: Wed Jun 15 15:54:40 UTC 2022 Modified Files: src/share/man/man4: ssdfb.4 Log Message: Fix typo .. the Adafruit 931 module is mask 0x03 and the 938 module is mask 0x04. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/ssdfb.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/ssdfb.4 diff -u src/share/man/man4/ssdfb.4:1.7 src/share/man/man4/ssdfb.4:1.8 --- src/share/man/man4/ssdfb.4:1.7 Thu Aug 5 19:23:44 2021 +++ src/share/man/man4/ssdfb.4 Wed Jun 15 15:54:40 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: ssdfb.4,v 1.7 2021/08/05 19:23:44 tnn Exp $ +.\" $NetBSD: ssdfb.4,v 1.8 2022/06/15 15:54:40 brad Exp $ .\" .\" Copyright (c) 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -68,10 +68,10 @@ Generic SSD1306 modules using default se Generic SH1106 modules using default settings .It .Em 0x03 : -Adafruit Industries, LLC product 938 (128x64) +Adafruit Industries, LLC product 931 (128x32) .It .Em 0x04 : -Adafruit Industries, LLC product 931 (128x32) +Adafruit Industries, LLC product 938 (128x64) .It .Em 0x05 : Generic SSD1322 modules using default settings
CVS commit: src/share/man/man4
Module Name:src Committed By: brad Date: Wed Jun 15 15:54:40 UTC 2022 Modified Files: src/share/man/man4: ssdfb.4 Log Message: Fix typo .. the Adafruit 931 module is mask 0x03 and the 938 module is mask 0x04. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/ssdfb.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Fri May 13 16:39:33 UTC 2022 Modified Files: src/distrib/sets/lists/base: mi src/distrib/sets/lists/man: mi src/external/mpl/bind/bin/confgen/ddns-confgen: Makefile Log Message: Add LINKS and MLINKS to the ddns-confgen Makefile to provide tsig-keygen. This helps to allow pkgsrc/security/acmesh to function and should be provided in all BIND >= 9.13 installs anyway. To generate a diff of this commit: cvs rdiff -u -r1.1294 -r1.1295 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.1738 -r1.1739 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.1 -r1.2 \ src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Fri May 13 16:39:33 UTC 2022 Modified Files: src/distrib/sets/lists/base: mi src/distrib/sets/lists/man: mi src/external/mpl/bind/bin/confgen/ddns-confgen: Makefile Log Message: Add LINKS and MLINKS to the ddns-confgen Makefile to provide tsig-keygen. This helps to allow pkgsrc/security/acmesh to function and should be provided in all BIND >= 9.13 installs anyway. To generate a diff of this commit: cvs rdiff -u -r1.1294 -r1.1295 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.1738 -r1.1739 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.1 -r1.2 \ src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.1294 src/distrib/sets/lists/base/mi:1.1295 --- src/distrib/sets/lists/base/mi:1.1294 Mon Apr 25 02:29:13 2022 +++ src/distrib/sets/lists/base/mi Fri May 13 16:39:32 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1294 2022/04/25 02:29:13 gutteridge Exp $ +# $NetBSD: mi,v 1.1295 2022/05/13 16:39:32 brad Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -1955,6 +1955,7 @@ ./usr/sbin/traceroute6base-netutil-bin use_inet6 ./usr/sbin/trpt base-netutil-bin ./usr/sbin/trsp base-obsolete obsolete +./usr/sbin/tsig-keygenbase-bind-bin ./usr/sbin/unboundbase-netutil-bin unbound ./usr/sbin/unbound-anchor base-netutil-bin unbound ./usr/sbin/unbound-checkconf base-netutil-bin unbound Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1738 src/distrib/sets/lists/man/mi:1.1739 --- src/distrib/sets/lists/man/mi:1.1738 Wed Apr 6 14:20:07 2022 +++ src/distrib/sets/lists/man/mi Fri May 13 16:39:33 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1738 2022/04/06 14:20:07 reinoud Exp $ +# $NetBSD: mi,v 1.1739 2022/05/13 16:39:33 brad Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -3255,6 +3255,7 @@ ./usr/share/man/cat8/trivial-rewrite.0 man-postfix-catman postfix,.cat ./usr/share/man/cat8/trpt.0 man-netutil-catman .cat ./usr/share/man/cat8/trsp.0 man-obsolete obsolete +./usr/share/man/cat8/tsig-keygen.0 man-bind-catman .cat ./usr/share/man/cat8/ttyflags.0 man-sysutil-catman .cat ./usr/share/man/cat8/tunefs.0 man-sysutil-catman .cat ./usr/share/man/cat8/umbctl.0 man-netutil-catman .cat @@ -6222,6 +6223,7 @@ ./usr/share/man/html8/traceroute6.html man-netutil-htmlman use_inet6,html ./usr/share/man/html8/trivial-rewrite.html man-postfix-htmlman postfix,html ./usr/share/man/html8/trpt.html man-netutil-htmlman html +./usr/share/man/html8/tsig-keygen.html man-bind-htmlman html ./usr/share/man/html8/ttyflags.html man-sysutil-htmlman html ./usr/share/man/html8/tunefs.html man-sysutil-htmlman html ./usr/share/man/html8/umbctl.html man-netutil-htmlman html @@ -9536,6 +9538,7 @@ ./usr/share/man/man8/trivial-rewrite.8 man-postfix-man postfix,.man ./usr/share/man/man8/trpt.8 man-netutil-man .man ./usr/share/man/man8/trsp.8 man-obsolete obsolete +./usr/share/man/man8/tsig-keygen.8 man-bind-man .man ./usr/share/man/man8/ttyflags.8 man-sysutil-man .man ./usr/share/man/man8/tunefs.8 man-sysutil-man .man ./usr/share/man/man8/umbctl.8 man-netutil-man .man Index: src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile diff -u src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.1 src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.2 --- src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.1 Sun Aug 12 13:02:24 2018 +++ src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile Fri May 13 16:39:32 2022 @@ -1,5 +1,8 @@ -# $NetBSD: Makefile,v 1.1 2018/08/12 13:02:24 christos Exp $ +# $NetBSD: Makefile,v 1.2 2022/05/13 16:39:32 brad Exp $ .include "${.PARSEDIR}/../Makefile.inc" +LINKS= ${BINDIR}/ddns-confgen ${BINDIR}/tsig-keygen +MLINKS= ddns-confgen.8 tsig-keygen.8 + .include
CVS commit: src/doc
Module Name:src Committed By: brad Date: Sat Apr 30 15:45:41 UTC 2022 Modified Files: src/doc: CHANGES Log Message: Mention the changes for /etc/rc.d/gpio To generate a diff of this commit: cvs rdiff -u -r1.2870 -r1.2871 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2870 src/doc/CHANGES:1.2871 --- src/doc/CHANGES:1.2870 Fri Apr 15 14:02:08 2022 +++ src/doc/CHANGES Sat Apr 30 15:45:41 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2870 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2871 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -488,3 +488,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: dhcp: Import version 4.4.3. [christos 20220402] udf: Added fsck_udf(8) and upgraded newfs_udf/makefs for UDF. [reinoud 20220506] OpenSSH: Import 9.0. [christos 20220415] + gpio: Allow /etc/rc.d/gpio to use a '!' character like /etc/rc.d/network + can to run a shell script. [brad 20220430]
CVS commit: src/doc
Module Name:src Committed By: brad Date: Sat Apr 30 15:45:41 UTC 2022 Modified Files: src/doc: CHANGES Log Message: Mention the changes for /etc/rc.d/gpio To generate a diff of this commit: cvs rdiff -u -r1.2870 -r1.2871 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Sat Apr 30 13:48:09 UTC 2022 Modified Files: src/etc/rc.d: gpio src/share/man/man5: gpio.conf.5 Log Message: Like /etc/rc.d/network, add the ability to put a '!' character as the first character in /etc/gpio.conf and have the rest evaluated in a shell. It is useful to be able to do actions after setting up gpio pins or attaching gpioiic(4). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/etc/rc.d/gpio cvs rdiff -u -r1.2 -r1.3 src/share/man/man5/gpio.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Sat Apr 30 13:48:09 UTC 2022 Modified Files: src/etc/rc.d: gpio src/share/man/man5: gpio.conf.5 Log Message: Like /etc/rc.d/network, add the ability to put a '!' character as the first character in /etc/gpio.conf and have the rest evaluated in a shell. It is useful to be able to do actions after setting up gpio pins or attaching gpioiic(4). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/etc/rc.d/gpio cvs rdiff -u -r1.2 -r1.3 src/share/man/man5/gpio.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/rc.d/gpio diff -u src/etc/rc.d/gpio:1.1 src/etc/rc.d/gpio:1.2 --- src/etc/rc.d/gpio:1.1 Sat Jul 25 16:20:10 2009 +++ src/etc/rc.d/gpio Sat Apr 30 13:48:09 2022 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: gpio,v 1.1 2009/07/25 16:20:10 mbalmer Exp $ +# $NetBSD: gpio,v 1.2 2022/04/30 13:48:09 brad Exp $ # # PROVIDE: gpio @@ -18,10 +18,21 @@ gpio_start() if [ -f /etc/gpio.conf ]; then echo "Configuring GPIO." cat /etc/gpio.conf | + collapse_backslash_newline | while read -r args; do - args=${args%%#*} # strip comments - test -z "$args" && continue - /usr/sbin/gpioctl -q $args + case "$args" in + "!"*) +# Run arbitrary command in a subshell. +( eval "${args#*!}" ) +;; + *) + ( +args=${args%%#*} # strip comments +test -z "$args" && continue +/usr/sbin/gpioctl -q $args +) +;; + esac done fi } Index: src/share/man/man5/gpio.conf.5 diff -u src/share/man/man5/gpio.conf.5:1.2 src/share/man/man5/gpio.conf.5:1.3 --- src/share/man/man5/gpio.conf.5:1.2 Sat Aug 1 13:14:40 2009 +++ src/share/man/man5/gpio.conf.5 Sat Apr 30 13:48:09 2022 @@ -1,4 +1,4 @@ -.\"$NetBSD: gpio.conf.5,v 1.2 2009/08/01 13:14:40 mbalmer Exp $ +.\"$NetBSD: gpio.conf.5,v 1.3 2022/04/30 13:48:09 brad Exp $ .\" .\" Copyright (c) 2009 Marc Balmer .\" All rights reserved. @@ -40,6 +40,9 @@ and is intended for configuring GPIO pin Lines starting with a hash .Pq Sq # and empty lines are ignored. +If a line starts with +.Sq \&! , +the rest of line will get evaluated as shell script fragment. All other lines are passed to .Xr gpioctl 8 . .Sh FILES
CVS commit: src/sys/dev/gpio
Module Name:src Committed By: brad Date: Wed Apr 27 23:15:30 UTC 2022 Modified Files: src/sys/dev/gpio: gpio.c Log Message: I have been using this for a while and forgot to commit it. This add a number of KERNEL_LOCK() calls and at the very least prevents gpioiic from panicing the system. This may be a fix for kern/56438. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/dev/gpio/gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/gpio
Module Name:src Committed By: brad Date: Wed Apr 27 23:15:30 UTC 2022 Modified Files: src/sys/dev/gpio: gpio.c Log Message: I have been using this for a while and forgot to commit it. This add a number of KERNEL_LOCK() calls and at the very least prevents gpioiic from panicing the system. This may be a fix for kern/56438. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/dev/gpio/gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/gpio/gpio.c diff -u src/sys/dev/gpio/gpio.c:1.70 src/sys/dev/gpio/gpio.c:1.71 --- src/sys/dev/gpio/gpio.c:1.70 Thu Mar 31 19:30:16 2022 +++ src/sys/dev/gpio/gpio.c Wed Apr 27 23:15:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gpio.c,v 1.70 2022/03/31 19:30:16 pgoyette Exp $ */ +/* $NetBSD: gpio.c,v 1.71 2022/04/27 23:15:30 brad Exp $ */ /* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */ /* @@ -23,7 +23,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.70 2022/03/31 19:30:16 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.71 2022/04/27 23:15:30 brad Exp $"); /* * General Purpose Input/Output framework. @@ -181,12 +181,14 @@ gpio_childdetached(device_t self, device if (error) return; + KERNEL_LOCK(1, NULL); LIST_FOREACH(gdev, >sc_devs, sc_next) if (gdev->sc_dev == child) { LIST_REMOVE(gdev, sc_next); kmem_free(gdev, sizeof(struct gpio_dev)); break; } + KERNEL_UNLOCK_ONE(NULL); mutex_enter(>sc_mtx); sc->sc_attach_busy = 0; @@ -199,8 +201,10 @@ static int gpio_rescan(device_t self, const char *ifattr, const int *locators) { + KERNEL_LOCK(1, NULL); config_search(self, NULL, CFARGS(.search = gpio_search)); + KERNEL_UNLOCK_ONE(NULL); return 0; } @@ -882,6 +886,7 @@ gpio_ioctl(struct gpio_softc *sc, u_long locs[GPIOCF_MASK] = ga.ga_mask; locs[GPIOCF_FLAG] = ga.ga_flags; + KERNEL_LOCK(1, NULL); cf = config_search(sc->sc_dev, , CFARGS(.locators = locs)); if (cf != NULL) { @@ -902,6 +907,8 @@ gpio_ioctl(struct gpio_softc *sc, u_long #endif } else error = EINVAL; + KERNEL_UNLOCK_ONE(NULL); + mutex_enter(>sc_mtx); sc->sc_attach_busy = 0; cv_signal(>sc_attach); @@ -1139,6 +1146,7 @@ gpio_ioctl_oapi(struct gpio_softc *sc, u if (error) return EBUSY; + KERNEL_LOCK(1, NULL); attach = data; LIST_FOREACH(gdev, >sc_devs, sc_next) { if (strcmp(device_xname(gdev->sc_dev), @@ -1148,11 +1156,15 @@ gpio_ioctl_oapi(struct gpio_softc *sc, u cv_signal(>sc_attach); mutex_exit(>sc_mtx); -if (config_detach(gdev->sc_dev, 0) == 0) +if (config_detach(gdev->sc_dev, 0) == 0) { + KERNEL_UNLOCK_ONE(NULL); return 0; +} break; } } + KERNEL_UNLOCK_ONE(NULL); + if (gdev == NULL) { mutex_enter(>sc_mtx); sc->sc_attach_busy = 0;
CVS commit: src
Module Name:src Committed By: brad Date: Wed Apr 27 23:11:25 UTC 2022 Modified Files: src/share/man/man4: sht3xtemp.4 src/sys/dev/i2c: sht3x.c sht3xreg.h Log Message: After testing with a couple of more samples of the SHT3x sensor chip it was found that the datasheet does not appear to provide enough information to make use of the alarm and interrupt function work. So actually remove the dead code that was an attempt at making that all work. Adjust the man page to mention that this. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/sht3xtemp.4 cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/sht3x.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht3xreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/sht3xtemp.4 diff -u src/share/man/man4/sht3xtemp.4:1.2 src/share/man/man4/sht3xtemp.4:1.3 --- src/share/man/man4/sht3xtemp.4:1.2 Sat Nov 6 19:36:12 2021 +++ src/share/man/man4/sht3xtemp.4 Wed Apr 27 23:11:25 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: sht3xtemp.4,v 1.2 2021/11/06 19:36:12 wiz Exp $ +.\" $NetBSD: sht3xtemp.4,v 1.3 2022/04/27 23:11:25 brad Exp $ .\" .\" Copyright (c) 2021 Brad Spencer .\" @@ -119,3 +119,6 @@ The .Nm driver was written by .An Brad Spencer Aq Mt b...@anduin.eldar.org . +.Sh BUGS +The datasheet did not provide enough information to get the alarm +function of the chip working. Index: src/sys/dev/i2c/sht3x.c diff -u src/sys/dev/i2c/sht3x.c:1.6 src/sys/dev/i2c/sht3x.c:1.7 --- src/sys/dev/i2c/sht3x.c:1.6 Thu Mar 31 19:30:16 2022 +++ src/sys/dev/i2c/sht3x.c Wed Apr 27 23:11:25 2022 @@ -1,5 +1,5 @@ -/* $NetBSD: sht3x.c,v 1.6 2022/03/31 19:30:16 pgoyette Exp $ */ +/* $NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $ */ /* * Copyright (c) 2021 Brad Spencer @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.6 2022/03/31 19:30:16 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $"); /* Driver for the Sensirion SHT30/SHT31/SHT35 @@ -52,18 +52,6 @@ static int sht3x_match(device_t, cfdata static void sht3x_attach(device_t, device_t, void *); static int sht3x_detach(device_t, int); static void sht3x_refresh(struct sysmon_envsys *, envsys_data_t *); -#ifdef __did_not_work -/* - * The chip that I had would not allow the limits to actually be set - * for reasons which are not obvious. The chip took the command just - * fine, but a read back of the limit registers showed that no change - * was made, so disable limits for now. - */ -static void sht3x_get_limits(struct sysmon_envsys *, envsys_data_t *, -sysmon_envsys_lim_t *, uint32_t *); -static void sht3x_set_limits(struct sysmon_envsys *, envsys_data_t *, -sysmon_envsys_lim_t *, uint32_t *); -#endif static int sht3x_verify_sysctl(SYSCTLFN_ARGS); static int sht3x_verify_sysctl_heateron(SYSCTLFN_ARGS); static int sht3x_verify_sysctl_modes(SYSCTLFN_ARGS); @@ -1181,9 +1169,6 @@ sht3x_attach(device_t parent, device_t s sc->sc_sensors[i].units = sht3x_sensors[i].type; sc->sc_sensors[i].state = ENVSYS_SINVALID; -#ifdef __did_not_work - sc->sc_sensors[i].flags |= ENVSYS_FMONLIMITS; -#endif DPRINTF(sc, 2, ("%s: registering sensor %d (%s)\n", __func__, i, sc->sc_sensors[i].desc)); @@ -1200,10 +1185,6 @@ sht3x_attach(device_t parent, device_t s sc->sc_sme->sme_name = device_xname(sc->sc_dev); sc->sc_sme->sme_cookie = sc; sc->sc_sme->sme_refresh = sht3x_refresh; -#ifdef __did_not_work - sc->sc_sme->sme_get_limits = sht3x_get_limits; - sc->sc_sme->sme_set_limits = sht3x_set_limits; -#endif DPRINTF(sc, 2, ("sht3x_attach: registering with envsys\n")); @@ -1370,38 +1351,6 @@ sht3x_parse_data(struct sht3x_sc *sc, en return 0; } -#ifdef __did_not_work -/* - * These are the the same as above except solved for the raw tick rather than - * temperature or humidity. These are needed for setting the alert limits, but - * since that did not work, disable these too for now. - */ -static uint16_t -sht3x_compute_raw_from_temp(uint32_t temp) -{ - uint64_t i1; - uint32_t tempc; - - tempc = temp - 27215; - tempc = tempc / 100; - - i1 = (13107 * tempc) + 589815; - return (uint16_t)(i1 / 35); -} - -static uint16_t -sht3x_compute_raw_from_rh(uint32_t mrh) -{ - uint64_t i1; - uint32_t rh; - - rh = mrh / 100; - - i1 = 13107 * rh; - return (uint16_t)(i1 / 20); -} -#endif - static int sht3x_refresh_periodic(struct sysmon_envsys *sme, envsys_data_t *edata) { @@ -1478,419 +1427,6 @@ sht3x_refresh(struct sysmon_envsys *sme, mutex_exit(>sc_mutex); } -#ifdef __did_not_work -static void -sht3x_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata, -sysmon_envsys_lim_t *limits, uint32_t *props) -{ - struct sht3x_sc *sc = sme->sme_cookie; - ui
CVS commit: src
Module Name:src Committed By: brad Date: Wed Apr 27 23:11:25 UTC 2022 Modified Files: src/share/man/man4: sht3xtemp.4 src/sys/dev/i2c: sht3x.c sht3xreg.h Log Message: After testing with a couple of more samples of the SHT3x sensor chip it was found that the datasheet does not appear to provide enough information to make use of the alarm and interrupt function work. So actually remove the dead code that was an attempt at making that all work. Adjust the man page to mention that this. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/sht3xtemp.4 cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/sht3x.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht3xreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/etc
Greg Troxel writes: [snip] > > I am opposed to deciding that all zfs filesystems should be treated as > critical (in a world where we have not abolished the notion). > > We could have a discussion about why we even have the concept of > critical filesystems, but if so that should not be about zfs and > should be in a new thread on tech-userlevel. And, I think it really > isn't strongly releated to this discussion. [snip] Ya, I suspect that the notion of precedence needs to be developed somehow and not abuse the notion of critical too much. That is, filesystem mounting by type needs to happen in a particular order. The default would have to choose something, either making not ZFS happen first followed by normal and usual ZFS pools, or the other way around. I suspect that someone loses out as no default can handle every way that ZFS may be used when other filesystem types are present. For example, in the cases I have, a FFS is the root filesystem along with other FFS file systems. Under these are ZFS normal pools, so the order I would prefer in this case is mount FFS first and then import the pools, as the places that the pools would mount under would not exist the other way around. However, I very much understand that the other way around could exist where ZFS normal pools are imported before anything else. I honestly don't remember what Solaris did, but I can't see any ordering default with NetBSD handling every case in the correct manor. Even if it were possible to know the root filesystem type in a simple manor like one can know the root filesystem device and partition, I don't think that it would be possible to guess all of the cases correctly. -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
Re: CVS commit: src/etc
Greg Troxel writes: [snip] > [I don't really know what you mean by legacy (other than non-zfs, but > you didn't say that, so perhaps you mean something different).] [snip] I am only going to speak to the use of "legacy" in this conversation. What is referred to here is a specific ZFS idea and should not be confused with any sort of global notion. Specifically, ZFS, by default and in common use, does not use anything like a /etc/fstab or /etc/vfstab to specify where the filesets get mounted. It also does not usually use the usual mount command either to mount them, although that would work in Solaris if I remember correctly (at least in some cases). What happens is that the mount point is specified in the fileset meta data and "zfs mount " takes care of getting it mounted. If you wanted to use /etc/fstab or /etc/vfstab with ZFS you need to mark the mountpoint in the fileset as being legacy, then you could fill in your /etc/... files as you wanted. This, of course, strongly suggests that Sun was going to make all of the other filesystems except ZFS second class, but Sun fell apart before that really progressed to anything final and Oracle never really ran to that conclusion either. No one is at all suggesting that any filesystem become second class in the NetBSD realization of ZFS. So the term legacy when speaking of ZFS is used to refer to a filesystem that uses whatever /etc/... files you use and uses the usual mount command. -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
Re: CVS commit: src/etc
Alexander Nasonov writes: > Brad Spencer wrote: >> Alexander Nasonov writes: >> > Are there any downside of mixing legacy and non-legacy mountpoints? >> > E.g. if my /var is legacy but /var/crash is a normal ZFS mountpoint? >> >> That should work fine as long as /var was arranged to be mounted first. >> The other way around may and probably is trouble right now, where a >> zpool Not-legacy needs to be mounted so that a ZFS legacy filesystem or, >> in fact, any other filesystem type gets mounted under it. I believe >> that Solaris did and probably still does have this problem too. Legacy >> ZFS mounts should be perfectly workable even from single user when /usr >> isn't available yet for most simple use cases. > > Since I plan to migrate my ZFS setup to a smaller cgd disk, I gave > legacy mountpoints a try to see how much complexity they add. > > I have the following ZFS mountpoints in my setup > > /usr - legacy > /var - legacy > /var/log - legacy > /var/tmp - normal > /var/mail - normal > ... > > Ideally, I'd like to keep all datasets under one root: > > tank/base/usr - legacy > tank/base/var - legacy > tank/base/var/log - legacy > tank/base/var/mail - normal > > but it has a small inconvenience: every time I add a new dataset under > a legacy mountpoint (e.g. create a dataset for /var/spool), it can't > inherit a mountpoint from a legacy mountpoint and I have to set it > manually (zfs set mountpoint=/var/spool tank/base/var/spool). Yes, that would very much be the case. Legacy mounts in ZFS are mostly there to make /etc/fstab (and simular ilk) work the same as one may be used to doing, so no inheritance. You do not have to use most of the zpool / zfs commands to get them mounted, but at the same time you can set their sizes and such. Getting too complicated with them, however, may introduce unexpected adventure. > One way to avoid this issue is to have separate hierarchies: > > tank/legacy > tank/legacy/usr > tank/legacy/var > tank/legacy/var/log > tank/base > tank/base/var > tank/base/var/mail > > but I'm pretty sure it has some downsides too. > > Alex -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
Re: CVS commit: src/etc
Alexander Nasonov writes: > J. Hannken-Illjes wrote: >> What is wrong with ZFS legacy mounts? >> >> $ zpool create -m legacy tank >> $ zfs create tank/a >> $ mount -t zfs tank/a /mnt > > Hmm, I heard about ZFS legacy (quite a while ago!) but I didn't > look into it because, well, "legacy"... > > Are there any downside of mixing legacy and non-legacy mountpoints? > E.g. if my /var is legacy but /var/crash is a normal ZFS mountpoint? > > Alex That should work fine as long as /var was arranged to be mounted first. The other way around may and probably is trouble right now, where a zpool Not-legacy needs to be mounted so that a ZFS legacy filesystem or, in fact, any other filesystem type gets mounted under it. I believe that Solaris did and probably still does have this problem too. Legacy ZFS mounts should be perfectly workable even from single user when /usr isn't available yet for most simple use cases. -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
CVS commit: src
Module Name:src Committed By: brad Date: Tue Dec 7 17:50:27 UTC 2021 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 spi.4 Log Message: Mention the SCMD device To generate a diff of this commit: cvs rdiff -u -r1.2852 -r1.2853 src/doc/CHANGES cvs rdiff -u -r1.32 -r1.33 src/share/man/man4/iic.4 cvs rdiff -u -r1.11 -r1.12 src/share/man/man4/spi.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2852 src/doc/CHANGES:1.2853 --- src/doc/CHANGES:1.2852 Thu Nov 25 06:19:06 2021 +++ src/doc/CHANGES Tue Dec 7 17:50:27 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2852 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2853 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -457,3 +457,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: cgdconfig(8): Added 'argon2id' password-based key generation method. [nia 20211122] aarch64: Add initial COMPAT_LINUX32 support. [ryo 20211125] + scmd: Driver and userland utility for the Sparkfun Serial Controlled + Motor Driver [brad 20211207] Index: src/share/man/man4/iic.4 diff -u src/share/man/man4/iic.4:1.32 src/share/man/man4/iic.4:1.33 --- src/share/man/man4/iic.4:1.32 Sun Dec 5 04:38:54 2021 +++ src/share/man/man4/iic.4 Tue Dec 7 17:50:27 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: iic.4,v 1.32 2021/12/05 04:38:54 msaitoh Exp $ +.\" $NetBSD: iic.4,v 1.33 2021/12/07 17:50:27 brad Exp $ .\" $OpenBSD: iic.4,v 1.74 2008/09/10 16:13:43 reyk Exp $ .\" .\" Copyright (c) 2004, 2006 Alexander Yurchenko @@ -209,6 +209,8 @@ NXP PCF8563 real-time clock RICOH RS5C372A and RS5C372B real-time clock .It Xr s390rtc 4 Seiko Instruments S-35390 real-time clock +.It Xr scmdi2c 4 +I2C frontend for the Sparkfun Serial Controlled Motor Driver. .It Xr sdtemp 4 JEDEC JC-42.4 compatible memory module temperature sensors .It Xr seeprom 4 Index: src/share/man/man4/spi.4 diff -u src/share/man/man4/spi.4:1.11 src/share/man/man4/spi.4:1.12 --- src/share/man/man4/spi.4:1.11 Thu Mar 11 15:46:03 2021 +++ src/share/man/man4/spi.4 Tue Dec 7 17:50:27 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: spi.4,v 1.11 2021/03/11 15:46:03 nia Exp $ +.\" $NetBSD: spi.4,v 1.12 2021/12/07 17:50:27 brad Exp $ .\" .\" Copyright (c) 2006 Urbana-Champaign Independent Media Center. .\" Copyright (c) 2006 Garrett D'Amore. @@ -141,6 +141,8 @@ Microchip MCP3x0x SAR analog to digital Microchip MCP4801/MCP4811/MCP4821 digital to analog converter. .It Xr tm121temp 4 Texas Instruments TMP121 temperature sensor. +.It Xr scmdspi 4 +SPI frontend for the Sparkfun Serial Controlled Motor Driver. .It Xr ssdfb 4 OLED/PLED framebuffer modules. .El
CVS commit: src
Module Name:src Committed By: brad Date: Tue Dec 7 17:50:27 UTC 2021 Modified Files: src/doc: CHANGES src/share/man/man4: iic.4 spi.4 Log Message: Mention the SCMD device To generate a diff of this commit: cvs rdiff -u -r1.2852 -r1.2853 src/doc/CHANGES cvs rdiff -u -r1.32 -r1.33 src/share/man/man4/iic.4 cvs rdiff -u -r1.11 -r1.12 src/share/man/man4/spi.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Tue Dec 7 17:39:55 UTC 2021 Modified Files: src/distrib/sets/lists/base: mi src/distrib/sets/lists/comp: mi src/distrib/sets/lists/debug: mi module.mi src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/etc: MAKEDEV.tmpl src/share/man/man4: Makefile src/sys/conf: files majors src/sys/dev/i2c: files.i2c src/sys/dev/ic: Makefile src/sys/dev/spi: files.spi src/sys/modules: Makefile src/usr.bin: Makefile Added Files: src/share/man/man4: scmd.4 scmdi2c.4 scmdspi.4 src/sys/dev/i2c: scmdi2c.c src/sys/dev/ic: scmd.c scmdreg.h scmdvar.h src/sys/dev/spi: scmdspi.c src/sys/modules/scmd: Makefile scmd.ioconf src/sys/modules/scmdi2c: Makefile scmdi2c.ioconf src/usr.bin/scmdctl: Makefile common.c common.h i2cspi.c i2cspi.h printscmd.c printscmd.h responses.h scmdctl.1 scmdctl.c scmdctl.h scmdctlconst.h uart.c uart.h Log Message: A driver and user land utility for the Sparkfun Serial Controlled Motor Driver module as illustrated here: https://www.sparkfun.com/products/13911 A SCMD module is a ARM SOC simular to a Arduino in front of a motor driver chip. The single SCMD module can control two motors and up to 16 additional modules can be chained together using an internal I2C bus. One can interface with the SCMD using tty uart commands, SPI or I2C. The driver in this commit adds a kernel driver for the I2C and SPI interfaces. The command line utility provides a set of convenience commands that support most of the functions of the SCMD and is able to use the tty uart mode, SPI user land or the included kernel driver in a uniform manor. The use of the SCMD module is mostly for small robots and the like, but it can control anything that is controllable by voltage. To generate a diff of this commit: cvs rdiff -u -r1.1285 -r1.1286 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.2398 -r1.2399 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.368 -r1.369 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.15 -r1.16 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.1729 -r1.1730 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.149 -r1.150 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.227 -r1.228 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.719 -r1.720 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/scmd.4 src/share/man/man4/scmdi2c.4 \ src/share/man/man4/scmdspi.4 cvs rdiff -u -r1.1290 -r1.1291 src/sys/conf/files cvs rdiff -u -r1.100 -r1.101 src/sys/conf/majors cvs rdiff -u -r1.119 -r1.120 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/scmdi2c.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/Makefile cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/scmd.c src/sys/dev/ic/scmdreg.h \ src/sys/dev/ic/scmdvar.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/files.spi cvs rdiff -u -r0 -r1.1 src/sys/dev/spi/scmdspi.c cvs rdiff -u -r1.261 -r1.262 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/scmd/Makefile \ src/sys/modules/scmd/scmd.ioconf cvs rdiff -u -r0 -r1.1 src/sys/modules/scmdi2c/Makefile \ src/sys/modules/scmdi2c/scmdi2c.ioconf cvs rdiff -u -r1.235 -r1.236 src/usr.bin/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/scmdctl/Makefile \ src/usr.bin/scmdctl/common.c src/usr.bin/scmdctl/common.h \ src/usr.bin/scmdctl/i2cspi.c src/usr.bin/scmdctl/i2cspi.h \ src/usr.bin/scmdctl/printscmd.c src/usr.bin/scmdctl/printscmd.h \ src/usr.bin/scmdctl/responses.h src/usr.bin/scmdctl/scmdctl.1 \ src/usr.bin/scmdctl/scmdctl.c src/usr.bin/scmdctl/scmdctl.h \ src/usr.bin/scmdctl/scmdctlconst.h src/usr.bin/scmdctl/uart.c \ src/usr.bin/scmdctl/uart.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Sun Nov 14 18:36:13 UTC 2021 Modified Files: src/sys/dev/i2c: sht3x.c Log Message: Fix some regressions that were introduced. One must make sure that you release the i2c bus if you acquire. One must not try to release the i2c bus if you failed to acquire it. One can't leave too early from the single-shot refresh without checking the status register as there may have been a reset and releasing the i2c bus. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/sht3x.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/sht3x.c diff -u src/sys/dev/i2c/sht3x.c:1.3 src/sys/dev/i2c/sht3x.c:1.4 --- src/sys/dev/i2c/sht3x.c:1.3 Sat Nov 13 13:36:42 2021 +++ src/sys/dev/i2c/sht3x.c Sun Nov 14 18:36:13 2021 @@ -1,4 +1,5 @@ -/* $NetBSD: sht3x.c,v 1.3 2021/11/13 13:36:42 christos Exp $ */ + +/* $NetBSD: sht3x.c,v 1.4 2021/11/14 18:36:13 brad Exp $ */ /* * Copyright (c) 2021 Brad Spencer @@ -17,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.3 2021/11/13 13:36:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.4 2021/11/14 18:36:13 brad Exp $"); /* Driver for the Sensirion SHT30/SHT31/SHT35 @@ -487,7 +488,7 @@ sht3x_init_periodic_measurement(void *au if (error) { DPRINTF(sc, 2, ("%s: Could not acquire iic bus for initing: " " %d\n", device_xname(sc->sc_dev), error)); - goto out; + goto outm; } error = sht3x_take_break(sc, true); @@ -510,6 +511,7 @@ sht3x_init_periodic_measurement(void *au out: iic_release_bus(sc->sc_tag, 0); +outm: mutex_exit(>sc_mutex); return error; } @@ -605,7 +607,9 @@ err: "%x%x - %x -- %d\n", device_xname(sc->sc_dev), rawbuf[0], rawbuf[1], rawbuf[2], rawbuf[3], rawbuf[4], rawbuf[5], error)); iic_release_bus(sc->sc_tag, 0); - memcpy(sc->sc_pbuffer, "dedbef", sizeof(sc->sc_pbuffer)); + if (error != 0) { + memcpy(sc->sc_pbuffer, "dedbef", sizeof(sc->sc_pbuffer)); + } mutex_exit(>sc_mutex); } @@ -1427,14 +1431,11 @@ sht3x_refresh_oneshot(struct sysmon_envs measurement_command_ss = sht3x_compute_measure_command_ss( sc->sc_repeatability); - DPRINTF(sc, 2, ("%s: Measurement command: %04x\n", - device_xname(sc->sc_dev), measurement_command_ss)); error = sht3x_cmdr(sc, measurement_command_ss, rawdata, sizeof(rawdata)); + DPRINTF(sc, 2, ("%s: Status for single-shot measurement cmd %04x " + "Error %d\n", device_xname(sc->sc_dev), measurement_command_ss, error)); if (error == 0) { - DPRINTF(sc, 2, ("%s: Failed to get new status in refresh for " - "single-shot %d\n", device_xname(sc->sc_dev), error)); - if ((error = sht3x_parse_data(sc, edata, rawdata)) == 0) - return 0; + error = sht3x_parse_data(sc, edata, rawdata); } uint16_t sbuf; @@ -1455,7 +1456,8 @@ sht3x_refresh_oneshot(struct sysmon_envs } iic_release_bus(sc->sc_tag, 0); - return 0; + + return error; } static void @@ -1875,7 +1877,7 @@ sht3x_set_limits(struct sysmon_envsys *s rawlimitslow = (rawlimitslow & 0x1FF) | limitlow; DPRINTF(sc, 2, ("%s: RH new raw limits high/low " "%04x %04x from %x %x\n", - device_xname(sc->sc_dev), rawlimitshigh, rawlimitslow, + device_xname(sc->sc_dev), rawlimitshigh, rawlimitslow, limithigh, limitlow)); sht3x_set_alert_limits(sc, rawlimitshigh, rawlimitslow, true); break; @@ -2036,6 +2038,10 @@ sht3x_detach(device_t self, int flags) mutex_exit(>sc_read_mutex); DPRINTF(sc, 2, ("%s: Will wait for anything to exit\n", device_xname(sc->sc_dev))); + /* In the worst case this will time out after 5 seconds. + * It really should not take that long for the drain / whatever + * to happen + */ cv_timedwait_sig(>sc_cond_dying, >sc_dying_mutex, mstohz(5000)); mutex_exit(>sc_dying_mutex);
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Sun Nov 14 18:36:13 UTC 2021 Modified Files: src/sys/dev/i2c: sht3x.c Log Message: Fix some regressions that were introduced. One must make sure that you release the i2c bus if you acquire. One must not try to release the i2c bus if you failed to acquire it. One can't leave too early from the single-shot refresh without checking the status register as there may have been a reset and releasing the i2c bus. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/sht3x.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Fri Nov 12 15:12:11 UTC 2021 Modified Files: src/share/man/man4: si70xxtemp.4 src/sys/dev/i2c: si70xx.c Log Message: Fix the serial number handling of the HTU21D chip and probably others. Increase the number of read attempts as the HTU21D and probably others do not respond as fast the actual SI70xx chip can. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/si70xxtemp.4 cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/si70xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Fri Nov 12 15:12:11 UTC 2021 Modified Files: src/share/man/man4: si70xxtemp.4 src/sys/dev/i2c: si70xx.c Log Message: Fix the serial number handling of the HTU21D chip and probably others. Increase the number of read attempts as the HTU21D and probably others do not respond as fast the actual SI70xx chip can. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/si70xxtemp.4 cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/si70xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/si70xxtemp.4 diff -u src/share/man/man4/si70xxtemp.4:1.6 src/share/man/man4/si70xxtemp.4:1.7 --- src/share/man/man4/si70xxtemp.4:1.6 Thu Nov 11 14:24:24 2021 +++ src/share/man/man4/si70xxtemp.4 Fri Nov 12 15:12:11 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: si70xxtemp.4,v 1.6 2021/11/11 14:24:24 wiz Exp $ +.\" $NetBSD: si70xxtemp.4,v 1.7 2021/11/12 15:12:11 brad Exp $ .\" .\" Copyright (c) 2017 Brad Spencer .\" @@ -72,7 +72,7 @@ and then another read command is sent to Depending on the resolution, and other factors, the wait time varies. The driver will attempt to read back the values readattempts number of times. -The default is 25 which should be more than enough for most purposes. +The default is 40 which should be enough for most purposes. There is an initial wait of 10,500 microseconds followed by a additional 1,000 microseconds per read attempt. .El Index: src/sys/dev/i2c/si70xx.c diff -u src/sys/dev/i2c/si70xx.c:1.9 src/sys/dev/i2c/si70xx.c:1.10 --- src/sys/dev/i2c/si70xx.c:1.9 Thu Nov 11 14:16:04 2021 +++ src/sys/dev/i2c/si70xx.c Fri Nov 12 15:12:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: si70xx.c,v 1.9 2021/11/11 14:16:04 brad Exp $ */ +/* $NetBSD: si70xx.c,v 1.10 2021/11/12 15:12:11 brad Exp $ */ /* * Copyright (c) 2017 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.9 2021/11/11 14:16:04 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.10 2021/11/12 15:12:11 brad Exp $"); /* Driver for the Silicon Labs SI7013/SI7020/SI7021, HTU21D and SHT21 @@ -609,6 +609,7 @@ si70xx_attach(device_t parent, device_t uint8_t testcrcpt1[4]; uint8_t testcrcpt2[4]; uint8_t crc1 = 0, crc2 = 0; + bool validcrcpt1, validcrcpt2; uint8_t readcrc1 = 0, readcrc2 = 0; uint8_t fwversion = 0, model, heaterregister; @@ -622,7 +623,7 @@ si70xx_attach(device_t parent, device_t #ifdef HAVE_I2C_EXECV sc->sc_clockstretch = 2048; #endif - sc->sc_readattempts = 25; + sc->sc_readattempts = 40; sc->sc_ignorecrc = false; sc->sc_sme = NULL; sc->sc_noheater = false; @@ -665,11 +666,24 @@ si70xx_attach(device_t parent, device_t testcrcpt1[3] = buf[6]; readcrc1 = buf[7]; crc1 = si70xx_crc(testcrcpt1, 4); + /* A "real" SI70xx has the CRC cover the entire first part of the + * serial number. An HTU21D has the CRC broken out into each + * part of the serial number. + */ + validcrcpt1 = (readcrc1 == crc1); + if (! validcrcpt1) { + validcrcpt1 = (si70xx_crc([0],1) == buf[1] && + si70xx_crc([1],1) == buf[3] && + si70xx_crc([2],1) == buf[5] && + si70xx_crc([3],1) == buf[7]); + DPRINTF(sc, 2, ("%s: Part 1 SN CRC was not valid for real type, " + "check clone: %d\n", device_xname(sc->sc_dev), validcrcpt1)); + } DPRINTF(sc, 2, ("%s: read 1 values: %02x%02x%02x%02x%02x%02x%02x%02x " - "- %02x\n", device_xname(sc->sc_dev), buf[0], buf[1], + "- %02x -- %d\n", device_xname(sc->sc_dev), buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], - crc1)); + crc1, validcrcpt1)); error = si70xx_cmd2(sc, SI70XX_READ_ID_PT2A, SI70XX_READ_ID_PT2B, buf, 8); @@ -684,16 +698,30 @@ si70xx_attach(device_t parent, device_t testcrcpt2[3] = buf[4]; readcrc2 = buf[5]; crc2 = si70xx_crc(testcrcpt2, 4); + /* It is even stranger for this part of the serial number. A "real" + * SI70XX will have a single CRC for the entire second part, but + * an HTU21D has a CRC for each word in this case. + * + * The datasheet actually agrees with the HTU21D case, and not the "real" + * chip. + */ + validcrcpt2 = (readcrc2 == crc2); + if (! validcrcpt2) { + validcrcpt2 = (si70xx_crc([0],2) == buf[2] && + si70xx_crc([2],2) == buf[5]); + DPRINTF(sc, 2, ("%s: Part 2 SN CRC was not valid for real type, " + "check clone: %d\n", device_xname(sc->sc_dev), validcrcpt2)); + } - DPRINTF(sc, 2, ("%s: read 2 values: %02x%02x%02x%02x%02x%02x - %02x\n", + DPRINTF(sc, 2, ("%s: read 2 values: %02x%02x%02x%02x%02x%02x - %02x -- %d\n", device_xname(sc->sc_dev), buf[0], buf[1], buf[2], - buf[3], buf[4], buf
CVS commit: src
Module Name:src Committed By: brad Date: Thu Nov 11 14:16:05 UTC 2021 Modified Files: src/share/man/man4: si70xxtemp.4 src/sys/dev/i2c: si70xx.c si70xxvar.h Log Message: Some HTU21D chips do not have a heater register and apparently no heater element. Disable the heater features in the driver when that condition is detected and let the attachment succeed. Also mention that the SHT21 is another clone. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/si70xxtemp.4 cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/si70xx.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/si70xxvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/si70xxtemp.4 diff -u src/share/man/man4/si70xxtemp.4:1.4 src/share/man/man4/si70xxtemp.4:1.5 --- src/share/man/man4/si70xxtemp.4:1.4 Thu Feb 8 09:03:23 2018 +++ src/share/man/man4/si70xxtemp.4 Thu Nov 11 14:16:04 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: si70xxtemp.4,v 1.4 2018/02/08 09:03:23 dholland Exp $ +.\" $NetBSD: si70xxtemp.4,v 1.5 2021/11/11 14:16:04 brad Exp $ .\" .\" Copyright (c) 2017 Brad Spencer .\" @@ -19,7 +19,7 @@ .Os .Sh NAME .Nm si70xxtemp -.Nd Driver for Silicon Labs SI7013/SI7020/SI7021 and HTU21D sensor chip via I2C bus +.Nd Driver for Silicon Labs SI7013/SI7020/SI7021, HTU21D and SHT21 sensor chip via I2C bus .Sh SYNOPSIS .Cd "si70xxtemp* at iic? addr 0x40" .Sh DESCRIPTION @@ -57,6 +57,9 @@ Turn the heater on and off. .It hw.si70xxtemp0.heaterstrength From 1 to 6, the amount of energy put into the heater. The higher the number, the more power used. +.Pp +Some HTU21D chips do not support a heater register. These chips are +detected and the heater features of the driver will be disabled. .It hw.si70xxtemp0.debug If the driver is compiled with .Dv SI70XX_DEBUG , Index: src/sys/dev/i2c/si70xx.c diff -u src/sys/dev/i2c/si70xx.c:1.8 src/sys/dev/i2c/si70xx.c:1.9 --- src/sys/dev/i2c/si70xx.c:1.8 Sat Aug 21 11:55:25 2021 +++ src/sys/dev/i2c/si70xx.c Thu Nov 11 14:16:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: si70xx.c,v 1.8 2021/08/21 11:55:25 andvar Exp $ */ +/* $NetBSD: si70xx.c,v 1.9 2021/11/11 14:16:04 brad Exp $ */ /* * Copyright (c) 2017 Brad Spencer @@ -17,10 +17,10 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.8 2021/08/21 11:55:25 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.9 2021/11/11 14:16:04 brad Exp $"); /* - Driver for the Silicon Labs SI7013/SI7020/SI7021 + Driver for the Silicon Labs SI7013/SI7020/SI7021, HTU21D and SHT21 */ #include @@ -442,7 +442,10 @@ static int si70xx_update_status(struct si70xx_sc *sc) { int error1 = si70xx_update_user(sc); - int error2 = si70xx_update_heater(sc); + int error2 = 0; + if (! sc->sc_noheater) { + error2 = si70xx_update_heater(sc); + } return error1 ? error1 : error2; } @@ -547,17 +550,22 @@ si70xx_sysctl_init(struct si70xx_sc *sc) CTL_HW, sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) return error; - if ((error = sysctl_createv(>sc_si70xxlog, 0, NULL, , - CTLFLAG_READWRITE, CTLTYPE_BOOL, "heateron", - SYSCTL_DESCR("Heater on"), si70xx_verify_sysctl_heateron, 0, - (void *)sc, 0, CTL_HW, sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) - return error; + if (! sc->sc_noheater) { + if ((error = sysctl_createv(>sc_si70xxlog, 0, NULL, , + CTLFLAG_READWRITE, CTLTYPE_BOOL, "heateron", + SYSCTL_DESCR("Heater on"), si70xx_verify_sysctl_heateron, 0, + (void *)sc, 0, CTL_HW, sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + + if ((error = sysctl_createv(>sc_si70xxlog, 0, NULL, , + CTLFLAG_READWRITE, CTLTYPE_INT, "heaterstrength", + SYSCTL_DESCR("Heater strength 1 to 6"), + si70xx_verify_sysctl_heatervalue, 0, (void *)sc, 0, CTL_HW, + sysctlroot_num, CTL_CREATE, CTL_EOL)) != 0) + return error; + } - return sysctl_createv(>sc_si70xxlog, 0, NULL, , - CTLFLAG_READWRITE, CTLTYPE_INT, "heaterstrength", - SYSCTL_DESCR("Heater strength 1 to 6"), - si70xx_verify_sysctl_heatervalue, 0, (void *)sc, 0, CTL_HW, - sysctlroot_num, CTL_CREATE, CTL_EOL); + return 0; } static int @@ -602,7 +610,7 @@ si70xx_attach(device_t parent, device_t uint8_t testcrcpt2[4]; uint8_t crc1 = 0, crc2 = 0; uint8_t readcrc1 = 0, readcrc2 = 0; - uint8_t fwversion, model; + uint8_t fwversion = 0, model, heaterregister; ia = aux; sc = device_private(self); @@ -617,6 +625,8 @@ si70xx_attach(device_t parent, device_t sc->sc_readattempts = 25; sc->sc_ignorecrc = false; sc->sc_sme = NULL; + sc->sc_noheater = false; + sc->sc_nofw = false; aprint_normal("\n"); @@ -629,10 +639,6 @@ si70xx_attach(device_t parent, device_t sc->sc_sme = NULL; return; } - if (
CVS commit: src
Module Name:src Committed By: brad Date: Thu Nov 11 14:16:05 UTC 2021 Modified Files: src/share/man/man4: si70xxtemp.4 src/sys/dev/i2c: si70xx.c si70xxvar.h Log Message: Some HTU21D chips do not have a heater register and apparently no heater element. Disable the heater features in the driver when that condition is detected and let the attachment succeed. Also mention that the SHT21 is another clone. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/si70xxtemp.4 cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/si70xx.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/si70xxvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: brad Date: Sat Nov 6 13:39:06 UTC 2021 Modified Files: src/doc: CHANGES Log Message: Mention sht3xtemp(4) To generate a diff of this commit: cvs rdiff -u -r1.2847 -r1.2848 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2847 src/doc/CHANGES:1.2848 --- src/doc/CHANGES:1.2847 Thu Oct 28 14:54:32 2021 +++ src/doc/CHANGES Sat Nov 6 13:39:06 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2847 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2848 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -450,3 +450,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: passwd.conf(5): Make 'argon2id' the default cipher for new passwords. [nia 20211026] acpi(4): Updated ACPICA to 20210930. [christos 20211028] + sht3xtemp(4): Driver for the Sensirion SHT30/SHT31/SHT35 temperature + and humidity sensor [brad 20211106]
CVS commit: src/doc
Module Name:src Committed By: brad Date: Sat Nov 6 13:39:06 UTC 2021 Modified Files: src/doc: CHANGES Log Message: Mention sht3xtemp(4) To generate a diff of this commit: cvs rdiff -u -r1.2847 -r1.2848 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man4
Module Name:src Committed By: brad Date: Sat Nov 6 13:36:34 UTC 2021 Modified Files: src/share/man/man4: iic.4 Log Message: Mention sht3xtemp(4) To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/iic.4 diff -u src/share/man/man4/iic.4:1.30 src/share/man/man4/iic.4:1.31 --- src/share/man/man4/iic.4:1.30 Thu Oct 14 20:23:31 2021 +++ src/share/man/man4/iic.4 Sat Nov 6 13:36:34 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: iic.4,v 1.30 2021/10/14 20:23:31 nia Exp $ +.\" $NetBSD: iic.4,v 1.31 2021/11/06 13:36:34 brad Exp $ .\" $OpenBSD: iic.4,v 1.74 2008/09/10 16:13:43 reyk Exp $ .\" .\" Copyright (c) 2004, 2006 Alexander Yurchenko @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd October 14, 2021 +.Dd November 6, 2021 .Dt IIC 4 .Os .Sh NAME @@ -217,6 +217,8 @@ JEDEC JC-42.4 compatible memory module t Sensirion SGP40 MOx gas sensors .It Xr sgsmix 4 SGS 7433 Basic Audio Processor found in some Apple machines +.It Xr sht3xtemp 4 +Sensirion SHT30/SHT31/SHT35 temperature/humidity sensors .It Xr sht4xtemp 4 Sensirion SHT40/SHT41/SHT45 temperature/humidity sensors .It Xr si70xxtemp 4
CVS commit: src/share/man/man4
Module Name:src Committed By: brad Date: Sat Nov 6 13:36:34 UTC 2021 Modified Files: src/share/man/man4: iic.4 Log Message: Mention sht3xtemp(4) To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/share/man/man4/iic.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
14 13:54:45 brad Exp $ +# $NetBSD: Makefile,v 1.260 2021/11/06 13:34:39 brad Exp $ .include @@ -69,6 +69,7 @@ SUBDIR+= hfs SUBDIR+= hythygtemp SUBDIR+= si70xxtemp SUBDIR+= am2315temp +SUBDIR+= sht3xtemp SUBDIR+= sht4xtemp SUBDIR+= sgp40mox SUBDIR+= i2cexec Added files: Index: src/share/man/man4/sht3xtemp.4 diff -u /dev/null src/share/man/man4/sht3xtemp.4:1.1 --- /dev/null Sat Nov 6 13:34:40 2021 +++ src/share/man/man4/sht3xtemp.4 Sat Nov 6 13:34:39 2021 @@ -0,0 +1,119 @@ +.\" $NetBSD: sht3xtemp.4,v 1.1 2021/11/06 13:34:39 brad Exp $ +.\" +.\" Copyright (c) 2021 Brad Spencer +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd October 31, 2021 +.Dt SHT3XTEMP 4 +.Os +.Sh NAME +.Nm sht3xtemp +.Nd Driver for Sensirion SHT30/SHT31/SHT35 sensor chip via I2C bus +.Sh SYNOPSIS +.Cd "sht3xtemp* at iic? addr 0x44" +.Cd "sht3xtemp* at iic? addr 0x45" +.Sh DESCRIPTION +The +.Nm +driver provides measurements from the SHT30/SHT31/SHT35 humidity/temperature +sensors via the +.Xr envsys 4 +framework. +The +.Nm +.Ar addr +argument selects the address at the +.Xr iic 4 +bus. +The mode of operation, repeatability, heater controls, periodic update rate +and crc validity can be changed through +.Xr sysctl 8 +nodes. +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 3 +variables are provided: +.Bl -tag -width indent +.It Li hw.sht3xtemp0.modes +Lists the modes supported by the driver and chip. +.It Li hw.sht3xtemp0.mode +Set the operation mode of the chip. The SHT3X chip can run in a +single-shot measurement mode or a periodic update mode. +Use one of the strings listed in +.Li hw.sht3xtemp.modes . +.It Li hw.sht3xtemp0.rates +List the periodic update rates supported by the driver and chip. +.It Li hw.sht3xtemp0.rate +Set the periodic update rate when the mode of operation is set to +periodic. The unit for this is measurements per second, or ART +which is a mode that operates at an update rate of 4Hz higher +response time. +Use one of the strings listed in +.Li hw.sht3xtemp.rates . +.Pp +Since it is possible to have subsecond periodic updates from the +chip if so desired a device file is provided that can be used to +get the raw temperature and humidity values outside of the +.Xr envsys 4 +framework. +The structure of this output is the raw temperature plus an 8-bit CRC +followed by the raw humidity plus an 8-bit CRC. +.It Li hw.sht3xtemp0.repeatabilities +List the valid values for the repeatability used for a measurement. +.It Li hw.sht3xtemp0.repeatability +Set the repeatability for the measurement. The higher the repeatability +the longer the measurement will take and the more power used. +Use one of the strings listed in +.Li hw.sht3xtemp.repeatabilities . +.It Li hw.sht3xtemp0.ignorecrc +If set, the crc calculation for %RH and temperature in the measurement phrase +will be ignored. +.It Li hw.sht3xtemp0.heateron +Turn the heater on and off. +.It Li hw.sht3xtemp0.debug +If the driver is compiled with +.Dv SHT3X_DEBUG , +this node will appear and can be used to set the debugging level. +.It Li hw.sht3xtemp0.readattempts +To read %RH or temperature the chip requires that the command be sent, +then a delay must be observed before a read can be done to get the values +back. +The delays are documented in the datasheet for the chip. +The driver will attempt to read back the values readattempts number of +times. +The default is 10 which should be more than enough for most purposes. +.El +.Sh FILES +.Bl -tag -width "/dev/sht3xtempu" -compact +.It /dev/sht3xtemp Ns Ar u +SHT3X device unit +.Ar u +file. +.El +.Sh SEE ALSO +.Xr envsys 4 , +.Xr iic 4 , +.Xr envstat 8 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Nx 10.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Brad Spencer Aq Mt b...@anduin.eldar.org . Index: src/sys/dev/i2c/sht3x.c diff -u /dev/null src/sys/dev/i2c/sht3x.c:1.1 --- /dev/null Sat Nov 6 13:34:40 2021 +++ src/sys/dev/i2c/sht3x.c Sat Nov 6 13:34:40 2021 @@ -0,0 +1,2111 @@ +/* $NetBSD: sht3x.c,v 1.1 2021/11/06 13:34:40 brad Exp $ */ + +/* + * Copyright (c) 2021 Brad Spencer + * + * Permission to use, copy, modify, and distribute this softwa
CVS commit: src
Module Name:src Committed By: brad Date: Sat Nov 6 13:34:40 UTC 2021 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/etc: MAKEDEV.tmpl src/share/man/man4: Makefile src/sys/conf: majors src/sys/dev/i2c: files.i2c src/sys/modules: Makefile Added Files: src/share/man/man4: sht3xtemp.4 src/sys/dev/i2c: sht3x.c sht3xreg.h sht3xvar.h src/sys/modules/sht3xtemp: Makefile sht3xtemp.ioconf Log Message: Driver for the Sensirion SHT30/SHT31/SHT35 temperature and humidity sensor such as: https://www.adafruit.com/product/2857 This is a higher priced sensor with a lot of features, including the ability to do sub-second periodic updates. The driver supports everything about the sensor except for the alert pin. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.1728 -r1.1729 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.148 -r1.149 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.226 -r1.227 src/etc/MAKEDEV.tmpl cvs rdiff -u -r1.718 -r1.719 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/sht3xtemp.4 cvs rdiff -u -r1.99 -r1.100 src/sys/conf/majors cvs rdiff -u -r1.118 -r1.119 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/sht3x.c src/sys/dev/i2c/sht3xreg.h \ src/sys/dev/i2c/sht3xvar.h cvs rdiff -u -r1.259 -r1.260 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/sht3xtemp/Makefile \ src/sys/modules/sht3xtemp/sht3xtemp.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Fri Oct 29 23:23:33 UTC 2021 Modified Files: src/sys/dev/i2c: sht4x.c Log Message: Correct an off by one degree error in the temperature conversion. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht4x.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/sht4x.c diff -u src/sys/dev/i2c/sht4x.c:1.1 src/sys/dev/i2c/sht4x.c:1.2 --- src/sys/dev/i2c/sht4x.c:1.1 Sun Oct 3 17:27:02 2021 +++ src/sys/dev/i2c/sht4x.c Fri Oct 29 23:23:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sht4x.c,v 1.1 2021/10/03 17:27:02 brad Exp $ */ +/* $NetBSD: sht4x.c,v 1.2 2021/10/29 23:23:33 brad Exp $ */ /* * Copyright (c) 2021 Brad Spencer @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sht4x.c,v 1.1 2021/10/03 17:27:02 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sht4x.c,v 1.2 2021/10/29 23:23:33 brad Exp $"); /* Driver for the Sensirion SHT40/SHT41/SHT45 @@ -723,7 +723,7 @@ sht4x_refresh(struct sysmon_envsys * sme It follows then: - T in Kelvin = (229.15 + 175 * rawvalue / 65535) + T in Kelvin = (228.15 + 175 * rawvalue / 65535) given the relationship between Celsius and Kelvin. @@ -771,7 +771,7 @@ sht4x_refresh(struct sysmon_envsys * sme switch (edata->sensor) { case SHT4X_TEMP_SENSOR: svalptr = [0]; - v1 = 22915; /* this is scaled up already from 229.15 */ + v1 = 22815; /* this is scaled up already from 228.15 */ v2 = 175; mul1 = 100; mul2 = 1;
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: brad Date: Fri Oct 29 23:23:33 UTC 2021 Modified Files: src/sys/dev/i2c: sht4x.c Log Message: Correct an off by one degree error in the temperature conversion. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht4x.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: brad Date: Thu Oct 14 14:53:41 UTC 2021 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Mention sht4xtemp and sgp40mox in CHANGES. Add an entry for the Sensirion VOC algorithm in 3RDPARTY. To generate a diff of this commit: cvs rdiff -u -r1.1820 -r1.1821 src/doc/3RDPARTY cvs rdiff -u -r1.2839 -r1.2840 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: brad Date: Thu Oct 14 14:53:41 UTC 2021 Modified Files: src/doc: 3RDPARTY CHANGES Log Message: Mention sht4xtemp and sgp40mox in CHANGES. Add an entry for the Sensirion VOC algorithm in 3RDPARTY. To generate a diff of this commit: cvs rdiff -u -r1.1820 -r1.1821 src/doc/3RDPARTY cvs rdiff -u -r1.2839 -r1.2840 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1820 src/doc/3RDPARTY:1.1821 --- src/doc/3RDPARTY:1.1820 Sat Oct 2 11:01:53 2021 +++ src/doc/3RDPARTY Thu Oct 14 14:53:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1820 2021/10/02 11:01:53 kre Exp $ +# $NetBSD: 3RDPARTY,v 1.1821 2021/10/14 14:53:41 brad Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -2260,3 +2260,16 @@ Responsible: riastradh License: bsd Location: sys/external/bsd/libsodium Notes: + +Package: Sensirion VOC index algorithm +Version: git commit hash 4f69c0d8e2f7192aeaf0d268211b1f54af50146b +Current Vers: git commit hash 4f69c0d8e2f7192aeaf0d268211b1f54af50146b +Maintainer: Brad Spencer +Archive Site: https://github.com/Sensirion/embedded-sgp +Home Page: https://github.com/Sensirion +Date: 2021-09-30 +Mailing List: +Responsible: brad +License: BSD (3-clause) +Location: sys/dev/i2c/sensirion_voc_algorithm.c sys/dev/i2c/sensirion_voc_algorithm.h +Notes: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2839 src/doc/CHANGES:1.2840 --- src/doc/CHANGES:1.2839 Wed Oct 13 08:29:26 2021 +++ src/doc/CHANGES Thu Oct 14 14:53:41 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2839 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2840 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -435,5 +435,9 @@ Changes from NetBSD 9.0 to NetBSD 10.0: xf86-input-ws. [nia 20210928] gnu-efi: Import version 3.0.14. [jmcneill 20210930] tzdata partly updated to 2021b [kre 20211001] + sht4xtemp(4): Driver for the Sensirion SHT40/SHT41/SHT45 temperature + and humidity sensor [brad 20211003] wm(4): Add Tiger Lake and newer devices (I219V 15-V9 and LM 16-19). [msaitoh 20211013] + sgp40mox(4): Driver for the Sensirion SGP40 MOx gas sensor for air quality + [brad 20211014]
CVS commit: src
Module Name:src Committed By: brad Date: Thu Oct 14 13:54:46 UTC 2021 Modified Files: src/distrib/sets/lists/debug: module.mi src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/share/man/man4: Makefile src/sys/dev/i2c: files.i2c src/sys/modules: Makefile Added Files: src/share/man/man4: sgp40mox.4 src/sys/dev/i2c: sensirion_arch_config.h sensirion_voc_algorithm.c sensirion_voc_algorithm.h sgp40.c sgp40reg.h sgp40var.h src/sys/modules/sgp40mox: Makefile sgp40mox.ioconf Log Message: A driver for the Sensirion SGP40 MOx gas sensor. An example of this chip from Adafruit is: https://www.adafruit.com/product/4829 This is a moderately priced gas sensor that can detect volatile organic compounds in the air. The driver uses the 3-clause BSD licensed VOC algorithm provided by Sensirion to turn the raw sensor metric into a VOC index which can indicate the quality of the air in a particular indoor environment. All published functions of the chip are supported and one unpublished feature. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/distrib/sets/lists/debug/module.mi cvs rdiff -u -r1.1727 -r1.1728 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.147 -r1.148 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.717 -r1.718 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/sgp40mox.4 cvs rdiff -u -r1.117 -r1.118 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/sensirion_arch_config.h \ src/sys/dev/i2c/sensirion_voc_algorithm.c \ src/sys/dev/i2c/sensirion_voc_algorithm.h src/sys/dev/i2c/sgp40.c \ src/sys/dev/i2c/sgp40reg.h src/sys/dev/i2c/sgp40var.h cvs rdiff -u -r1.258 -r1.259 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/sgp40mox/Makefile \ src/sys/modules/sgp40mox/sgp40mox.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
e/man/man4/sgsmix.4 man-sys-man .man ./usr/share/man/man4/shb.4 man-sys-man .man ./usr/share/man/man4/shmif.4 man-sys-man .man Index: src/distrib/sets/lists/modules/mi diff -u src/distrib/sets/lists/modules/mi:1.147 src/distrib/sets/lists/modules/mi:1.148 --- src/distrib/sets/lists/modules/mi:1.147 Sun Oct 3 17:27:02 2021 +++ src/distrib/sets/lists/modules/mi Thu Oct 14 13:54:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.147 2021/10/03 17:27:02 brad Exp $ +# $NetBSD: mi,v 1.148 2021/10/14 13:54:46 brad Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -397,6 +397,8 @@ ./@MODULEDIR@/securelevel/securelevel.kmod modules-base-kernel kmod ./@MODULEDIR@/sequencermodules-base-kernel kmod ./@MODULEDIR@/sequencer/sequencer.kmod modules-base-kernel kmod +./@MODULEDIR@/sgp40moxmodules-base-kernel kmod +./@MODULEDIR@/sgp40mox/sgp40mox.kmod modules-base-kernel kmod ./@MODULEDIR@/sht4xtempmodules-base-kernel kmod ./@MODULEDIR@/sht4xtemp/sht4xtemp.kmod modules-base-kernel kmod ./@MODULEDIR@/si70xxtemp modules-base-kernel kmod Index: src/share/man/man4/Makefile diff -u src/share/man/man4/Makefile:1.717 src/share/man/man4/Makefile:1.718 --- src/share/man/man4/Makefile:1.717 Tue Oct 12 04:55:19 2021 +++ src/share/man/man4/Makefile Thu Oct 14 13:54:45 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.717 2021/10/12 04:55:19 msaitoh Exp $ +# $NetBSD: Makefile,v 1.718 2021/10/14 13:54:45 brad Exp $ # @(#)Makefile 8.1 (Berkeley) 6/18/93 MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \ @@ -56,8 +56,8 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 a rnd.4 route.4 rs5c372rtc.4 rtk.4 rtsx.4 rtw.4 rtwn.4 rum.4 run.4 \ s390rtc.4 satalink.4 sbus.4 schide.4 \ scsi.4 sctp.4 sd.4 se.4 seeprom.4 sem.4 \ - ses.4 sf.4 sfb.4 sgsmix.4 shb.4 shmif.4 shpcic.4 sht4xtemp.4 si70xxtemp.4 \ - siisata.4 siop.4 sip.4 siside.4 sk.4 sl.4 slide.4 \ + ses.4 sf.4 sfb.4 sgp40mox.4 sgsmix.4 shb.4 shmif.4 shpcic.4 sht4xtemp.4 \ + si70xxtemp.4 siisata.4 siop.4 sip.4 siside.4 sk.4 sl.4 slide.4 \ sm.4 smscphy.4 smsh.4 sn.4 sony.4 spc.4 speaker.4 spif.4 sqphy.4 \ srt.4 ss.4 \ ssdfb.4 st.4 ste.4 stge.4 sti.4 stpcide.4 sv.4 \ Index: src/sys/dev/i2c/files.i2c diff -u src/sys/dev/i2c/files.i2c:1.117 src/sys/dev/i2c/files.i2c:1.118 --- src/sys/dev/i2c/files.i2c:1.117 Sun Oct 3 17:27:02 2021 +++ src/sys/dev/i2c/files.i2c Thu Oct 14 13:54:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.i2c,v 1.117 2021/10/03 17:27:02 brad Exp $ +# $NetBSD: files.i2c,v 1.118 2021/10/14 13:54:46 brad Exp $ obsolete defflag opt_i2cbus.h I2C_SCAN define i2cbus { } @@ -400,6 +400,12 @@ device sht4xtemp attach sht4xtemp at iic file dev/i2c/sht4x.csht4xtemp +# Sensirion SGP40 MOx gas sensor +device sgp40mox +attach sgp40mox at iic +file dev/i2c/sgp40.csgp40mox +file dev/i2c/sensirion_voc_algorithm.c sgp40mox + # Philips PCA955x GPIO device pcagpio: leds attach pcagpio at iic Index: src/sys/modules/Makefile diff -u src/sys/modules/Makefile:1.258 src/sys/modules/Makefile:1.259 --- src/sys/modules/Makefile:1.258 Sat Oct 9 07:01:34 2021 +++ src/sys/modules/Makefile Thu Oct 14 13:54:45 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.258 2021/10/09 07:01:34 ryo Exp $ +# $NetBSD: Makefile,v 1.259 2021/10/14 13:54:45 brad Exp $ .include @@ -70,6 +70,7 @@ SUBDIR+= hythygtemp SUBDIR+= si70xxtemp SUBDIR+= am2315temp SUBDIR+= sht4xtemp +SUBDIR+= sgp40mox SUBDIR+= i2cexec SUBDIR+= i2c_bitbang SUBDIR+= if_agr Added files: Index: src/share/man/man4/sgp40mox.4 diff -u /dev/null src/share/man/man4/sgp40mox.4:1.1 --- /dev/null Thu Oct 14 13:54:46 2021 +++ src/share/man/man4/sgp40mox.4 Thu Oct 14 13:54:45 2021 @@ -0,0 +1,107 @@ +.\" $NetBSD: sgp40mox.4,v 1.1 2021/10/14 13:54:45 brad Exp $ +.\" +.\" Copyright (c) 2021 Brad Spencer +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd October 7, 2021 +.Dt SGP40MOX 4 +.Os +.Sh NAME +.Nm sgp40mox +.Nd Driver for Sensirion SGP40 MOx gas sensor +.Sh SYNOPSIS +.Cd "sgp40mox* at iic? addr 0x59" +.Sh DESCRIPTION +The +.Nm +driver provides an air quality measurement from the SGP40 +sensor via the +.Xr envsys 4 +framework. +The +.Nm +.Ar addr +argument s
CVS commit: src/distrib/sets/lists/debug
Module Name:src Committed By: brad Date: Mon Oct 4 07:04:39 UTC 2021 Modified Files: src/distrib/sets/lists/debug: module.mi Log Message: Sorry.. missed the debug module build in the previous commit. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/distrib/sets/lists/debug/module.mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/module.mi diff -u src/distrib/sets/lists/debug/module.mi:1.12 src/distrib/sets/lists/debug/module.mi:1.13 --- src/distrib/sets/lists/debug/module.mi:1.12 Sat Sep 11 16:10:37 2021 +++ src/distrib/sets/lists/debug/module.mi Mon Oct 4 07:04:39 2021 @@ -1,4 +1,4 @@ -# $NetBSD: module.mi,v 1.12 2021/09/11 16:10:37 pgoyette Exp $ +# $NetBSD: module.mi,v 1.13 2021/10/04 07:04:39 brad Exp $ ./usr/libdata/debug/@MODULEDIR@ modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/accf_dataready modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/accf_dataready/accf_dataready.kmod.debug modules-base-kernel kmod,debug @@ -332,7 +332,9 @@ ./usr/libdata/debug/@MODULEDIR@/securelevel/securelevel.kmod.debug modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/sequencermodules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/sequencer/sequencer.kmod.debug modules-base-kernel kmod,debug -./usr/libdata/debug/@MODULEDIR@/si70xxtemp modules-base-kernel kmod,debug +./usr/libdata/debug/@MODULEDIR@/sht4xtempmodules-base-kernel kmod,debug +./usr/libdata/debug/@MODULEDIR@/sht4xtemp/sht4xtemp.kmod.debug modules-base-kernel kmod,debug +./usr/libdata/debug/@MODULEDIR@/si70xxtempmodules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/si70xxtemp/si70xxtemp.kmod.debug modules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/skipjackmodules-base-kernel kmod,debug ./usr/libdata/debug/@MODULEDIR@/skipjack/skipjack.kmod.debug modules-base-kernel kmod,debug
CVS commit: src/distrib/sets/lists/debug
Module Name:src Committed By: brad Date: Mon Oct 4 07:04:39 UTC 2021 Modified Files: src/distrib/sets/lists/debug: module.mi Log Message: Sorry.. missed the debug module build in the previous commit. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/distrib/sets/lists/debug/module.mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
isata.4 siop.4 sip.4 siside.4 sk.4 sl.4 slide.4 \ sm.4 smscphy.4 smsh.4 sn.4 sony.4 spc.4 speaker.4 spif.4 sqphy.4 \ srt.4 ss.4 \ Index: src/sys/dev/i2c/files.i2c diff -u src/sys/dev/i2c/files.i2c:1.116 src/sys/dev/i2c/files.i2c:1.117 --- src/sys/dev/i2c/files.i2c:1.116 Tue Jul 27 20:23:41 2021 +++ src/sys/dev/i2c/files.i2c Sun Oct 3 17:27:02 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.i2c,v 1.116 2021/07/27 20:23:41 macallan Exp $ +# $NetBSD: files.i2c,v 1.117 2021/10/03 17:27:02 brad Exp $ obsolete defflag opt_i2cbus.h I2C_SCAN define i2cbus { } @@ -395,6 +395,11 @@ device cwfg: sysmon_envsys attach cwfg at iic file dev/i2c/cwfg.ccwfg +# Sensirion SHT40/SHT41/SHT45 Temperature and Humidity sensor +device sht4xtemp +attach sht4xtemp at iic +file dev/i2c/sht4x.csht4xtemp + # Philips PCA955x GPIO device pcagpio: leds attach pcagpio at iic Index: src/sys/modules/Makefile diff -u src/sys/modules/Makefile:1.256 src/sys/modules/Makefile:1.257 --- src/sys/modules/Makefile:1.256 Sat Sep 25 17:55:37 2021 +++ src/sys/modules/Makefile Sun Oct 3 17:27:02 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.256 2021/09/25 17:55:37 maya Exp $ +# $NetBSD: Makefile,v 1.257 2021/10/03 17:27:02 brad Exp $ .include @@ -69,6 +69,7 @@ SUBDIR+= hfs SUBDIR+= hythygtemp SUBDIR+= si70xxtemp SUBDIR+= am2315temp +SUBDIR+= sht4xtemp SUBDIR+= i2cexec SUBDIR+= i2c_bitbang SUBDIR+= if_agr Added files: Index: src/share/man/man4/sht4xtemp.4 diff -u /dev/null src/share/man/man4/sht4xtemp.4:1.1 --- /dev/null Sun Oct 3 17:27:03 2021 +++ src/share/man/man4/sht4xtemp.4 Sun Oct 3 17:27:02 2021 @@ -0,0 +1,93 @@ +.\" $NetBSD: sht4xtemp.4,v 1.1 2021/10/03 17:27:02 brad Exp $ +.\" +.\" Copyright (c) 2021 Brad Spencer +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd September 28th, 2021 +.Dt SHT4XTEMP 4 +.Os +.Sh NAME +.Nm sht4xtemp +.Nd Driver for Sensirion SHT40/SHT41/SHT45 sensor chip via I2C bus +.Sh SYNOPSIS +.Cd "sht4xtemp* at iic? addr 0x44" +.Sh DESCRIPTION +The +.Nm +driver provides measurements from the SHT40/SHT41/SHT45 humidity/temperature +sensors via the +.Xr envsys 4 +framework. +The +.Nm +.Ar addr +argument selects the address at the +.Xr iic 4 +bus. +The resolution, heater controls and crc validity can be changed through +.Xr sysctl 8 +nodes. +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 3 +variables are provided: +.Bl -tag -width indent +.It hw.sht4xtemp0.resolutions +Lists the resolutions supported by the driver and chip. +.It hw.sht4xtemp0.resolution +Set the resolution, or number of bits, used for %RH and temperature. +Use one of the strings listed in hw.sht4xtemp.resolutions. +.It hw.sht4xtemp0.ignorecrc +If set, the crc calculation for %RH and temperature will be ignored. +.It hw.sht4xtemp0.heateron +Turn the heater on and off. Please note that the heater is turned on right +before the measurement and runs for a pulse width of time. Then the measurement +is taken and the heater is turned off. There is no way to keep the heater running +with this chip. +.It hw.sht4xtemp0.heaterstrength +From 1 to 3, the amount of energy put into the heater. +The higher the number, the more power used. +.It hw.sht4xtemp0.heaterpulses +Lists the valid heater pulses supported by the driver and chip. +.It hw.sht4xtemp0.heaterpulse +Set the heater pulse length. Use one of the strings listed in +hw.sht4xtemp.heaterpulses +.It hw.sht4xtemp0.debug +If the driver is compiled with +.Dv SI70XX_DEBUG , +this node will appear and can be used to set the debugging level. +.It hw.sht4xtemp0.readattempts +To read %RH or temperature the chip requires that the command be sent, +then a delay must be observed before a read can be done to get the values +back. The delays are documented in the datasheet for the chip. +The driver will attempt to read back the values readattempts number of +times. +The default is 10 which should be more than enough for most purposes. +.El +.Sh SEE ALSO +.Xr envsys 4 , +.Xr iic 4 , +.Xr envstat 8 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Nx 10.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Brad Spencer Aq Mt b...@anduin.eldar.org . Index: src/sys/dev/i2c/
CVS commit: src
Module Name:src Committed By: brad Date: Sun Oct 3 17:27:02 UTC 2021 Modified Files: src/distrib/sets/lists/man: mi src/distrib/sets/lists/modules: mi src/share/man/man4: Makefile src/sys/dev/i2c: files.i2c src/sys/modules: Makefile Added Files: src/share/man/man4: sht4xtemp.4 src/sys/dev/i2c: sht4x.c sht4xreg.h sht4xvar.h src/sys/modules/sht4xtemp: Makefile sht4xtemp.ioconf Log Message: A driver for the Sensirion SHT40/SHT41/SHT45 temperature and humidity sensor. An example of this chip is: https://www.adafruit.com/product/4885 This is a lower cost chip that provides higher then usual precision according to the data sheet. This driver supports all of the published functions that the chip has. To generate a diff of this commit: cvs rdiff -u -r1.1725 -r1.1726 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.146 -r1.147 src/distrib/sets/lists/modules/mi cvs rdiff -u -r1.715 -r1.716 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/sht4xtemp.4 cvs rdiff -u -r1.116 -r1.117 src/sys/dev/i2c/files.i2c cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/sht4x.c src/sys/dev/i2c/sht4xreg.h \ src/sys/dev/i2c/sht4xvar.h cvs rdiff -u -r1.256 -r1.257 src/sys/modules/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/sht4xtemp/Makefile \ src/sys/modules/sht4xtemp/sht4xtemp.ioconf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: brad Date: Fri Oct 4 23:06:19 UTC 2019 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c Log Message: For ZFS on NetBSD there are a number of functions called zfs_netbsd_{create,mknod,link,etc..} that call functions called zfs_{create,mknod,link,etc..}. These later functions may return a error code along with a *vpp that is NULL. This situation was not handled by the zfs_netbsd_* functions and would result in a panic in a number of cases. The simplest to trigger it was filling up a dataset or pool resulting in a over quota condition. An attempt to create another file, or directory at that point would panic. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: brad Date: Fri Oct 4 23:06:19 UTC 2019 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c Log Message: For ZFS on NetBSD there are a number of functions called zfs_netbsd_{create,mknod,link,etc..} that call functions called zfs_{create,mknod,link,etc..}. These later functions may return a error code along with a *vpp that is NULL. This situation was not handled by the zfs_netbsd_* functions and would result in a panic in a number of cases. The simplest to trigger it was filling up a dataset or pool resulting in a over quota condition. An attempt to create another file, or directory at that point would panic. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.52 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.53 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.52 Sat Aug 24 12:59:05 2019 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Fri Oct 4 23:06:19 2019 @@ -5318,7 +5318,8 @@ zfs_netbsd_create(void *v) KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); if (error == 0) VN_KNOTE(dvp, NOTE_WRITE); - VOP_UNLOCK(*vpp, 0); + if (*vpp != NULL) + VOP_UNLOCK(*vpp, 0); return (error); } @@ -5358,7 +5359,8 @@ zfs_netbsd_mknod(void *v) KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); if (error == 0) VN_KNOTE(dvp, NOTE_WRITE); - VOP_UNLOCK(*vpp, 0); + if (*vpp != NULL) + VOP_UNLOCK(*vpp, 0); return (error); } @@ -5428,7 +5430,8 @@ zfs_netbsd_mkdir(void *v) KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); if (error == 0) VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK); - VOP_UNLOCK(*vpp, 0); + if (*vpp != NULL) + VOP_UNLOCK(*vpp, 0); return (error); } @@ -5717,7 +5720,8 @@ zfs_netbsd_symlink(void *v) VN_KNOTE(ap->a_dvp, NOTE_WRITE); KASSERT((error == 0) == (*vpp != NULL)); KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); - VOP_UNLOCK(*vpp, 0); + if (*vpp != NULL) + VOP_UNLOCK(*vpp, 0); return (error); }
CVS commit: src
Module Name:src Committed By: brad Date: Sun Sep 22 18:45:20 UTC 2019 Modified Files: src/distrib/sets/lists/base: shl.mi src/external/cddl/osnet/lib/libavl: Makefile src/external/cddl/osnet/lib/libnvpair: Makefile src/external/cddl/osnet/lib/libumem: Makefile src/external/cddl/osnet/lib/libuutil: Makefile src/external/cddl/osnet/lib/libzfs: Makefile src/external/cddl/osnet/lib/libzfs_core: Makefile src/external/cddl/osnet/lib/libzpool: Makefile src/lib/libpthread: Makefile Log Message: Add USE_SHLIBDIR=yes to a number of Makefiles for the libraries used by /sbin/{zfs,zpool,mount_zfs}. The general effect is to move them from /usr/lib to /lib. Compatibility links are installed in /usr/lib and nothing that is installed, say in /usr/pkg, appears to break. With this, it is possible to have a /var and /usr mount using ZFS legacy mounting early on in the boot process. Run tested on amd64 and i386 and compile tested on evbarm. To generate a diff of this commit: cvs rdiff -u -r1.870 -r1.871 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/libavl/Makefile cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/lib/libnvpair/Makefile cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/lib/libumem/Makefile cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/libuutil/Makefile cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/lib/libzfs/Makefile cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/lib/libzfs_core/Makefile cvs rdiff -u -r1.12 -r1.13 src/external/cddl/osnet/lib/libzpool/Makefile cvs rdiff -u -r1.94 -r1.95 src/lib/libpthread/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Sun Sep 22 18:45:20 UTC 2019 Modified Files: src/distrib/sets/lists/base: shl.mi src/external/cddl/osnet/lib/libavl: Makefile src/external/cddl/osnet/lib/libnvpair: Makefile src/external/cddl/osnet/lib/libumem: Makefile src/external/cddl/osnet/lib/libuutil: Makefile src/external/cddl/osnet/lib/libzfs: Makefile src/external/cddl/osnet/lib/libzfs_core: Makefile src/external/cddl/osnet/lib/libzpool: Makefile src/lib/libpthread: Makefile Log Message: Add USE_SHLIBDIR=yes to a number of Makefiles for the libraries used by /sbin/{zfs,zpool,mount_zfs}. The general effect is to move them from /usr/lib to /lib. Compatibility links are installed in /usr/lib and nothing that is installed, say in /usr/pkg, appears to break. With this, it is possible to have a /var and /usr mount using ZFS legacy mounting early on in the boot process. Run tested on amd64 and i386 and compile tested on evbarm. To generate a diff of this commit: cvs rdiff -u -r1.870 -r1.871 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/libavl/Makefile cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/lib/libnvpair/Makefile cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/lib/libumem/Makefile cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/libuutil/Makefile cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/lib/libzfs/Makefile cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/lib/libzfs_core/Makefile cvs rdiff -u -r1.12 -r1.13 src/external/cddl/osnet/lib/libzpool/Makefile cvs rdiff -u -r1.94 -r1.95 src/lib/libpthread/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.870 src/distrib/sets/lists/base/shl.mi:1.871 --- src/distrib/sets/lists/base/shl.mi:1.870 Fri Sep 6 11:12:06 2019 +++ src/distrib/sets/lists/base/shl.mi Sun Sep 22 18:45:19 2019 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.870 2019/09/06 11:12:06 christos Exp $ +# $NetBSD: shl.mi,v 1.871 2019/09/22 18:45:19 brad Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -13,6 +13,9 @@ # # Note: libtermcap and libtermlib are hardlinked and share the same version. # +./lib/libavl.so base-zfs-shlib dynamicroot,zfs +./lib/libavl.so.0base-zfs-shlib dynamicroot,zfs +./lib/libavl.so.0.0 base-zfs-shlib dynamicroot,zfs ./lib/libblacklist.sobase-sys-shlib dynamicroot ./lib/libblacklist.so.0base-sys-shlib dynamicroot ./lib/libblacklist.so.0.0 base-sys-shlib dynamicroot @@ -60,6 +63,9 @@ ./lib/libnpf.so base-npf-shlib dynamicroot,npf ./lib/libnpf.so.0base-npf-shlib dynamicroot,npf ./lib/libnpf.so.0.1base-npf-shlib dynamicroot,npf +./lib/libnvpair.sobase-zfs-shlib dynamicroot,zfs +./lib/libnvpair.so.0base-zfs-shlib dynamicroot,zfs +./lib/libnvpair.so.0.0base-zfs-shlib dynamicroot,zfs ./lib/libpcap.sobase-sys-shlib dynamicroot ./lib/libpcap.so.7base-sys-shlib dynamicroot ./lib/libpcap.so.7.0base-sys-shlib dynamicroot @@ -69,6 +75,9 @@ ./lib/libprop.sobase-sys-shlib dynamicroot ./lib/libprop.so.1base-sys-shlib dynamicroot ./lib/libprop.so.1.1base-sys-shlib dynamicroot +./lib/libpthread.sobase-sys-shlib dynamicroot +./lib/libpthread.so.1base-sys-shlib dynamicroot +./lib/libpthread.so.1.4base-sys-shlib dynamicroot ./lib/libradius.sobase-sys-shlib dynamicroot ./lib/libradius.so.4base-sys-shlib dynamicroot ./lib/libradius.so.4.0base-sys-shlib dynamicroot @@ -87,12 +96,27 @@ ./lib/libtermlib.sobase-sys-shlib dynamicroot ./lib/libtermlib.so.0base-sys-shlib dynamicroot ./lib/libtermlib.so.0.6base-sys-shlib dynamicroot +./lib/libumem.sobase-zfs-shlib dynamicroot,zfs +./lib/libumem.so.0base-zfs-shlib dynamicroot,zfs +./lib/libumem.so.0.0base-zfs-shlib dynamicroot,zfs ./lib/libutil.sobase-sys-shlib dynamicroot ./lib/libutil.so.7base-sys-shlib dynamicroot ./lib/libutil.so.7.24base-sys-shlib dynamicroot +./lib/libuutil.sobase-zfs-shlib dynamicroot,zfs +./lib/libuutil.so.0base-zfs-shlib dynamicroot,zfs +./lib/libuutil.so.0.0base-zfs-shlib dynamicroot,zfs ./lib/libz.so base-sys-shlib dynamicroot ./lib/libz.so.1 base-sys-shlib dynamicroot ./lib/libz.so.1.0base-sys-shlib dynamicroot +./lib/libzfs.so base-zfs-shlib dynamicroot,zfs +./lib/libzfs.so.0base-zfs-shlib dynamicroot,zfs +./lib/libzfs.so.0.0base-zfs-shlib dynamicroot,zfs +./lib/libzfs_core.sobase-zfs-shlib dynamicroot,zfs +./lib/libzfs_core.so.0base-zfs-shlib dynamicroot,zfs +./lib/libzfs_core.so.0.0 base-zfs-shlib dynamicroot,zfs +./lib/libzpool.sobase-zfs-shlib dynamicroot,zfs +./lib/libzpool.so.0
CVS commit: src/external/cddl/osnet/sbin/zfs
Module Name:src Committed By: brad Date: Fri Sep 20 22:38:28 UTC 2019 Modified Files: src/external/cddl/osnet/sbin/zfs: mount_zfs.8 Log Message: Add a copyright to the man page and a bit of history. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sbin/zfs/mount_zfs.8 diff -u src/external/cddl/osnet/sbin/zfs/mount_zfs.8:1.3 src/external/cddl/osnet/sbin/zfs/mount_zfs.8:1.4 --- src/external/cddl/osnet/sbin/zfs/mount_zfs.8:1.3 Mon Sep 16 04:57:12 2019 +++ src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Fri Sep 20 22:38:28 2019 @@ -1,5 +1,29 @@ -.\" $NetBSD: mount_zfs.8,v 1.3 2019/09/16 04:57:12 wiz Exp $ +.\" $NetBSD: mount_zfs.8,v 1.4 2019/09/20 22:38:28 brad Exp $ .\" +.\" Copyright (c) 2012, Martin Matuska . +.\" Copyright (c) 2013-2014, Xin Li . +.\" All Rights Reserved. +.\" +.\" The contents of this file are subject to the terms of the +.\" Common Development and Distribution License (the "License"). +.\" You may not use this file except in compliance with the License. +.\" +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +.\" or http://www.opensolaris.org/os/licensing. +.\" See the License for the specific language governing permissions +.\" and limitations under the License. +.\" +.\" When distributing Covered Code, include this CDDL HEADER in each +.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. +.\" If applicable, add the following below this CDDL HEADER, with the +.\" fields enclosed by brackets "[]" replaced with your own identifying +.\" information: Portions Copyright [] [name of copyright owner] +.\" +.\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2011, Nexenta Systems, Inc. All Rights Reserved. +.\" Copyright (c) 2011, Justin T. Gibbs +.\" Copyright (c) 2013 by Delphix. All Rights Reserved. +.\" Copyright (c) 2012, Glen Barber .\" .Dd September 15, 2019 .Dt MOUNT_ZFS 8 @@ -22,7 +46,7 @@ where the ZFS property is .Xr fstab 5 , .Xr zfs 8 .Sh HISTORY -The +A command to manage legacy ZFS mounts appeared in Solaris as /etc/fs/zfs/mount. The .Nm utility first appeared in .Nx 9.0 .
CVS commit: src/external/cddl/osnet/sbin/zfs
Module Name:src Committed By: brad Date: Fri Sep 20 22:38:28 UTC 2019 Modified Files: src/external/cddl/osnet/sbin/zfs: mount_zfs.8 Log Message: Add a copyright to the man page and a bit of history. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: brad Date: Sun Sep 15 19:38:09 UTC 2019 Modified Files: src/distrib/sets/lists/base: mi src/distrib/sets/lists/etc: mi src/distrib/sets/lists/man: mi src/etc/defaults: rc.conf src/etc/rc.d: Makefile mountall src/external/cddl/osnet/dist/cmd/zfs: zfs_main.c src/external/cddl/osnet/sbin/zfs: Makefile Added Files: src/etc/rc.d: zfs src/external/cddl/osnet/sbin/zfs: mount_zfs.8 Log Message: Add support for legacy ZFS filesystems, specified by mountpoint=legacy in the ZFS properties of the dataset and a simple man page for mount_zfs. With this, it is possible to put ZFS filesystems in /etc/fstab as file system type zfs. Add a rc.d script that kicks the module ZFS load mostly before mountall runs simular to what LVM does. This allows for any legacy mounts to be specified in critical_local_filesystems and allows for ZFS pools on top of cgd (probably among other things). Introduce a rc.conf variable called zfs which needs to be set to YES, in the usual manor of things, to get zvols and ZFS dataset support rather then just assume that 'zfs mount' does that in mountall. Fix a problem in mountall if ZFS is not compiled into the system. To generate a diff of this commit: cvs rdiff -u -r1.1216 -r1.1217 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.258 -r1.259 src/distrib/sets/lists/etc/mi cvs rdiff -u -r1.1651 -r1.1652 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.151 -r1.152 src/etc/defaults/rc.conf cvs rdiff -u -r1.104 -r1.105 src/etc/rc.d/Makefile cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/mountall cvs rdiff -u -r0 -r1.1 src/etc/rc.d/zfs cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/sbin/zfs/Makefile cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.1216 src/distrib/sets/lists/base/mi:1.1217 --- src/distrib/sets/lists/base/mi:1.1216 Sun Sep 8 21:04:31 2019 +++ src/distrib/sets/lists/base/mi Sun Sep 15 19:38:08 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1216 2019/09/08 21:04:31 roy Exp $ +# $NetBSD: mi,v 1.1217 2019/09/15 19:38:08 brad Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -569,6 +569,7 @@ ./sbin/mount_umapbase-miscfs-root ./sbin/mount_unionbase-miscfs-root ./sbin/mount_v7fsbase-sysutil-root +./sbin/mount_zfsbase-zfs-root zfs ./sbin/mountd base-obsolete obsolete ./sbin/newbtconfbase-sysutil-root ./sbin/newfs base-sysutil-root Index: src/distrib/sets/lists/etc/mi diff -u src/distrib/sets/lists/etc/mi:1.258 src/distrib/sets/lists/etc/mi:1.259 --- src/distrib/sets/lists/etc/mi:1.258 Sat May 11 19:31:03 2019 +++ src/distrib/sets/lists/etc/mi Sun Sep 15 19:38:08 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.258 2019/05/11 19:31:03 maxv Exp $ +# $NetBSD: mi,v 1.259 2019/09/15 19:38:08 brad Exp $ # # Note: end-user configuration files that are moved to another location # should not be marked "obsolete"; they should just be removed from @@ -323,6 +323,7 @@ ./etc/rc.d/yppasswddetc-nis-rc yp ./etc/rc.d/ypservetc-nis-rc yp ./etc/rc.d/ypsetetc-obsolete obsolete +./etc/rc.d/zfs etc-sys-rc zfs ./etc/rc.lkm etc-obsolete obsolete ./etc/rc.local etc-sys-rc ./etc/rc.shutdownetc-sys-rc Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1651 src/distrib/sets/lists/man/mi:1.1652 --- src/distrib/sets/lists/man/mi:1.1651 Fri Aug 30 08:54:58 2019 +++ src/distrib/sets/lists/man/mi Sun Sep 15 19:38:09 2019 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1651 2019/08/30 08:54:58 mrg Exp $ +# $NetBSD: mi,v 1.1652 2019/09/15 19:38:09 brad Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2794,6 +2794,7 @@ ./usr/share/man/cat8/mount_umap.0 man-miscfs-catman .cat ./usr/share/man/cat8/mount_union.0 man-miscfs-catman .cat ./usr/share/man/cat8/mount_v7fs.0 man-sysutil-catman .cat +./usr/share/man/cat8/mount_zfs.0 man-sysutil-catman .cat ./usr/share/man/cat8/mountd.0 man-nfsserver-catman .cat ./usr/share/man/cat8/moused.0 man-sysutil-catman .cat ./usr/share/man/cat8/mrinfo.0 man-netutil-catman .cat @@ -5759,6 +5760,7 @@ ./usr/share/man/html8/mount_umap.html man-miscfs-htmlman html ./usr/share/man/html8/mount_union.html man-miscfs-htmlman html ./usr/share/man/html8/mount_v7fs.html man-sysutil-htmlman html +./usr/share/man/html8/mount_zfs.html man-sysutil-htmlman html ./usr/share/man/html8/mountd.html man-nfsserver-htmlman html ./usr/share/man/html8/moused.html man-sysutil-htmlman html ./usr/share/man/html8/mrinfo.html man-netutil-htmlman html @@ -8906,6 +8908,7 @@
CVS commit: src
Module Name:src Committed By: brad Date: Sun Sep 15 19:38:09 UTC 2019 Modified Files: src/distrib/sets/lists/base: mi src/distrib/sets/lists/etc: mi src/distrib/sets/lists/man: mi src/etc/defaults: rc.conf src/etc/rc.d: Makefile mountall src/external/cddl/osnet/dist/cmd/zfs: zfs_main.c src/external/cddl/osnet/sbin/zfs: Makefile Added Files: src/etc/rc.d: zfs src/external/cddl/osnet/sbin/zfs: mount_zfs.8 Log Message: Add support for legacy ZFS filesystems, specified by mountpoint=legacy in the ZFS properties of the dataset and a simple man page for mount_zfs. With this, it is possible to put ZFS filesystems in /etc/fstab as file system type zfs. Add a rc.d script that kicks the module ZFS load mostly before mountall runs simular to what LVM does. This allows for any legacy mounts to be specified in critical_local_filesystems and allows for ZFS pools on top of cgd (probably among other things). Introduce a rc.conf variable called zfs which needs to be set to YES, in the usual manor of things, to get zvols and ZFS dataset support rather then just assume that 'zfs mount' does that in mountall. Fix a problem in mountall if ZFS is not compiled into the system. To generate a diff of this commit: cvs rdiff -u -r1.1216 -r1.1217 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.258 -r1.259 src/distrib/sets/lists/etc/mi cvs rdiff -u -r1.1651 -r1.1652 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.151 -r1.152 src/etc/defaults/rc.conf cvs rdiff -u -r1.104 -r1.105 src/etc/rc.d/Makefile cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/mountall cvs rdiff -u -r0 -r1.1 src/etc/rc.d/zfs cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/sbin/zfs/Makefile cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src
Sevan Janiyan writes: > On 03/09/2019 12:32, Robert Elz wrote: >> but doesn't macos have the ability to turn that off? > > Nope, it's set when you create the filesystem. :/ > > > Sevan One possible alternative to that is to install OpenZFS on MacOS and create a ZFS filesystem inside of whatever... (Install OpenZFS for your version of MacOS) dd if=/dev/zero of=/Users/bspencer/ZFSTEST/file1 bs=1048576 count=100 zpool create zfspool /Users/bspencer/ZFSTEST/file1 this will give you a new volume in /Volumes that will be case sensitive even if the outer filesystem isn't.. The big disadvantage is that you will have to preallocate the space, but this isn't too bad for building NetBSD, as those estimates are knowable. -- Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org
CVS commit: src/tests/fs/common
Module Name:src Committed By: brad Date: Fri Aug 30 23:45:13 UTC 2019 Modified Files: src/tests/fs/common: fstest_lfs.c Log Message: The cleaner is compiled into the ATF test harness for the LFS filesystem tests. Use the new -J option to pass the raw device into the cleaner. This avoids the not rump safe getdiskrawname call and makes sure we use an internal rump device name for cleaning. This should fix bin/54488. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/fs/common/fstest_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/common/fstest_lfs.c diff -u src/tests/fs/common/fstest_lfs.c:1.6 src/tests/fs/common/fstest_lfs.c:1.7 --- src/tests/fs/common/fstest_lfs.c:1.6 Sun Jan 20 14:50:58 2019 +++ src/tests/fs/common/fstest_lfs.c Fri Aug 30 23:45:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fstest_lfs.c,v 1.6 2019/01/20 14:50:58 gson Exp $ */ +/* $NetBSD: fstest_lfs.c,v 1.7 2019/08/30 23:45:13 brad Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -125,7 +125,7 @@ cleaner(void *arg) { char thepath[MAXPATHLEN]; struct lfstestargs *args = arg; - const char *the_argv[7]; + const char *the_argv[9]; char buf[64]; rump_pub_lwproc_newlwp(rump_sys_getpid()); @@ -139,14 +139,16 @@ cleaner(void *arg) the_argv[1] = "-D"; /* don't fork() & detach */ the_argv[2] = "-S"; the_argv[3] = buf; - the_argv[4] = args->ta_mntpath; - the_argv[5] = NULL; + the_argv[4] = "-J"; + the_argv[5] = thepath; + the_argv[6] = args->ta_mntpath; + the_argv[7] = NULL; /* xxxatf */ optind = 1; opterr = 1; - lfs_cleaner_main(5, __UNCONST(the_argv)); + lfs_cleaner_main(7, __UNCONST(the_argv)); rump_pub_lwproc_releaselwp();
CVS commit: src/tests/fs/common
Module Name:src Committed By: brad Date: Fri Aug 30 23:45:13 UTC 2019 Modified Files: src/tests/fs/common: fstest_lfs.c Log Message: The cleaner is compiled into the ATF test harness for the LFS filesystem tests. Use the new -J option to pass the raw device into the cleaner. This avoids the not rump safe getdiskrawname call and makes sure we use an internal rump device name for cleaning. This should fix bin/54488. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/fs/common/fstest_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/puffs/rump_lfs
Module Name:src Committed By: brad Date: Fri Aug 30 23:41:48 UTC 2019 Modified Files: src/usr.sbin/puffs/rump_lfs: rump_lfs.c Log Message: The cleaner is compiled into rump_lfs and executed as a thread. Pass in the raw device using the new -J option. This avoids the use of getdiskrawname which is not particularly rump safe in this context and insures that the rump container device is used for cleaning, not the outer device. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/puffs/rump_lfs/rump_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/puffs/rump_lfs/rump_lfs.c diff -u src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.18 src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.19 --- src/usr.sbin/puffs/rump_lfs/rump_lfs.c:1.18 Sun Aug 2 18:11:57 2015 +++ src/usr.sbin/puffs/rump_lfs/rump_lfs.c Fri Aug 30 23:41:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_lfs.c,v 1.18 2015/08/02 18:11:57 dholland Exp $ */ +/* $NetBSD: rump_lfs.c,v 1.19 2019/08/30 23:41:48 brad Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -43,16 +43,20 @@ #include "mount_lfs.h" +#define RUMPRAWDEVICE "/dev/rrumpy0" + static void * cleaner(void *arg) { - const char *the_argv[7]; + const char *the_argv[9]; the_argv[0] = "megamaid"; the_argv[1] = "-D"; /* don't fork() & detach */ - the_argv[2] = arg; + the_argv[2] = "-J"; /* treat arg as a device */ + the_argv[3] = RUMPRAWDEVICE; + the_argv[4] = arg; - lfs_cleaner_main(3, __UNCONST(the_argv)); + lfs_cleaner_main(5, __UNCONST(the_argv)); return NULL; } @@ -93,7 +97,7 @@ main(int argc, char *argv[]) * XXX: this particular piece inspired by the cleaner code. * obviously FIXXXME along with the cleaner. */ - sprintf(rawdev, "/dev/r%s", canon_dev+5); + strlcpy(rawdev, RUMPRAWDEVICE, MAXPATHLEN); rump_pub_etfs_register(rawdev, canon_dev, RUMP_ETFS_CHR); /*
CVS commit: src/usr.sbin/puffs/rump_lfs
Module Name:src Committed By: brad Date: Fri Aug 30 23:41:48 UTC 2019 Modified Files: src/usr.sbin/puffs/rump_lfs: rump_lfs.c Log Message: The cleaner is compiled into rump_lfs and executed as a thread. Pass in the raw device using the new -J option. This avoids the use of getdiskrawname which is not particularly rump safe in this context and insures that the rump container device is used for cleaning, not the outer device. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/puffs/rump_lfs/rump_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/lfs_cleanerd
Module Name:src Committed By: brad Date: Fri Aug 30 23:37:23 UTC 2019 Modified Files: src/libexec/lfs_cleanerd: lfs_cleanerd.8 lfs_cleanerd.c Log Message: Add support for passing the raw device name separate from the filesystem. This is useful in the case where the cleaner is compiled into code, such as rump_lfs and the ATF tests. This helps to fix bin/54488 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/libexec/lfs_cleanerd/lfs_cleanerd.8 cvs rdiff -u -r1.59 -r1.60 src/libexec/lfs_cleanerd/lfs_cleanerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/lfs_cleanerd/lfs_cleanerd.8 diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.8:1.18 src/libexec/lfs_cleanerd/lfs_cleanerd.8:1.19 --- src/libexec/lfs_cleanerd/lfs_cleanerd.8:1.18 Thu Aug 6 21:18:54 2009 +++ src/libexec/lfs_cleanerd/lfs_cleanerd.8 Fri Aug 30 23:37:23 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: lfs_cleanerd.8,v 1.18 2009/08/06 21:18:54 wiz Exp $ +.\" $NetBSD: lfs_cleanerd.8,v 1.19 2019/08/30 23:37:23 brad Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -39,9 +39,11 @@ .Nm .Op Fl bcDdfmqs .Op Fl i Ar segment-number +.Op Fl J Ar raw-device .Op Fl l Ar load-threshhold .Op Fl n Ar number-of-segments .Op Fl r Ar report-frequency +.Op Fl S Ar semaphore-address .Op Fl t Ar timeout .Pa node .Sh DESCRIPTION @@ -94,6 +96,12 @@ Invalidate the segment with segment numb This option is used by .Xr resize_lfs 8 , and should not be specified on the command line. +.It Fl J Ar raw device +Specify the raw device that the cleaner is to work against rather than +trying to figure it out from the mount point. This is mostly useful +when the cleaner is compiled into +.Xr rump_lfs 8 , +and the ATF test framework. .It Fl l Ar load-threshhold Clean more aggressively when the system load is below the given threshhold. The default threshhold is 0.2. @@ -112,6 +120,13 @@ Quit after cleaning once. Give an efficiency report after every .Ar report-frequency times through the main loop. +.It Fl S Ar semaphore address +When the cleaner code is compiled into +.Xr rump_lfs 8 , +and the ATF frame work, this option allows for a synchronization +semaphore to be specified. This option is not available in the +stand alone +.Xr lfs_cleanerd 8 . .It Fl s When cleaning the file system, send only a few blocks through lfs_markv at a time. @@ -132,7 +147,8 @@ to a low value. .Xr lfs_bmapv 2 , .Xr lfs_markv 2 , .Xr lfs_segwait 2 , -.Xr mount_lfs 8 +.Xr mount_lfs 8 , +.Xr rump_lfs 8 . .Sh HISTORY The .Nm Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.59 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.60 --- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.59 Thu Aug 22 20:28:08 2019 +++ src/libexec/lfs_cleanerd/lfs_cleanerd.c Fri Aug 30 23:37:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_cleanerd.c,v 1.59 2019/08/22 20:28:08 brad Exp $ */ +/* $NetBSD: lfs_cleanerd.c,v 1.60 2019/08/30 23:37:23 brad Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -76,6 +76,7 @@ int segwait_timeout; /* Time to wait in int do_quit; /* Quit after one cleaning loop */ int do_coalesce; /* Coalesce filesystem */ int do_small; /* Use small writes through markv */ +char *do_asdevice; /* Use this as the raw device */ char *copylog_filename; /* File to use for fs debugging analysis */ int inval_segment; /* Segment to invalidate */ int stat_report; /* Report statistics for this period of cycles */ @@ -165,7 +166,7 @@ init_unmounted_fs(struct clfs *fs, char { struct lfs *disc_fs; int i; - + fs->clfs_dev = fsname; if ((fs->clfs_devfd = kops.ko_open(fs->clfs_dev, O_RDWR)) < 0) { syslog(LOG_ERR, "couldn't open device %s read/write", @@ -215,26 +216,34 @@ init_fs(struct clfs *fs, char *fsname) void *sbuf; size_t mlen; - /* - * Get the raw device from the block device. - * XXX this is ugly. Is there a way to discover the raw device - * XXX for a given mount point? - */ - if (kops.ko_statvfs(fsname, , ST_WAIT) < 0) - return -1; - mlen = strlen(sf.f_mntfromname) + 2; - fs->clfs_dev = malloc(mlen); - if (fs->clfs_dev == NULL) { - syslog(LOG_ERR, "couldn't malloc device name string: %m"); - return -1; - } - if (getdiskrawname(fs->clfs_dev, mlen, sf.f_mntfromname) == NULL) { - syslog(LOG_ERR, "couldn't convert '%s' ro raw name: %m", - sf.f_mntfromname); - return -1; + if (do_asdevice != NULL) { + fs->clfs_dev = strndup(do_asdevice,strlen(do_asdevice) + 2); + if (fs->clfs_dev == NULL) { + syslog(LOG_ERR, "couldn't malloc device name string: %m"); + return -1; + } + } else { + /* + * Get the raw device from the block device. + * XXX this is ugly. Is there a way to discover the raw device + * XXX for a given mount point? + */ + if (kops.ko_statvfs(fsname, , ST_WAIT) < 0) + return -1; +
CVS commit: src/libexec/lfs_cleanerd
Module Name:src Committed By: brad Date: Fri Aug 30 23:37:23 UTC 2019 Modified Files: src/libexec/lfs_cleanerd: lfs_cleanerd.8 lfs_cleanerd.c Log Message: Add support for passing the raw device name separate from the filesystem. This is useful in the case where the cleaner is compiled into code, such as rump_lfs and the ATF tests. This helps to fix bin/54488 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/libexec/lfs_cleanerd/lfs_cleanerd.8 cvs rdiff -u -r1.59 -r1.60 src/libexec/lfs_cleanerd/lfs_cleanerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/lfs_cleanerd
Module Name:src Committed By: brad Date: Thu Aug 22 20:28:08 UTC 2019 Modified Files: src/libexec/lfs_cleanerd: lfs_cleanerd.c Log Message: Use getdiskrawname to find the device name Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/libexec/lfs_cleanerd/lfs_cleanerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/lfs_cleanerd
Module Name:src Committed By: brad Date: Thu Aug 22 20:28:08 UTC 2019 Modified Files: src/libexec/lfs_cleanerd: lfs_cleanerd.c Log Message: Use getdiskrawname to find the device name Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/libexec/lfs_cleanerd/lfs_cleanerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.58 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.59 --- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.58 Fri Mar 18 10:10:21 2016 +++ src/libexec/lfs_cleanerd/lfs_cleanerd.c Thu Aug 22 20:28:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_cleanerd.c,v 1.58 2016/03/18 10:10:21 mrg Exp $ */ +/* $NetBSD: lfs_cleanerd.c,v 1.59 2019/08/22 20:28:08 brad Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -213,7 +213,7 @@ init_fs(struct clfs *fs, char *fsname) int rootfd; int i; void *sbuf; - char *bn; + size_t mlen; /* * Get the raw device from the block device. @@ -222,16 +222,17 @@ init_fs(struct clfs *fs, char *fsname) */ if (kops.ko_statvfs(fsname, , ST_WAIT) < 0) return -1; - fs->clfs_dev = malloc(strlen(sf.f_mntfromname) + 2); + mlen = strlen(sf.f_mntfromname) + 2; + fs->clfs_dev = malloc(mlen); if (fs->clfs_dev == NULL) { syslog(LOG_ERR, "couldn't malloc device name string: %m"); return -1; } - bn = strrchr(sf.f_mntfromname, '/'); - bn = bn ? bn+1 : sf.f_mntfromname; - strlcpy(fs->clfs_dev, sf.f_mntfromname, bn - sf.f_mntfromname + 1); - strcat(fs->clfs_dev, "r"); - strcat(fs->clfs_dev, bn); + if (getdiskrawname(fs->clfs_dev, mlen, sf.f_mntfromname) == NULL) { + syslog(LOG_ERR, "couldn't convert '%s' ro raw name: %m", + sf.f_mntfromname); + return -1; + } if ((fs->clfs_devfd = kops.ko_open(fs->clfs_dev, O_RDONLY, 0)) < 0) { syslog(LOG_ERR, "couldn't open device %s for reading", fs->clfs_dev);
CVS commit: src/lib/libutil
Module Name:src Committed By: brad Date: Thu Aug 22 20:23:43 UTC 2019 Modified Files: src/lib/libutil: getdiskrawname.c Log Message: Teach getdiskrawname and getdiskcookedname about zvols. Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/getdiskrawname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libutil/getdiskrawname.c diff -u src/lib/libutil/getdiskrawname.c:1.5 src/lib/libutil/getdiskrawname.c:1.6 --- src/lib/libutil/getdiskrawname.c:1.5 Wed Sep 17 23:54:42 2014 +++ src/lib/libutil/getdiskrawname.c Thu Aug 22 20:23:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: getdiskrawname.c,v 1.5 2014/09/17 23:54:42 christos Exp $ */ +/* $NetBSD: getdiskrawname.c,v 1.6 2019/08/22 20:23:43 brad Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: getdiskrawname.c,v 1.5 2014/09/17 23:54:42 christos Exp $"); +__RCSID("$NetBSD: getdiskrawname.c,v 1.6 2019/08/22 20:23:43 brad Exp $"); #include @@ -70,10 +70,74 @@ resolve_link(char *buf, size_t bufsiz, c return buf; } +/* + * zvol device names look like: + * /dev/zvol/dsk/pool_name/.../volume_name + * /dev/zvol/rdsk/pool_name/.../volume_name + * + * ZFS pools can be divided nearly to infinity + * + * This allows for 16 pool names, which one would hope would be enough + */ +#define DISKMAXPARTS 20 +static int +calc_zvol_name(char *buf, size_t bufsiz, const char *name, const char *raw) +{ + char copyname[PATH_MAX]; + char *names[DISKMAXPARTS]; + char *last, *p; + size_t i = 0; + + strlcpy(copyname, name, sizeof(copyname)); + for (p = strtok_r(copyname, "/", ); p; + p = strtok_r(NULL, "/", )) { + if (i >= DISKMAXPARTS) { + errno = ENOSPC; + return -1; + } + names[i++] = p; + } + + if (i < 4) { + errno = EINVAL; + return -1; + } + + snprintf(buf, bufsiz, "/dev/zvol/%sdsk", raw); + for (size_t j = 3; j < i; j++) { + strlcat(buf, "/", bufsiz); + strlcat(buf, names[j], bufsiz); + } + return 0; +} + +static int +calc_name(char *buf, size_t bufsiz, const char *name, const char *raw) +{ + int skip = 1; + + if (strncmp("/dev/zvol/", name, 10) == 0) + return calc_zvol_name(buf, bufsiz, name, raw); + + const char *dp = strrchr(name, '/'); + if (!*raw && ((dp != NULL && dp[1] != 'r') + || (dp == NULL && name[0] != 'r'))) { + errno = EINVAL; + return -1; + } + if (raw[0] != 'r') + skip = 2; + if (dp != NULL) + snprintf(buf, bufsiz, "%.*s/%s%s", (int)(dp - name), + name, raw, dp + skip); + else + snprintf(buf, bufsiz, "%s%s", raw, name); + return 0; +} + const char * getdiskrawname(char *buf, size_t bufsiz, const char *name) { - const char *dp; struct stat st; char dest[PATH_MAX]; @@ -82,8 +146,6 @@ getdiskrawname(char *buf, size_t bufsiz, return NULL; } - dp = strrchr(name, '/'); - if (stat(name, ) == -1) return NULL; @@ -92,10 +154,8 @@ getdiskrawname(char *buf, size_t bufsiz, return NULL; } - if (dp != NULL) - (void)snprintf(buf, bufsiz, "%.*s/r%s", (int)(dp - name), name, dp + 1); - else - (void)snprintf(buf, bufsiz, "r%s", name); + if (calc_name(buf, bufsiz, name, "r") == -1) + return NULL; return buf; } @@ -103,7 +163,6 @@ getdiskrawname(char *buf, size_t bufsiz, const char * getdiskcookedname(char *buf, size_t bufsiz, const char *name) { - const char *dp; struct stat st; char dest[PATH_MAX]; @@ -112,13 +171,6 @@ getdiskcookedname(char *buf, size_t bufs return NULL; } - dp = strrchr(name, '/'); - - if ((dp != NULL && dp[1] != 'r') || (dp == NULL && name[0] != 'r')) { - errno = EINVAL; - return NULL; - } - if (stat(name, ) == -1) return NULL; @@ -127,10 +179,8 @@ getdiskcookedname(char *buf, size_t bufs return NULL; } - if (dp != NULL) - (void)snprintf(buf, bufsiz, "%.*s/%s", (int)(dp - name), name, dp + 2); - else - (void)snprintf(buf, bufsiz, "%s", name + 1); + if (calc_name(buf, bufsiz, name, "") == -1) + return NULL; return buf; }
CVS commit: src/lib/libutil
Module Name:src Committed By: brad Date: Thu Aug 22 20:23:43 UTC 2019 Modified Files: src/lib/libutil: getdiskrawname.c Log Message: Teach getdiskrawname and getdiskcookedname about zvols. Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/getdiskrawname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/resize_lfs
Module Name:src Committed By: brad Date: Thu Aug 22 20:26:07 UTC 2019 Modified Files: src/sbin/resize_lfs: resize_lfs.c Log Message: Use getdiskrawname to find the device name. Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sbin/resize_lfs/resize_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/resize_lfs/resize_lfs.c diff -u src/sbin/resize_lfs/resize_lfs.c:1.14 src/sbin/resize_lfs/resize_lfs.c:1.15 --- src/sbin/resize_lfs/resize_lfs.c:1.14 Sun Aug 2 18:18:09 2015 +++ src/sbin/resize_lfs/resize_lfs.c Thu Aug 22 20:26:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: resize_lfs.c,v 1.14 2015/08/02 18:18:09 dholland Exp $ */ +/* $NetBSD: resize_lfs.c,v 1.15 2019/08/22 20:26:07 brad Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. * All rights reserved. @@ -47,6 +47,7 @@ #include #include #include +#include #include "partutil.h" @@ -98,7 +99,8 @@ main(int argc, char **argv) err(1, "%s", fsname); rdevlen = strlen(vfs.f_mntfromname) + 2; rdev = malloc(rdevlen); - snprintf(rdev, rdevlen, "/dev/r%s", vfs.f_mntfromname + 5); + if (getdiskrawname(rdev, rdevlen, vfs.f_mntfromname) == NULL) + err(1, "Could not convert '%s' to raw name", vfs.f_mntfromname); devfd = open(rdev, O_RDONLY); if (devfd < 0) err(1, "open raw device");
CVS commit: src/sbin/resize_lfs
Module Name:src Committed By: brad Date: Thu Aug 22 20:26:07 UTC 2019 Modified Files: src/sbin/resize_lfs: resize_lfs.c Log Message: Use getdiskrawname to find the device name. Reviewed by Christos To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sbin/resize_lfs/resize_lfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.