usb: Propagate errors through usb_register_companion()

This loses the messages explaining the error printed with
error_printf_unless_qmp().  The next commit will make up for the loss.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Markus Armbruster 2015-02-17 14:28:02 +01:00 committed by Gerd Hoffmann
parent 5a4992834d
commit f4bbaaf584
5 changed files with 44 additions and 28 deletions

View file

@ -360,9 +360,10 @@ 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)
void usb_register_companion(const char *masterbus, USBPort *ports[],
uint32_t portcount, uint32_t firstport,
void *opaque, USBPortOps *ops, int speedmask,
Error **errp)
{
USBBus *bus;
int i;
@ -374,21 +375,23 @@ int usb_register_companion(const char *masterbus, USBPort *ports[],
}
if (!bus || !bus->ops->register_companion) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "masterbus",
"an USB masterbus");
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "masterbus",
"an USB masterbus");
#if 0 /* conversion from qerror_report() to error_set() broke this: */
if (bus) {
error_printf_unless_qmp(
"USB bus '%s' does not allow companion controllers\n",
masterbus);
}
return -1;
#endif
return;
}
for (i = 0; i < portcount; i++) {
usb_fill_port(ports[i], opaque, i, ops, speedmask);
}
return bus->ops->register_companion(bus, ports, portcount, firstport);
bus->ops->register_companion(bus, ports, portcount, firstport, errp);
}
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)