Skip to content

Commit

Permalink
usb: Convert usb devices to hotplug handler API
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
Igor Mammedov authored and afaerber committed Oct 15, 2014
1 parent 138d587 commit 5f4d917
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hw/usb/bus.c
Expand Up @@ -24,17 +24,23 @@ static Property usb_props[] = {
static void usb_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);

k->print_dev = usb_bus_dev_print;
k->get_dev_path = usb_get_dev_path;
k->get_fw_dev_path = usb_get_fw_dev_path;
hc->unplug = qdev_simple_device_unplug_cb;
}

static const TypeInfo usb_bus_info = {
.name = TYPE_USB_BUS,
.parent = TYPE_BUS,
.instance_size = sizeof(USBBus),
.class_init = usb_bus_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_HOTPLUG_HANDLER },
{ }
}
};

static int next_usb_bus = 0;
Expand Down Expand Up @@ -79,9 +85,9 @@ void usb_bus_new(USBBus *bus, size_t bus_size,
USBBusOps *ops, DeviceState *host)
{
qbus_create_inplace(bus, bus_size, TYPE_USB_BUS, host, NULL);
qbus_set_bus_hotplug_handler(BUS(bus), &error_abort);
bus->ops = ops;
bus->busnr = next_usb_bus++;
bus->qbus.allow_hotplug = 1; /* Yes, we can */
QTAILQ_INIT(&bus->free);
QTAILQ_INIT(&bus->used);
QTAILQ_INSERT_TAIL(&busses, bus, next);
Expand Down Expand Up @@ -701,7 +707,6 @@ static void usb_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
k->bus_type = TYPE_USB_BUS;
k->unplug = qdev_simple_unplug_cb;
k->realize = usb_qdev_realize;
k->unrealize = usb_qdev_unrealize;
k->props = usb_props;
Expand Down

0 comments on commit 5f4d917

Please sign in to comment.