qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paul Brook <paul@codesourcery.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] [patch 1/3] add USBPortOps to USBPort
Date: Wed, 01 Dec 2010 14:47:05 -0200	[thread overview]
Message-ID: <20101201164742.979755400@redhat.com> (raw)
In-Reply-To: 20101201164704.729398122@redhat.com

[-- Attachment #1: usb-bus-ops --]
[-- Type: text/plain, Size: 5446 bytes --]

Needed for remote wakeup notification.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm/hw/usb-bus.c
===================================================================
--- qemu-kvm.orig/hw/usb-bus.c
+++ qemu-kvm/hw/usb-bus.c
@@ -110,11 +110,11 @@ USBDevice *usb_create_simple(USBBus *bus
 }
 
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
-                       usb_attachfn attach)
+                       USBPortOps *ops)
 {
     port->opaque = opaque;
     port->index = index;
-    port->attach = attach;
+    port->ops = ops;
     QTAILQ_INSERT_TAIL(&bus->free, port, next);
     bus->nfree++;
 }
Index: qemu-kvm/hw/usb.c
===================================================================
--- qemu-kvm.orig/hw/usb.c
+++ qemu-kvm/hw/usb.c
@@ -28,7 +28,7 @@
 
 void usb_attach(USBPort *port, USBDevice *dev)
 {
-    port->attach(port, dev);
+    port->ops->attach(port, dev);
 }
 
 /**********************/
Index: qemu-kvm/hw/usb.h
===================================================================
--- qemu-kvm.orig/hw/usb.h
+++ qemu-kvm/hw/usb.h
@@ -124,6 +124,7 @@
 
 typedef struct USBBus USBBus;
 typedef struct USBPort USBPort;
+typedef struct USBPortOps USBPortOps;
 typedef struct USBDevice USBDevice;
 typedef struct USBDeviceInfo USBDeviceInfo;
 typedef struct USBPacket USBPacket;
@@ -196,12 +197,14 @@ struct USBDeviceInfo {
     USBDevice *(*usbdevice_init)(const char *params);
 };
 
-typedef void (*usb_attachfn)(USBPort *port, USBDevice *dev);
+struct USBPortOps {
+    void (*attach)(USBPort *port, USBDevice *dev);
+};
 
 /* USB port on which a device can be connected */
 struct USBPort {
     USBDevice *dev;
-    usb_attachfn attach;
+    USBPortOps *ops;
     void *opaque;
     int index; /* internal port index, may be used with the opaque */
     QTAILQ_ENTRY(USBPort) next;
@@ -312,7 +315,7 @@ USBDevice *usb_create(USBBus *bus, const
 USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
-                       usb_attachfn attach);
+                       USBPortOps *ops);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 int usb_device_attach(USBDevice *dev);
 int usb_device_detach(USBDevice *dev);
Index: qemu-kvm/hw/usb-musb.c
===================================================================
--- qemu-kvm.orig/hw/usb-musb.c
+++ qemu-kvm/hw/usb-musb.c
@@ -261,6 +261,10 @@
 
 static void musb_attach(USBPort *port, USBDevice *dev);
 
+static USBPortOps musb_port_ops = {
+    .attach = musb_attach,
+};
+
 typedef struct {
     uint16_t faddr[2];
     uint8_t haddr[2];
@@ -343,7 +347,7 @@ struct MUSBState {
     }
 
     usb_bus_new(&s->bus, NULL /* FIXME */);
-    usb_register_port(&s->bus, &s->port, s, 0, musb_attach);
+    usb_register_port(&s->bus, &s->port, s, 0, &musb_port_ops);
 
     return s;
 }
Index: qemu-kvm/hw/usb-ohci.c
===================================================================
--- qemu-kvm.orig/hw/usb-ohci.c
+++ qemu-kvm/hw/usb-ohci.c
@@ -1676,6 +1676,10 @@ static CPUWriteMemoryFunc * const ohci_w
     ohci_mem_write
 };
 
+static USBPortOps ohci_port_ops = {
+    .attach = ohci_attach,
+};
+
 static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
                           int num_ports, uint32_t localmem_base)
 {
@@ -1705,7 +1709,7 @@ static void usb_ohci_init(OHCIState *ohc
     usb_bus_new(&ohci->bus, dev);
     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);
+        usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, &ohci_port_ops);
     }
 
     ohci->async_td = 0;
