Revision ae60fea9

b/hw/usb-bus.c
160 160
    bus->nfree++;
161 161
}
162 162

  
163
int usb_register_companion(const char *masterbus, USBPort *ports[],
164
                           uint32_t portcount, uint32_t firstport,
165
                           void *opaque, USBPortOps *ops, int speedmask)
166
{
167
    USBBus *bus;
168
    int i;
169

  
170
    QTAILQ_FOREACH(bus, &busses, next) {
171
        if (strcmp(bus->qbus.name, masterbus) == 0) {
172
            break;
173
        }
174
    }
175

  
176
    if (!bus || !bus->ops->register_companion) {
177
        qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
178
                      "an USB masterbus");
179
        if (bus) {
180
            error_printf_unless_qmp(
181
                "USB bus '%s' does not allow companion controllers\n",
182
                masterbus);
183
        }
184
        return -1;
185
    }
186

  
187
    for (i = 0; i < portcount; i++) {
188
        usb_fill_port(ports[i], opaque, i, ops, speedmask);
189
    }
190

  
191
    return bus->ops->register_companion(bus, ports, portcount, firstport);
192
}
193

  
163 194
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)
164 195
{
165 196
    if (upstream) {
b/hw/usb.h
344 344
};
345 345

  
346 346
struct USBBusOps {
347
    int (*register_companion)(USBBus *bus, USBPort *ports[],
348
                              uint32_t portcount, uint32_t firstport);
347 349
    void (*device_destroy)(USBBus *bus, USBDevice *dev);
348 350
};
349 351

  
......
356 358
USBDevice *usbdevice_create(const char *cmdline);
357 359
void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
358 360
                       USBPortOps *ops, int speedmask);
361
int usb_register_companion(const char *masterbus, USBPort *ports[],
362
                           uint32_t portcount, uint32_t firstport,
363
                           void *opaque, USBPortOps *ops, int speedmask);
359 364
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
360 365
void usb_unregister_port(USBBus *bus, USBPort *port);
361 366
int usb_device_attach(USBDevice *dev);

Also available in: Unified diff