|
Hans de Goede |
3f1f29 |
From 99a493bf96aa03427633b24653112b43fa7b7131 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
3f1f29 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
3f1f29 |
Date: Tue, 21 Jun 2011 11:52:28 +0200
|
|
Hans de Goede |
3f1f29 |
Subject: [PATCH 05/35] usb: Make port wakeup and complete ops take a USBPort
|
|
Hans de Goede |
3f1f29 |
instead of a Device
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
This makes them consistent with the attach and detach ops, and in general
|
|
Hans de Goede |
3f1f29 |
it makes sense to make portops take a port as argument. This also makes
|
|
Hans de Goede |
3f1f29 |
adding support for a companion controller easier / cleaner.
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
[ kraxel: fix usb-musb.c build ]
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
3f1f29 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
3f1f29 |
---
|
|
Hans de Goede |
3f1f29 |
hw/usb-ehci.c | 2 +-
|
|
Hans de Goede |
3f1f29 |
hw/usb-hub.c | 10 +++++-----
|
|
Hans de Goede |
3f1f29 |
hw/usb-musb.c | 6 +++---
|
|
Hans de Goede |
3f1f29 |
hw/usb-ohci.c | 12 +++++-------
|
|
Hans de Goede |
3f1f29 |
hw/usb-uhci.c | 11 +++++------
|
|
Hans de Goede |
3f1f29 |
hw/usb.c | 4 ++--
|
|
Hans de Goede |
3f1f29 |
hw/usb.h | 9 +++++++--
|
|
Hans de Goede |
3f1f29 |
7 files changed, 28 insertions(+), 26 deletions(-)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
|
|
Hans de Goede |
3f1f29 |
index 88cb2c2..428c90b 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-ehci.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-ehci.c
|
|
Hans de Goede |
3f1f29 |
@@ -1111,7 +1111,7 @@ static int ehci_buffer_rw(EHCIQueue *q, int bytes, int rw)
|
|
Hans de Goede |
3f1f29 |
return 0;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void ehci_async_complete_packet(USBDevice *dev, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
+static void ehci_async_complete_packet(USBPort *port, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
EHCIQueue *q = container_of(packet, EHCIQueue, packet);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
|
|
Hans de Goede |
3f1f29 |
index 6e2a358..d324bba 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-hub.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-hub.c
|
|
Hans de Goede |
3f1f29 |
@@ -246,10 +246,10 @@ static void usb_hub_detach(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void usb_hub_wakeup(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
+static void usb_hub_wakeup(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
- USBHubState *s = dev->port->opaque;
|
|
Hans de Goede |
3f1f29 |
- USBHubPort *port = &s->ports[dev->port->index];
|
|
Hans de Goede |
3f1f29 |
+ USBHubState *s = port1->opaque;
|
|
Hans de Goede |
3f1f29 |
+ USBHubPort *port = &s->ports[port1->index];
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
if (port->wPortStatus & PORT_STAT_SUSPEND) {
|
|
Hans de Goede |
3f1f29 |
port->wPortChange |= PORT_STAT_C_SUSPEND;
|
|
Hans de Goede |
3f1f29 |
@@ -257,9 +257,9 @@ static void usb_hub_wakeup(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void usb_hub_complete(USBDevice *dev, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
+static void usb_hub_complete(USBPort *port, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
- USBHubState *s = dev->port->opaque;
|
|
Hans de Goede |
3f1f29 |
+ USBHubState *s = port->opaque;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
/*
|
|
Hans de Goede |
3f1f29 |
* Just pass it along upstream for now.
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
|
|
Hans de Goede |
3f1f29 |
index 84e6017..580bdc8 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-musb.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-musb.c
|
|
Hans de Goede |
3f1f29 |
@@ -261,7 +261,7 @@
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static void musb_attach(USBPort *port);
|
|
Hans de Goede |
3f1f29 |
static void musb_detach(USBPort *port);
|
|
Hans de Goede |
3f1f29 |
-static void musb_schedule_cb(USBDevice *dev, USBPacket *p);
|
|
Hans de Goede |
3f1f29 |
+static void musb_schedule_cb(USBPort *port, USBPacket *p);
|
|
Hans de Goede |
3f1f29 |
static void musb_device_destroy(USBBus *bus, USBDevice *dev);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static USBPortOps musb_port_ops = {
|
|
Hans de Goede |
3f1f29 |
@@ -517,7 +517,7 @@ static void musb_cb_tick1(void *opaque)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
#define musb_cb_tick (dir ? musb_cb_tick1 : musb_cb_tick0)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void musb_schedule_cb(USBDevice *dev, USBPacket *packey)
|
|
Hans de Goede |
3f1f29 |
+static void musb_schedule_cb(USBPort *port, USBPacket *packey)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
MUSBPacket *p = container_of(packey, MUSBPacket, p);
|
|
Hans de Goede |
3f1f29 |
MUSBEndPoint *ep = p->ep;
|
|
Hans de Goede |
3f1f29 |
@@ -615,7 +615,7 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep,
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
ep->status[dir] = ret;
|
|
Hans de Goede |
3f1f29 |
- musb_schedule_cb(s->port.dev, &ep->packey[dir].p);
|
|
Hans de Goede |
3f1f29 |
+ musb_schedule_cb(&s->port, &ep->packey[dir].p);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static void musb_tx_packet_complete(USBPacket *packey, void *opaque)
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
|
|
Hans de Goede |
3f1f29 |
index 95e4623..bd92c31 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-ohci.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-ohci.c
|
|
Hans de Goede |
3f1f29 |
@@ -367,15 +367,13 @@ static void ohci_detach(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
ohci_set_interrupt(s, OHCI_INTR_RHSC);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void ohci_wakeup(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
+static void ohci_wakeup(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
- USBBus *bus = usb_bus_from_device(dev);
|
|
Hans de Goede |
3f1f29 |
- OHCIState *s = container_of(bus, OHCIState, bus);
|
|
Hans de Goede |
3f1f29 |
- int portnum = dev->port->index;
|
|
Hans de Goede |
3f1f29 |
- OHCIPort *port = &s->rhport[portnum];
|
|
Hans de Goede |
3f1f29 |
+ OHCIState *s = port1->opaque;
|
|
Hans de Goede |
3f1f29 |
+ OHCIPort *port = &s->rhport[port1->index];
|
|
Hans de Goede |
3f1f29 |
uint32_t intr = 0;
|
|
Hans de Goede |
3f1f29 |
if (port->ctrl & OHCI_PORT_PSS) {
|
|
Hans de Goede |
3f1f29 |
- DPRINTF("usb-ohci: port %d: wakeup\n", portnum);
|
|
Hans de Goede |
3f1f29 |
+ DPRINTF("usb-ohci: port %d: wakeup\n", port1->index);
|
|
Hans de Goede |
3f1f29 |
port->ctrl |= OHCI_PORT_PSSC;
|
|
Hans de Goede |
3f1f29 |
port->ctrl &= ~OHCI_PORT_PSS;
|
|
Hans de Goede |
3f1f29 |
intr = OHCI_INTR_RHSC;
|
|
Hans de Goede |
3f1f29 |
@@ -602,7 +600,7 @@ static void ohci_copy_iso_td(OHCIState *ohci,
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static void ohci_process_lists(OHCIState *ohci, int completion);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void ohci_async_complete_packet(USBDevice *dev, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
+static void ohci_async_complete_packet(USBPort *port, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
OHCIState *ohci = container_of(packet, OHCIState, usb_packet);
|
|
Hans de Goede |
3f1f29 |
#ifdef DEBUG_PACKET
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
|
|
Hans de Goede |
3f1f29 |
index fd25d2a..ab635f6 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb-uhci.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb-uhci.c
|
|
Hans de Goede |
3f1f29 |
@@ -620,11 +620,10 @@ static void uhci_detach(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
uhci_resume(s);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void uhci_wakeup(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
+static void uhci_wakeup(USBPort *port1)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
- USBBus *bus = usb_bus_from_device(dev);
|
|
Hans de Goede |
3f1f29 |
- UHCIState *s = container_of(bus, UHCIState, bus);
|
|
Hans de Goede |
3f1f29 |
- UHCIPort *port = s->ports + dev->port->index;
|
|
Hans de Goede |
3f1f29 |
+ UHCIState *s = port1->opaque;
|
|
Hans de Goede |
3f1f29 |
+ UHCIPort *port = &s->ports[port1->index];
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
if (port->ctrl & UHCI_PORT_SUSPEND && !(port->ctrl & UHCI_PORT_RD)) {
|
|
Hans de Goede |
3f1f29 |
port->ctrl |= UHCI_PORT_RD;
|
|
Hans de Goede |
3f1f29 |
@@ -657,7 +656,7 @@ static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)
|
|
Hans de Goede |
3f1f29 |
return ret;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void uhci_async_complete(USBDevice *dev, USBPacket *packet);
|
|
Hans de Goede |
3f1f29 |
+static void uhci_async_complete(USBPort *port, USBPacket *packet);
|
|
Hans de Goede |
3f1f29 |
static void uhci_process_frame(UHCIState *s);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
/* return -1 if fatal error (frame must be stopped)
|
|
Hans de Goede |
3f1f29 |
@@ -849,7 +848,7 @@ done:
|
|
Hans de Goede |
3f1f29 |
return len;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
-static void uhci_async_complete(USBDevice *dev, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
+static void uhci_async_complete(USBPort *port, USBPacket *packet)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
UHCIAsync *async = container_of(packet, UHCIAsync, packet);
|
|
Hans de Goede |
3f1f29 |
UHCIState *s = async->uhci;
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb.c b/hw/usb.c
|
|
Hans de Goede |
3f1f29 |
index 4a39cbc..735ffd1 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb.c
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb.c
|
|
Hans de Goede |
3f1f29 |
@@ -52,7 +52,7 @@ void usb_attach(USBPort *port, USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
void usb_wakeup(USBDevice *dev)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) {
|
|
Hans de Goede |
3f1f29 |
- dev->port->ops->wakeup(dev);
|
|
Hans de Goede |
3f1f29 |
+ dev->port->ops->wakeup(dev->port);
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
@@ -335,7 +335,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
/* Note: p->owner != dev is possible in case dev is a hub */
|
|
Hans de Goede |
3f1f29 |
assert(p->owner != NULL);
|
|
Hans de Goede |
3f1f29 |
- dev->port->ops->complete(dev, p);
|
|
Hans de Goede |
3f1f29 |
+ dev->port->ops->complete(dev->port, p);
|
|
Hans de Goede |
3f1f29 |
p->owner = NULL;
|
|
Hans de Goede |
3f1f29 |
}
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/hw/usb.h b/hw/usb.h
|
|
Hans de Goede |
3f1f29 |
index a5f2efa..65f45a0 100644
|
|
Hans de Goede |
3f1f29 |
--- a/hw/usb.h
|
|
Hans de Goede |
3f1f29 |
+++ b/hw/usb.h
|
|
Hans de Goede |
3f1f29 |
@@ -252,8 +252,13 @@ struct USBDeviceInfo {
|
|
Hans de Goede |
3f1f29 |
typedef struct USBPortOps {
|
|
Hans de Goede |
3f1f29 |
void (*attach)(USBPort *port);
|
|
Hans de Goede |
3f1f29 |
void (*detach)(USBPort *port);
|
|
Hans de Goede |
3f1f29 |
- void (*wakeup)(USBDevice *dev);
|
|
Hans de Goede |
3f1f29 |
- void (*complete)(USBDevice *dev, USBPacket *p);
|
|
Hans de Goede |
3f1f29 |
+ void (*wakeup)(USBPort *port);
|
|
Hans de Goede |
3f1f29 |
+ /*
|
|
Hans de Goede |
3f1f29 |
+ * Note that port->dev will be different then the device from which
|
|
Hans de Goede |
3f1f29 |
+ * the packet originated when a hub is involved, if you want the orginating
|
|
Hans de Goede |
3f1f29 |
+ * device use p->owner
|
|
Hans de Goede |
3f1f29 |
+ */
|
|
Hans de Goede |
3f1f29 |
+ void (*complete)(USBPort *port, USBPacket *p);
|
|
Hans de Goede |
3f1f29 |
} USBPortOps;
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
/* USB port on which a device can be connected */
|
|
Hans de Goede |
3f1f29 |
--
|
|
Hans de Goede |
3f1f29 |
1.7.5.1
|
|
Hans de Goede |
3f1f29 |
|