Patchwork set usb bus name by busno.

login
register
mail settings
Submitter 乔崇
Date March 29, 2013, 2:48 a.m.
Message ID <1364525338-18163-1-git-send-email-qiaochong@loongson.cn>
Download mbox | patch
Permalink /patch/232296/
State New
Headers show

Comments

乔崇 - March 29, 2013, 2:48 a.m.
So when we add several usb buses on system, we can add usb device on special usb bus by special usb bus name usb-bus.busno.

Signed-off-by: qiaochong <qiaochong@loongson.cn>
---
 hw/usb/bus.c | 4 +++-
 1 个文件被修改,插入 3 行(+),删除 1 行(-)
Gerd Hoffmann - April 2, 2013, 1:36 p.m.
On 03/29/13 03:48, qiaochong wrote:
> So when we add several usb buses on system, we can add usb device on
> special usb bus by special usb bus name usb-bus.busno.

Just name your usb host adapters using id (i.e. -device usb-ehci,id=foo).
The usb bus name will be "${id}.0" then.

cheers,
  Gerd

Patch

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index e58cd9a..c31a17c 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -68,7 +68,9 @@  const VMStateDescription vmstate_usb_device = {
 
 void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host)
 {
-    qbus_create_inplace(&bus->qbus, TYPE_USB_BUS, host, NULL);
+    char name[64];
+    snprintf(name, 64, TYPE_USB_BUS ".%d", next_usb_bus);
+    qbus_create_inplace(&bus->qbus, TYPE_USB_BUS, host, name);
     bus->ops = ops;
     bus->busnr = next_usb_bus++;
     bus->qbus.allow_hotplug = 1; /* Yes, we can */