Revision cdedd006 hw/usb-bus.c
b/hw/usb-bus.c | ||
---|---|---|
5 | 5 |
#include "monitor.h" |
6 | 6 |
|
7 | 7 |
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); |
8 |
static char *usbbus_get_fw_dev_path(DeviceState *dev); |
|
8 | 9 |
|
9 | 10 |
static struct BusInfo usb_bus_info = { |
10 | 11 |
.name = "USB", |
11 | 12 |
.size = sizeof(USBBus), |
12 | 13 |
.print_dev = usb_bus_dev_print, |
14 |
.get_fw_dev_path = usbbus_get_fw_dev_path, |
|
13 | 15 |
}; |
14 | 16 |
static int next_usb_bus = 0; |
15 | 17 |
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses); |
... | ... | |
307 | 309 |
} |
308 | 310 |
return usb->usbdevice_init(params); |
309 | 311 |
} |
312 |
|
|
313 |
static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p, |
|
314 |
int len) |
|
315 |
{ |
|
316 |
int l = 0; |
|
317 |
USBPort *port; |
|
318 |
|
|
319 |
QTAILQ_FOREACH(port, &bus->used, next) { |
|
320 |
if (port->dev == d) { |
|
321 |
if (port->pdev) { |
|
322 |
l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len); |
|
323 |
} |
|
324 |
l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev), |
|
325 |
port->index); |
|
326 |
break; |
|
327 |
} |
|
328 |
} |
|
329 |
|
|
330 |
return l; |
|
331 |
} |
|
332 |
|
|
333 |
static char *usbbus_get_fw_dev_path(DeviceState *dev) |
|
334 |
{ |
|
335 |
USBDevice *d = (USBDevice*)dev; |
|
336 |
USBBus *bus = usb_bus_from_device(d); |
|
337 |
char path[100]; |
|
338 |
int l; |
|
339 |
|
|
340 |
assert(d->attached != 0); |
|
341 |
|
|
342 |
l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path)); |
|
343 |
|
|
344 |
if (l == 0) { |
|
345 |
abort(); |
|
346 |
} |
|
347 |
|
|
348 |
path[l-1] = '\0'; |
|
349 |
|
|
350 |
return strdup(path); |
|
351 |
} |
Also available in: Unified diff