usb: skip reporting of incomplete init. usb device

Fixes #3944
This commit is contained in:
Alexander Boettcher 2020-11-11 10:54:09 +01:00 committed by Christian Helmuth
parent 4e90dc4512
commit fae3c12366
2 changed files with 28 additions and 6 deletions

View File

@ -107,6 +107,13 @@ struct Device : List<Device>::Element
{
return &iface->altsetting[alt_setting].endpoint[endpoint_num];
}
Session_label label()
{
if (!udev || !udev->bus)
return Session_label("usb-unknown");
return Session_label("usb-", udev->bus->busnum, "-", udev->devnum);
}
};
@ -1030,6 +1037,13 @@ void Device::report_device_list()
{
for (Device *d = list()->first(); d; d = d->next()) {
usb_interface *iface = d->interface(0);
if (!iface || !iface->cur_altsetting || !d->udev || !d->udev->bus) {
Genode::warning("device ", d->label().string(), " state incomplete");
continue;
}
xml.node("device", [&] ()
{
char buf[16];
@ -1037,8 +1051,7 @@ void Device::report_device_list()
unsigned const bus = d->udev->bus->busnum;
unsigned const dev = d->udev->devnum;
Genode::snprintf(buf, sizeof(buf), "usb-%d-%d", bus, dev);
xml.attribute("label", buf);
xml.attribute("label", d->label().string());
Genode::snprintf(buf, sizeof(buf), "0x%4x",
d->udev->descriptor.idVendor);
@ -1054,7 +1067,6 @@ void Device::report_device_list()
Genode::snprintf(buf, sizeof(buf), "0x%4x", dev);
xml.attribute("dev", buf);
usb_interface *iface = d->interface(0);
Genode::snprintf(buf, sizeof(buf), "0x%02x",
iface->cur_altsetting->desc.bInterfaceClass);
xml.attribute("class", buf);

View File

@ -119,8 +119,12 @@ struct Device : List<Device>::Element
return &iface->altsetting[alt_setting].endpoint[endpoint_num];
}
Session_label label() {
return Session_label("usb-", udev->bus->busnum, "-", udev->devnum); }
Session_label label()
{
if (!udev || !udev->bus)
return Session_label("usb-unknown");
return Session_label("usb-", udev->bus->busnum, "-", udev->devnum);
}
};
@ -1060,6 +1064,13 @@ void Device::report_device_list()
{
for (Device *d = list()->first(); d; d = d->next()) {
usb_interface *iface = d->interface(0);
if (!iface || !iface->cur_altsetting || !d->udev || !d->udev->bus) {
Genode::warning("device ", d->label().string(), " state incomplete");
continue;
}
xml.node("device", [&] ()
{
char buf[16];
@ -1083,7 +1094,6 @@ void Device::report_device_list()
Genode::snprintf(buf, sizeof(buf), "0x%4x", dev);
xml.attribute("dev", buf);
usb_interface *iface = d->interface(0);
Genode::snprintf(buf, sizeof(buf), "0x%02x",
iface->cur_altsetting->desc.bInterfaceClass);
xml.attribute("class", buf);