From bc624321dc358b2d0fb1436533ece68e6422764c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Sep 2024 16:26:20 -0600 Subject: dm: usb: Deal with USB keyboard persisting across tests Clear any USB-keyboard devices before running a unit test, to avoid using a stale udevice pointer in stdio. Add a long comment to explain this situation and why this solution seems best, at least for now. Signed-off-by: Simon Glass --- common/usb_kbd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common/usb_kbd.c') diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 1d9845b01ed..bbfee23bc26 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -137,6 +137,11 @@ extern int __maybe_unused net_busy_flag; /* The period of time between two calls of usb_kbd_testc(). */ static unsigned long kbd_testc_tms; +int usb_kbd_remove_for_test(void) +{ + return console_remove_by_name(DEVNAME); +} + /* Puts character in the queue and sets up the in and out pointer. */ static void usb_kbd_put_queue(struct usb_kbd_pdata *data, u8 c) { -- cgit v1.2.3