mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
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 <sjg@chromium.org>
This commit is contained in:
parent
010c449263
commit
bc624321dc
5 changed files with 97 additions and 0 deletions
|
@ -1243,3 +1243,37 @@ int console_init_r(void)
|
|||
}
|
||||
|
||||
#endif /* CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
|
||||
|
||||
int console_remove_by_name(const char *name)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#if CONFIG_IS_ENABLED(CONSOLE_MUX)
|
||||
int fnum;
|
||||
|
||||
log_debug("removing console device %s\n", name);
|
||||
for (fnum = 0; fnum < MAX_FILES; fnum++) {
|
||||
struct stdio_dev **src, **dest;
|
||||
int i;
|
||||
|
||||
log_debug("file %d: %d devices: ", fnum, cd_count[fnum]);
|
||||
src = console_devices[fnum];
|
||||
dest = src;
|
||||
for (i = 0; i < cd_count[fnum]; i++, src++) {
|
||||
struct stdio_dev *sdev = *src;
|
||||
int ret = 0;
|
||||
|
||||
if (!strcmp(sdev->name, name))
|
||||
ret = stdio_deregister_dev(sdev, true);
|
||||
else
|
||||
*dest++ = *src;
|
||||
if (ret && !err)
|
||||
err = ret;
|
||||
}
|
||||
cd_count[fnum] = dest - console_devices[fnum];
|
||||
log_debug("now %d\n", cd_count[fnum]);
|
||||
}
|
||||
#endif /* CONSOLE_MUX */
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue