83 lines
2.7 KiB
Diff
83 lines
2.7 KiB
Diff
From fc63639374684dae600d200c133adad75044e587 Mon Sep 17 00:00:00 2001
|
|
From: Hans de Goede <hdegoede@redhat.com>
|
|
Date: Fri, 24 Jun 2011 11:29:56 +0200
|
|
Subject: [PATCH 04/35] usb: Add a register_companion USB bus op.
|
|
|
|
This is a preparation patch for adding support for USB companion controllers.
|
|
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
---
|
|
hw/usb-bus.c | 31 +++++++++++++++++++++++++++++++
|
|
hw/usb.h | 5 +++++
|
|
2 files changed, 36 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
|
|
index e37e8a2..b511bac 100644
|
|
--- a/hw/usb-bus.c
|
|
+++ b/hw/usb-bus.c
|
|
@@ -160,6 +160,37 @@ void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
|
|
bus->nfree++;
|
|
}
|
|
|
|
+int usb_register_companion(const char *masterbus, USBPort *ports[],
|
|
+ uint32_t portcount, uint32_t firstport,
|
|
+ void *opaque, USBPortOps *ops, int speedmask)
|
|
+{
|
|
+ USBBus *bus;
|
|
+ int i;
|
|
+
|
|
+ QTAILQ_FOREACH(bus, &busses, next) {
|
|
+ if (strcmp(bus->qbus.name, masterbus) == 0) {
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!bus || !bus->ops->register_companion) {
|
|
+ qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
|
|
+ "an USB masterbus");
|
|
+ if (bus) {
|
|
+ error_printf_unless_qmp(
|
|
+ "USB bus '%s' does not allow companion controllers\n",
|
|
+ masterbus);
|
|
+ }
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ for (i = 0; i < portcount; i++) {
|
|
+ usb_fill_port(ports[i], opaque, i, ops, speedmask);
|
|
+ }
|
|
+
|
|
+ return bus->ops->register_companion(bus, ports, portcount, firstport);
|
|
+}
|
|
+
|
|
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)
|
|
{
|
|
if (upstream) {
|
|
diff --git a/hw/usb.h b/hw/usb.h
|
|
index 076e2ff..a5f2efa 100644
|
|
--- a/hw/usb.h
|
|
+++ b/hw/usb.h
|
|
@@ -344,6 +344,8 @@ struct USBBus {
|
|
};
|
|
|
|
struct USBBusOps {
|
|
+ int (*register_companion)(USBBus *bus, USBPort *ports[],
|
|
+ uint32_t portcount, uint32_t firstport);
|
|
void (*device_destroy)(USBBus *bus, USBDevice *dev);
|
|
};
|
|
|
|
@@ -356,6 +358,9 @@ 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,
|
|
USBPortOps *ops, int speedmask);
|
|
+int usb_register_companion(const char *masterbus, USBPort *ports[],
|
|
+ uint32_t portcount, uint32_t firstport,
|
|
+ void *opaque, USBPortOps *ops, int speedmask);
|
|
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
|
|
void usb_unregister_port(USBBus *bus, USBPort *port);
|
|
int usb_device_attach(USBDevice *dev);
|
|
--
|
|
1.7.5.1
|
|
|