Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/landisk/dev Migrate btn_init() from btnopen() (with...



details:   https://anonhg.NetBSD.org/src/rev/8597081a9f98
branches:  trunk
changeset: 1022378:8597081a9f98
user:      rin <rin%NetBSD.org@localhost>
date:      Thu Jul 15 05:07:50 2021 +0000

description:
Migrate btn_init() from btnopen() (with RUN_ONCE) to btn_obio_attach().

Fix uninitialized use of btn_event_list_lock in btn_event_register().

Found by LOCKDEBUG.

diffstat:

 sys/arch/landisk/dev/btn_obio.c  |   5 +++--
 sys/arch/landisk/dev/button.c    |  12 +++---------
 sys/arch/landisk/dev/buttonvar.h |   4 +++-
 3 files changed, 9 insertions(+), 12 deletions(-)

diffs (91 lines):

diff -r 8cac8c8f73c9 -r 8597081a9f98 sys/arch/landisk/dev/btn_obio.c
--- a/sys/arch/landisk/dev/btn_obio.c   Thu Jul 15 04:58:33 2021 +0000
+++ b/sys/arch/landisk/dev/btn_obio.c   Thu Jul 15 05:07:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: btn_obio.c,v 1.6 2012/01/21 19:44:29 nonaka Exp $      */
+/*     $NetBSD: btn_obio.c,v 1.7 2021/07/15 05:07:50 rin Exp $ */
 
 /*-
  * Copyright (C) 2005 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -28,7 +28,7 @@
 #include "pwrsw_obio.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btn_obio.c,v 1.6 2012/01/21 19:44:29 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btn_obio.c,v 1.7 2021/07/15 05:07:50 rin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -141,6 +141,7 @@
        }
        sc->sc_mask |= BTN_RESET_BIT;
 
+       btn_init();
        for (i = 0; i < NBUTTON; i++) {
                int idx = btnlist[i].idx;
                sc->sc_bev[idx].bev_name = btnlist[i].name;
diff -r 8cac8c8f73c9 -r 8597081a9f98 sys/arch/landisk/dev/button.c
--- a/sys/arch/landisk/dev/button.c     Thu Jul 15 04:58:33 2021 +0000
+++ b/sys/arch/landisk/dev/button.c     Thu Jul 15 05:07:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: button.c,v 1.10 2020/12/19 21:25:03 thorpej Exp $      */
+/*     $NetBSD: button.c,v 1.11 2021/07/15 05:07:50 rin Exp $  */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.10 2020/12/19 21:25:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.11 2021/07/15 05:07:50 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -59,7 +59,6 @@
 /*
  * event handler
  */
-static ONCE_DECL(btn_once);
 static LIST_HEAD(, btn_event) btn_event_list;
 static kmutex_t btn_event_list_lock;
 
@@ -105,7 +104,7 @@
        .d_flag = 0
 };
 
-static int
+int
 btn_init(void)
 {
 
@@ -161,11 +160,6 @@
 {
        int error;
 
-       error = RUN_ONCE(&btn_once, btn_init);
-       if (error) {
-               return error;
-       }
-
        if (minor(dev) != 0) {
                return (ENODEV);
        }
diff -r 8cac8c8f73c9 -r 8597081a9f98 sys/arch/landisk/dev/buttonvar.h
--- a/sys/arch/landisk/dev/buttonvar.h  Thu Jul 15 04:58:33 2021 +0000
+++ b/sys/arch/landisk/dev/buttonvar.h  Thu Jul 15 05:07:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buttonvar.h,v 1.1 2006/09/01 21:26:18 uwe Exp $        */
+/*     $NetBSD: buttonvar.h,v 1.2 2021/07/15 05:07:50 rin Exp $        */
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -45,6 +45,8 @@
        LIST_ENTRY(btn_event) bev_list;
 };
 
+int    btn_init(void);
+
 void   btn_settype(const char *type);
 
 int    btn_event_register(struct btn_event *bev);



Home | Main Index | Thread Index | Old Index