Module Name:    src
Committed By:   bouyer
Date:           Wed Sep 26 09:06:48 UTC 2018

Modified Files:
        src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Don't call ukbd_cnattach() unconditionally, this causes a non-functionnal
keyboard if there is a framebuffer but the console is serial only.
Instead add a fdt_device_register_post_config() callback, which checks
if the just-attached wsdisplay is the console, and calls ukbd_cnattach()
in this case.
OK jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/evbarm/fdt/fdt_machdep.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/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.38 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.39
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.38	Sat Sep 22 11:58:19 2018
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Wed Sep 26 09:06:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.38 2018/09/22 11:58:19 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.39 2018/09/26 09:06:48 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.38 2018/09/22 11:58:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.39 2018/09/26 09:06:48 bouyer Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep.
 #include "opt_cpuoptions.h"
 
 #include "ukbd.h"
+#include "wsdisplay.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,6 +85,9 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep.
 #if NUKBD > 0
 #include <dev/usb/ukbdvar.h>
 #endif
+#if NWSDISPLAY > 0
+#include <dev/wscons/wsdisplayvar.h>
+#endif
 
 #ifdef MEMORY_DISK_DYNAMIC
 #include <dev/md.h>
@@ -116,6 +120,7 @@ extern char KERNEL_BASE_phys[];
 
 static void fdt_update_stdout_path(void);
 static void fdt_device_register(device_t, void *);
+static void fdt_device_register_post_config(device_t, void *);
 static void fdt_cpu_rootconf(void);
 static void fdt_reset(void);
 static void fdt_powerdown(void);
@@ -428,6 +433,7 @@ initarm(void *arg)
 	cpu_reset_address = fdt_reset;
 	cpu_powerdown_address = fdt_powerdown;
 	evbarm_device_register = fdt_device_register;
+	evbarm_device_register_post_config = fdt_device_register_post_config;
 	evbarm_cpu_rootconf = fdt_cpu_rootconf;
 
 	/* Talk to the user */
@@ -541,10 +547,6 @@ consinit(void)
 
 	cons->consinit(&faa, uart_freq);
 
-#if NUKBD > 0
-	ukbd_cnattach();	/* allow USB keyboard to become console */
-#endif
-
 	initialized = true;
 }
 
@@ -626,6 +628,18 @@ fdt_device_register(device_t self, void 
 }
 
 static void
+fdt_device_register_post_config(device_t self, void *aux)
+{
+#if NUKBD > 0 && NWSDISPLAY > 0
+	if (device_is_a(self, "wsdisplay")) {
+		struct wsdisplay_softc *sc = device_private(self);
+		if (wsdisplay_isconsole(sc))
+			ukbd_cnattach();
+	}
+#endif
+}
+
+static void
 fdt_cpu_rootconf(void)
 {
 	device_t dev;

Reply via email to