diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2015-02-25 11:54:15 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-02-25 11:54:15 +0000 |
commit | 3d30395f7fb3315e4ecf0de4e48790e1326bbd47 (patch) | |
tree | 2bb4195587d1d5e7f6be11e0b0bafdb548f82c4e /hw | |
parent | c28d4869ea1235b80ef59d5f5e8ca96bc4155c0c (diff) | |
parent | c3cf77cb63b71618224129df41f114488e0f74e4 (diff) |
Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20150218-1' into staging
usb: error handling fixes from Markus, make sysbus ehci arm-only.
# gpg: Signature made Wed Feb 18 09:54:13 2015 GMT using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
* remotes/kraxel/tags/pull-usb-20150218-1:
Make sysbus EHCI devices ARM only by default
PPC: Don't use legacy -usbdevice support for setting up board
r2d: Don't use legacy -usbdevice support for setting up board
usb: Change usb_create_simple() to abort on failure
usb: Suppress bogus error when automatic usb-hub creation fails
usb: Do not prefix error_setg() messages with "Error: "
usb: Improve -usbdevice error reporting a bit
usb: usb_create() can't fail, drop useless error handling
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ppc/mac_newworld.c | 7 | ||||
-rw-r--r-- | hw/ppc/spapr.c | 7 | ||||
-rw-r--r-- | hw/sh4/r2d.c | 2 | ||||
-rw-r--r-- | hw/usb/Makefile.objs | 3 | ||||
-rw-r--r-- | hw/usb/bus.c | 52 | ||||
-rw-r--r-- | hw/usb/dev-bluetooth.c | 11 | ||||
-rw-r--r-- | hw/usb/dev-network.c | 4 | ||||
-rw-r--r-- | hw/usb/dev-serial.c | 7 | ||||
-rw-r--r-- | hw/usb/dev-storage.c | 6 | ||||
-rw-r--r-- | hw/usb/host-legacy.c | 1 |
10 files changed, 53 insertions, 47 deletions
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index c3770121e2..624b4ab50b 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -420,11 +420,14 @@ static void ppc_core99_init(MachineState *machine) if (machine->usb) { pci_create_simple(pci_bus, -1, "pci-ohci"); + /* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */ if (machine_arch == ARCH_MAC99_U3) { - usbdevice_create("keyboard"); - usbdevice_create("mouse"); + USBBus *usb_bus = usb_bus_find(-1); + + usb_create_simple(usb_bus, "usb-kbd"); + usb_create_simple(usb_bus, "usb-mouse"); } } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 812d03054d..a82a0f99b3 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1533,9 +1533,12 @@ static void ppc_spapr_init(MachineState *machine) if (machine->usb) { pci_create_simple(phb->bus, -1, "pci-ohci"); + if (spapr->has_graphics) { - usbdevice_create("keyboard"); - usbdevice_create("mouse"); + USBBus *usb_bus = usb_bus_find(-1); + + usb_create_simple(usb_bus, "usb-kbd"); + usb_create_simple(usb_bus, "usb-mouse"); } } diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c index 12f44d28f0..d1d0847ba2 100644 --- a/hw/sh4/r2d.c +++ b/hw/sh4/r2d.c @@ -301,7 +301,7 @@ static void r2d_init(MachineState *machine) "rtl8139", i==0 ? "2" : NULL); /* USB keyboard */ - usbdevice_create("keyboard"); + usb_create_simple(usb_bus_find(-1), "usb-kbd"); /* Todo: register on board registers */ memset(&boot_params, 0, sizeof(boot_params)); diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs index 3fe4dff3bd..0ccd477577 100644 --- a/hw/usb/Makefile.objs +++ b/hw/usb/Makefile.objs @@ -5,7 +5,8 @@ common-obj-y += libhw.o # usb host adapters common-obj-$(CONFIG_USB_UHCI) += hcd-uhci.o common-obj-$(CONFIG_USB_OHCI) += hcd-ohci.o -common-obj-$(CONFIG_USB_EHCI) += hcd-ehci.o hcd-ehci-pci.o hcd-ehci-sysbus.o +common-obj-$(CONFIG_USB_EHCI) += hcd-ehci.o hcd-ehci-pci.o +common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 986b2d8da8..d83a93887f 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -315,23 +315,33 @@ USBDevice *usb_create(USBBus *bus, const char *name) return USB_DEVICE(dev); } -USBDevice *usb_create_simple(USBBus *bus, const char *name) +static USBDevice *usb_try_create_simple(USBBus *bus, const char *name, + Error **errp) { - USBDevice *dev = usb_create(bus, name); - int rc; + Error *err = NULL; + USBDevice *dev; + dev = USB_DEVICE(qdev_try_create(&bus->qbus, name)); if (!dev) { - error_report("Failed to create USB device '%s'", name); + error_setg(errp, "Failed to create USB device '%s'", name); return NULL; } - rc = qdev_init(&dev->qdev); - if (rc < 0) { - error_report("Failed to initialize USB device '%s'", name); + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err) { + error_setg(errp, "Failed to initialize USB device '%s': %s", + name, error_get_pretty(err)); + error_free(err); + object_unparent(OBJECT(dev)); return NULL; } return dev; } +USBDevice *usb_create_simple(USBBus *bus, const char *name) +{ + return usb_try_create_simple(bus, name, &error_abort); +} + static void usb_fill_port(USBPort *port, void *opaque, int index, USBPortOps *ops, int speedmask) { @@ -416,17 +426,17 @@ void usb_claim_port(USBDevice *dev, Error **errp) } } if (port == NULL) { - error_setg(errp, "Error: usb port %s (bus %s) not found (in use?)", + error_setg(errp, "usb port %s (bus %s) not found (in use?)", dev->port_path, bus->qbus.name); return; } } else { if (bus->nfree == 1 && strcmp(object_get_typename(OBJECT(dev)), "usb-hub") != 0) { /* Create a new hub and chain it on */ - usb_create_simple(bus, "usb-hub"); + usb_try_create_simple(bus, "usb-hub", NULL); } if (bus->nfree == 0) { - error_setg(errp, "Error: tried to attach usb device %s to a bus " + error_setg(errp, "tried to attach usb device %s to a bus " "with no free ports", dev->product_desc); return; } @@ -655,10 +665,12 @@ USBDevice *usbdevice_create(const char *cmdline) { USBBus *bus = usb_bus_find(-1 /* any */); LegacyUSBFactory *f = NULL; + Error *err = NULL; GSList *i; char driver[32]; const char *params; int len; + USBDevice *dev; params = strchr(cmdline,':'); if (params) { @@ -693,14 +705,28 @@ USBDevice *usbdevice_create(const char *cmdline) return NULL; } - if (!f->usbdevice_init) { + if (f->usbdevice_init) { + dev = f->usbdevice_init(bus, params); + } else { if (*params) { error_report("usbdevice %s accepts no params", driver); return NULL; } - return usb_create_simple(bus, f->name); + dev = usb_create(bus, f->name); + } + if (!dev) { + error_report("Failed to create USB device '%s'", f->name); + return NULL; } - return f->usbdevice_init(bus, params); + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err) { + error_report("Failed to initialize USB device '%s': %s", + f->name, error_get_pretty(err)); + error_free(err); + object_unparent(OBJECT(dev)); + return NULL; + } + return dev; } static void usb_device_class_init(ObjectClass *klass, void *data) diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index 390d475c16..9bf673057a 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -530,21 +530,12 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline) } else { hci = bt_new_hci(qemu_find_bt_vlan(0)); } - if (!hci) return NULL; + dev = usb_create(bus, name); - if (!dev) { - error_report("Failed to create USB device '%s'", name); - return NULL; - } s = DO_UPCAST(struct USBBtState, dev, dev); s->hci = hci; - if (qdev_init(&dev->qdev) < 0) { - error_report("Failed to initialize USB device '%s'", name); - return NULL; - } - return dev; } diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 5b95d5c382..7131abdb21 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1405,11 +1405,7 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline) } dev = usb_create(bus, "usb-net"); - if (!dev) { - return NULL; - } qdev_set_nic_properties(&dev->qdev, &nd_table[idx]); - qdev_init_nofail(&dev->qdev); return dev; } diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 1cee450259..67c2072ce7 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -544,16 +544,11 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename) return NULL; dev = usb_create(bus, "usb-serial"); - if (!dev) { - return NULL; - } qdev_prop_set_chr(&dev->qdev, "chardev", cdrv); if (vendorid) qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid); if (productid) qdev_prop_set_uint16(&dev->qdev, "productid", productid); - qdev_init_nofail(&dev->qdev); - return dev; } @@ -568,8 +563,6 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused) dev = usb_create(bus, "usb-braille"); qdev_prop_set_chr(&dev->qdev, "chardev", cdrv); - qdev_init_nofail(&dev->qdev); - return dev; } diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 4539733e42..af2e1b915d 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -706,17 +706,11 @@ static USBDevice *usb_msd_init(USBBus *bus, const char *filename) /* create guest device */ dev = usb_create(bus, "usb-storage"); - if (!dev) { - return NULL; - } if (qdev_prop_set_drive(&dev->qdev, "drive", blk_by_legacy_dinfo(dinfo)) < 0) { object_unparent(OBJECT(dev)); return NULL; } - if (qdev_init(&dev->qdev) < 0) - return NULL; - return dev; } diff --git a/hw/usb/host-legacy.c b/hw/usb/host-legacy.c index 3cc9c4282c..422ed9a65f 100644 --- a/hw/usb/host-legacy.c +++ b/hw/usb/host-legacy.c @@ -128,7 +128,6 @@ USBDevice *usb_host_device_open(USBBus *bus, const char *devname) qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr); qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id); qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id); - qdev_init_nofail(&dev->qdev); return dev; fail: |