qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 28/30] usb: convert to hotplug handler API


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 28/30] usb: convert to hotplug handler API
Date: Wed, 24 Sep 2014 15:04:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]