[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 31/32] usb: rewrite fw path, fix numbering
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH v4 31/32] usb: rewrite fw path, fix numbering |
Date: |
Wed, 12 Jan 2011 12:20:13 +0100 |
This patch rewrites the firmware path code to use the physical port
location tracking just added to the qemu usb core. It also fixes the
port numbering to start with "1" in the firmware path.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-bus.c | 68 ++++++++++++++++++++++-----------------------------------
1 files changed, 26 insertions(+), 42 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 1f59f9a..f89176b 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -7,14 +7,14 @@
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
static char *usb_get_dev_path(DeviceState *dev);
-static char *usbbus_get_fw_dev_path(DeviceState *dev);
+static char *usb_get_fw_dev_path(DeviceState *qdev);
static struct BusInfo usb_bus_info = {
.name = "USB",
.size = sizeof(USBBus),
.print_dev = usb_bus_dev_print,
.get_dev_path = usb_get_dev_path,
- .get_fw_dev_path = usbbus_get_fw_dev_path,
+ .get_fw_dev_path = usb_get_fw_dev_path,
.props = (Property[]) {
DEFINE_PROP_STRING("port", USBDevice, port_path),
DEFINE_PROP_END_OF_LIST()
@@ -279,6 +279,30 @@ static char *usb_get_dev_path(DeviceState *qdev)
return qemu_strdup(dev->port->path);
}
+static char *usb_get_fw_dev_path(DeviceState *qdev)
+{
+ USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);
+ char *fw_path, *in;
+ int pos = 0;
+ long nr;
+
+ fw_path = qemu_malloc(32 + strlen(dev->port->path) * 6);
+ in = dev->port->path;
+ while (true) {
+ nr = strtol(in, &in, 10);
+ if (in[0] == '.') {
+ /* some hub between root port and device */
+ pos += sprintf(fw_path + pos, "address@hidden/", nr);
+ in++;
+ } else {
+ /* the device itself */
+ pos += sprintf(fw_path + pos, "address@hidden",
qdev_fw_name(qdev), nr);
+ break;
+ }
+ }
+ return fw_path;
+}
+
void usb_info(Monitor *mon)
{
USBBus *bus;
@@ -351,43 +375,3 @@ USBDevice *usbdevice_create(const char *cmdline)
}
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, "address@hidden/",
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);
-}
--
1.7.1
- [Qemu-devel] [PATCH v4 14/32] usb: move remote wakeup handling to common code, (continued)
- [Qemu-devel] [PATCH v4 14/32] usb: move remote wakeup handling to common code, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 21/32] usb: hid: change serial number to "42"., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 19/32] usb: hub: remote wakeup support., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 23/32] usb: add attach callback, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 15/32] usb: create USBPortOps, move attach there., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 20/32] usb: hid: remote wakeup support., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 18/32] usb: uhci: remote wakeup support., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 17/32] usb: add usb_wakeup() + wakeup callback to port ops, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 31/32] usb: rewrite fw path, fix numbering,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH v4 24/32] usb: add usb_desc_attach, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 22/32] usb: add speed mask to ports, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 32/32] usb: zap pdev from usbport, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 27/32] usb storage: fix status reporting, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 28/32] usb storage: handle long responses, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 16/32] usb: rework attach/detach workflow, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 25/32] usb: add device qualifier support, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 26/32] usb storage: high speed support, Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 29/32] usb: keep track of physical port address., Gerd Hoffmann, 2011/01/12
- [Qemu-devel] [PATCH v4 30/32] usb: add port property., Gerd Hoffmann, 2011/01/12