mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
Add get_fw_dev_path callback for usb bus.
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
ab28ccc0c6
commit
cdedd00613
1 changed files with 42 additions and 0 deletions
42
hw/usb-bus.c
42
hw/usb-bus.c
|
@ -5,11 +5,13 @@
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
|
||||||
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
|
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
|
||||||
|
static char *usbbus_get_fw_dev_path(DeviceState *dev);
|
||||||
|
|
||||||
static struct BusInfo usb_bus_info = {
|
static struct BusInfo usb_bus_info = {
|
||||||
.name = "USB",
|
.name = "USB",
|
||||||
.size = sizeof(USBBus),
|
.size = sizeof(USBBus),
|
||||||
.print_dev = usb_bus_dev_print,
|
.print_dev = usb_bus_dev_print,
|
||||||
|
.get_fw_dev_path = usbbus_get_fw_dev_path,
|
||||||
};
|
};
|
||||||
static int next_usb_bus = 0;
|
static int next_usb_bus = 0;
|
||||||
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
|
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
|
||||||
|
@ -307,3 +309,43 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||||
}
|
}
|
||||||
return usb->usbdevice_init(params);
|
return usb->usbdevice_init(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p,
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
int l = 0;
|
||||||
|
USBPort *port;
|
||||||
|
|
||||||
|
QTAILQ_FOREACH(port, &bus->used, next) {
|
||||||
|
if (port->dev == d) {
|
||||||
|
if (port->pdev) {
|
||||||
|
l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len);
|
||||||
|
}
|
||||||
|
l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev),
|
||||||
|
port->index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *usbbus_get_fw_dev_path(DeviceState *dev)
|
||||||
|
{
|
||||||
|
USBDevice *d = (USBDevice*)dev;
|
||||||
|
USBBus *bus = usb_bus_from_device(d);
|
||||||
|
char path[100];
|
||||||
|
int l;
|
||||||
|
|
||||||
|
assert(d->attached != 0);
|
||||||
|
|
||||||
|
l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path));
|
||||||
|
|
||||||
|
if (l == 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
path[l-1] = '\0';
|
||||||
|
|
||||||
|
return strdup(path);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue