From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWmFk-0003ME-KC for qemu-devel@nongnu.org; Wed, 24 Sep 2014 09:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWmFe-0001nv-9p for qemu-devel@nongnu.org; Wed, 24 Sep 2014 09:05:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWmFe-0001nT-0a for qemu-devel@nongnu.org; Wed, 24 Sep 2014 09:04:58 -0400 Message-ID: <5422C168.9030001@redhat.com> Date: Wed, 24 Sep 2014 15:04:40 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411559299-19042-1-git-send-email-imammedo@redhat.com> <1411559299-19042-29-git-send-email-imammedo@redhat.com> <1411563641.30748.7.camel@nilsson.home.kraxel.org> In-Reply-To: <1411563641.30748.7.camel@nilsson.home.kraxel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 28/30] usb: convert to hotplug handler API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann , Igor Mammedov Cc: dmitry@daynix.com, mst@redhat.com, agraf@suse.de, qemu-devel@nongnu.org, cornelia.huck@de.ibm.com, amit.shah@redhat.com, borntraeger@de.ibm.com, rth@twiddle.net Il 24/09/2014 15:00, Gerd Hoffmann ha scritto: >> @@ -81,7 +81,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size, >> qbus_create_inplace(bus, bus_size, TYPE_USB_BUS, host, NULL); >> bus->ops = ops; >> bus->busnr = next_usb_bus++; >> - bus->qbus.allow_hotplug = 1; /* Yes, we can */ >> + qbus_set_hotplug_handler(BUS(bus), host, &error_abort); >> QTAILQ_INIT(&bus->free); >> QTAILQ_INIT(&bus->used); >> QTAILQ_INSERT_TAIL(&busses, bus, next); > >> diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c >> index d37ed02..91f7d87 100644 >> --- a/hw/usb/dev-smartcard-reader.c >> +++ b/hw/usb/dev-smartcard-reader.c >> @@ -1313,7 +1313,7 @@ static void ccid_realize(USBDevice *dev, Error **errp) >> qbus_create_inplace(&s->bus, sizeof(s->bus), TYPE_CCID_BUS, DEVICE(dev), >> NULL); >> s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP); >> - s->bus.qbus.allow_hotplug = 1; >> + qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(dev), &error_abort); > > That is the ccid (smartcard) bus, please make it a separate patch. > >> diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c >> index 490f2b6..b7990da 100644 >> --- a/hw/usb/hcd-ehci-pci.c >> +++ b/hw/usb/hcd-ehci-pci.c >> @@ -138,6 +138,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) >> { >> DeviceClass *dc = DEVICE_CLASS(klass); >> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); >> + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); >> >> k->init = usb_ehci_pci_initfn; >> k->exit = usb_ehci_pci_exit; >> @@ -145,6 +146,7 @@ static void ehci_class_init(ObjectClass *klass, void *data) >> k->config_write = usb_ehci_pci_write_config; >> dc->vmsd = &vmstate_ehci_pci; >> dc->props = ehci_pci_properties; >> + hc->unplug = qdev_simple_device_unplug_cb; >> } > > Can't we do this in usb_bus_new instead of duplicating in every host > adapter? So you would make TYPE_USB_BUS the hotplug handler itself, instead of the controller? That would make sense since TYPE_USB_BUS already coordinates hotplug/unplug with the HCD via the USBPortOps. Paolo