diff --git a/sys/dev/gpio/gpioc.c b/sys/dev/gpio/gpioc.c --- a/sys/dev/gpio/gpioc.c +++ b/sys/dev/gpio/gpioc.c @@ -677,19 +677,18 @@ gpioc_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct gpioc_cdevpriv *priv; - int err; + int err = 0; priv = malloc(sizeof(*priv), M_GPIOC, M_WAITOK | M_ZERO); priv->sc = dev->si_drv1; - priv->report_option = GPIO_EVENT_REPORT_DETAIL; - err = devfs_set_cdevpriv(priv, gpioc_cdevpriv_dtor); - if (err != 0) { - gpioc_cdevpriv_dtor(priv); - return (err); - } + mtx_init(&priv->mtx, "gpioc priv", NULL, MTX_DEF); knlist_init_mtx(&priv->selinfo.si_note, &priv->mtx); + priv->async = false; + priv->report_option = GPIO_EVENT_REPORT_DETAIL; + priv->sigio = NULL; + /* * Allocate a circular buffer for events. The scheme we use for summary * reporting assumes there will always be a pair of events available to @@ -701,7 +700,13 @@ priv->events = malloc(priv->numevents * sizeof(struct gpio_event_detail), M_GPIOC, M_WAITOK | M_ZERO); - return (0); + priv->evidx_head = priv->evidx_tail = 0; + SLIST_INIT(&priv->pins); + + err = devfs_set_cdevpriv(priv, gpioc_cdevpriv_dtor); + if (err != 0) + gpioc_cdevpriv_dtor(priv); + return (err); } static int