qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [patch 1/2] add USBBusOps to USBBus


From: Marcelo Tosatti
Subject: [Qemu-devel] [patch 1/2] add USBBusOps to USBBus
Date: Thu, 25 Nov 2010 15:04:40 -0200
User-agent: quilt/0.47-1

Needed for remote wakeup notification.

Signed-off-by: Marcelo Tosatti <address@hidden>

Index: qemu-kvm/hw/usb-bus.c
===================================================================
--- qemu-kvm.orig/hw/usb-bus.c
+++ qemu-kvm/hw/usb-bus.c
@@ -14,11 +14,12 @@ static struct BusInfo usb_bus_info = {
 static int next_usb_bus = 0;
 static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
 
-void usb_bus_new(USBBus *bus, DeviceState *host)
+void usb_bus_new(USBBus *bus, DeviceState *host, USBBusOps *ops)
 {
     qbus_create_inplace(&bus->qbus, &usb_bus_info, host, NULL);
     bus->busnr = next_usb_bus++;
     bus->qbus.allow_hotplug = 1; /* Yes, we can */
+    bus->ops = ops;
     QTAILQ_INIT(&bus->free);
     QTAILQ_INIT(&bus->used);
     QTAILQ_INSERT_TAIL(&busses, bus, next);
Index: qemu-kvm/hw/usb.c
===================================================================
--- qemu-kvm.orig/hw/usb.c
+++ qemu-kvm/hw/usb.c
@@ -229,3 +229,12 @@ void usb_send_msg(USBDevice *dev, int ms
 
     /* This _must_ be synchronous */
 }
+
+void usb_remote_wakeup(USBDevice *dev)
+{
+    USBBus *bus = usb_bus_from_device(dev);
+
+    if (bus->ops && bus->ops->remote_wakeup_cb) {
+        bus->ops->remote_wakeup_cb(bus, dev);
+    }
+}
Index: qemu-kvm/hw/usb.h
===================================================================
--- qemu-kvm.orig/hw/usb.h
+++ qemu-kvm/hw/usb.h
@@ -123,6 +123,7 @@
 #define USB_ENDPOINT_XFER_INT          3
 
 typedef struct USBBus USBBus;
+typedef struct USBBusOps USBBusOps;
 typedef struct USBPort USBPort;
 typedef struct USBDevice USBDevice;
 typedef struct USBDeviceInfo USBDeviceInfo;
@@ -294,8 +295,16 @@ void musb_set_size(MUSBState *s, int epn
 
 /* usb-bus.c */
 
+struct USBBusOps {
+    /*
+     * Process remote wakeup request.
+     */
+    void (*remote_wakeup_cb)(USBBus *bus, USBDevice *dev);
+};
+
 struct USBBus {
     BusState qbus;
+    USBBusOps *ops;
     int busnr;
     int nfree;
     int nused;
@@ -304,7 +313,7 @@ struct USBBus {
     QTAILQ_ENTRY(USBBus) next;
 };
 
-void usb_bus_new(USBBus *bus, DeviceState *host);
+void usb_bus_new(USBBus *bus, DeviceState *host, USBBusOps *ops);
 USBBus *usb_bus_find(int busnr);
 void usb_qdev_register(USBDeviceInfo *info);
 void usb_qdev_register_many(USBDeviceInfo *info);
@@ -317,6 +326,7 @@ void usb_unregister_port(USBBus *bus, US
 int usb_device_attach(USBDevice *dev);
 int usb_device_detach(USBDevice *dev);
 int usb_device_delete_addr(int busnr, int addr);
+void usb_remote_wakeup(USBDevice *dev);
 
 static inline USBBus *usb_bus_from_device(USBDevice *d)
 {
Index: qemu-kvm/hw/usb-musb.c
===================================================================
--- qemu-kvm.orig/hw/usb-musb.c
+++ qemu-kvm/hw/usb-musb.c
@@ -342,7 +342,7 @@ struct MUSBState {
         s->ep[i].epnum = i;
     }
 
-    usb_bus_new(&s->bus, NULL /* FIXME */);
+    usb_bus_new(&s->bus, NULL /* FIXME */, NULL);
     usb_register_port(&s->bus, &s->port, s, 0, musb_attach);
 
     return s;
Index: qemu-kvm/hw/usb-ohci.c
===================================================================
--- qemu-kvm.orig/hw/usb-ohci.c
+++ qemu-kvm/hw/usb-ohci.c
@@ -1702,7 +1702,7 @@ static void usb_ohci_init(OHCIState *ohc
 
     ohci->name = dev->info->name;
 
-    usb_bus_new(&ohci->bus, dev);
+    usb_bus_new(&ohci->bus, dev, NULL);
     ohci->num_ports = num_ports;
     for (i = 0; i < num_ports; i++) {
         usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, 
ohci_attach);
Index: qemu-kvm/hw/usb-uhci.c
===================================================================
--- qemu-kvm.orig/hw/usb-uhci.c
+++ qemu-kvm/hw/usb-uhci.c
@@ -1113,7 +1113,7 @@ static int usb_uhci_common_initfn(UHCISt
     pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
     pci_conf[0x60] = 0x10; // release number
 
-    usb_bus_new(&s->bus, &s->dev.qdev);
+    usb_bus_new(&s->bus, &s->dev.qdev, NULL);
     for(i = 0; i < NB_PORTS; i++) {
         usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]