Index: qemu-kvm/hw/usb-uhci.c
===================================================================
--- qemu-kvm.orig/hw/usb-uhci.c
+++ qemu-kvm/hw/usb-uhci.c
@@ -1101,6 +1101,10 @@ static void uhci_map(PCIDevice *pci_dev,
     register_ioport_read(addr, 32, 1, uhci_ioport_readb, s);
 }
 
+static USBPortOps uhci_port_ops = {
+    .attach = uhci_attach,
+};
+
 static int usb_uhci_common_initfn(UHCIState *s)
 {
     uint8_t *pci_conf = s->dev.config;
@@ -1115,7 +1119,7 @@ static int usb_uhci_common_initfn(UHCISt
 
     usb_bus_new(&s->bus, &s->dev.qdev);
     for(i = 0; i < NB_PORTS; i++) {
-        usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
+        usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops);
     }
     s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
     s->expire_time = qemu_get_clock(vm_clock) +
Index: qemu-kvm/hw/usb-hub.c
===================================================================
--- qemu-kvm.orig/hw/usb-hub.c
+++ qemu-kvm/hw/usb-hub.c
@@ -524,6 +524,10 @@ static void usb_hub_handle_destroy(USBDe
     }
 }
 
+static USBPortOps hub_port_ops = {
+    .attach = usb_hub_attach,
+};
+
 static int usb_hub_initfn(USBDevice *dev)
 {
     USBHubState *s = DO_UPCAST(USBHubState, dev, dev);
@@ -535,7 +539,7 @@ static int usb_hub_initfn(USBDevice *dev
     for (i = 0; i < s->nb_ports; i++) {
         port = &s->ports[i];
         usb_register_port(usb_bus_from_device(dev),
-                          &port->port, s, i, usb_hub_attach);
+                          &port->port, s, i, &hub_port_ops);
         port->wPortStatus = PORT_STAT_POWER;
         port->wPortChange = 0;
     }

  reply	other threads:[~2010-12-01 16:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25 15:34 [Qemu-devel] PATCH: QEMU support for UHCI suspend / remote wake up Marcelo Tosatti
2010-11-25 16:15 ` [Qemu-devel] " Gerd Hoffmann
2010-11-25 17:04   ` [Qemu-devel] [patch 0/2] USB UHCI global suspend / remote wakeup Marcelo Tosatti
2010-11-25 17:04     ` [Qemu-devel] [patch 1/2] add USBBusOps to USBBus Marcelo Tosatti
2010-11-25 17:04     ` [Qemu-devel] [patch 2/2] support for UHCI suspend / remote wake up Marcelo Tosatti
2010-12-01 15:12       ` [Qemu-devel] " Gerd Hoffmann
2010-12-01 16:58         ` Marcelo Tosatti
2010-12-01 17:17           ` Gerd Hoffmann
2010-11-26  0:38     ` [Qemu-devel] [patch 0/2] USB UHCI global suspend / remote wakeup Paul Brook
2010-11-26  2:15       ` Marcelo Tosatti
2010-11-26  8:49         ` Gerd Hoffmann
2010-11-26 12:09           ` Paul Brook
2010-12-01 16:47     ` [Qemu-devel] [patch 0/3] QEMU support for UHCI suspend / remote wake up (v3) Marcelo Tosatti
2010-12-01 16:47       ` Marcelo Tosatti [this message]
2010-12-01 17:10         ` [Qemu-devel] Re: [patch 1/3] add USBPortOps to USBPort Gerd Hoffmann
2010-12-01 16:47       ` [Qemu-devel] [patch 2/3] support for UHCI suspend / remote wake up Marcelo Tosatti
2010-12-01 17:12         ` [Qemu-devel] " Gerd Hoffmann
2010-12-01 16:47       ` [Qemu-devel] [patch 3/3] UHCI: Substate section for migration of remote wakeup feature Marcelo Tosatti
2010-12-01 17:16         ` [Qemu-devel] " Gerd Hoffmann
2010-12-01 19:14           ` Juan Quintela
2010-12-01 20:56             ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101201164742.979755400@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).