usb: replace handle_destroy with unrealize
Curiously, unrealize() is not being used, but it seems more appropriate than handle_destroy() together with realize(). It is more ubiquitous destroy name in qemu code base and may throw errors. Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20170221141451.28305-25-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
		
							parent
							
								
									796b288f7b
								
							
						
					
					
						commit
						c4fe9700e6
					
				@ -136,11 +136,12 @@ USBDevice *usb_device_find_device(USBDevice *dev, uint8_t addr)
 | 
				
			|||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_device_handle_destroy(USBDevice *dev)
 | 
					static void usb_device_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
 | 
					    USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
 | 
				
			||||||
    if (klass->handle_destroy) {
 | 
					
 | 
				
			||||||
        klass->handle_destroy(dev);
 | 
					    if (klass->unrealize) {
 | 
				
			||||||
 | 
					        klass->unrealize(dev, errp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -291,7 +292,7 @@ static void usb_qdev_unrealize(DeviceState *qdev, Error **errp)
 | 
				
			|||||||
    if (dev->attached) {
 | 
					    if (dev->attached) {
 | 
				
			||||||
        usb_device_detach(dev);
 | 
					        usb_device_detach(dev);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    usb_device_handle_destroy(dev);
 | 
					    usb_device_unrealize(dev, errp);
 | 
				
			||||||
    if (dev->port) {
 | 
					    if (dev->port) {
 | 
				
			||||||
        usb_release_port(dev);
 | 
					        usb_release_port(dev);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -617,7 +617,7 @@ static void usb_audio_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_audio_handle_destroy(USBDevice *dev)
 | 
					static void usb_audio_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBAudioState *s = USB_AUDIO(dev);
 | 
					    USBAudioState *s = USB_AUDIO(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -683,7 +683,7 @@ static void usb_audio_class_init(ObjectClass *klass, void *data)
 | 
				
			|||||||
    k->handle_reset   = usb_audio_handle_reset;
 | 
					    k->handle_reset   = usb_audio_handle_reset;
 | 
				
			||||||
    k->handle_control = usb_audio_handle_control;
 | 
					    k->handle_control = usb_audio_handle_control;
 | 
				
			||||||
    k->handle_data    = usb_audio_handle_data;
 | 
					    k->handle_data    = usb_audio_handle_data;
 | 
				
			||||||
    k->handle_destroy = usb_audio_handle_destroy;
 | 
					    k->unrealize      = usb_audio_unrealize;
 | 
				
			||||||
    k->set_interface  = usb_audio_set_interface;
 | 
					    k->set_interface  = usb_audio_set_interface;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -496,7 +496,7 @@ static void usb_bt_out_hci_packet_acl(void *opaque,
 | 
				
			|||||||
    usb_bt_fifo_enqueue(&s->acl, data, len);
 | 
					    usb_bt_fifo_enqueue(&s->acl, data, len);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_bt_handle_destroy(USBDevice *dev)
 | 
					static void usb_bt_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct USBBtState *s = (struct USBBtState *) dev->opaque;
 | 
					    struct USBBtState *s = (struct USBBtState *) dev->opaque;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -559,7 +559,7 @@ static void usb_bt_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_bt_handle_reset;
 | 
					    uc->handle_reset   = usb_bt_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_bt_handle_control;
 | 
					    uc->handle_control = usb_bt_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_bt_handle_data;
 | 
					    uc->handle_data    = usb_bt_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_bt_handle_destroy;
 | 
					    uc->unrealize      = usb_bt_unrealize;
 | 
				
			||||||
    dc->vmsd = &vmstate_usb_bt;
 | 
					    dc->vmsd = &vmstate_usb_bt;
 | 
				
			||||||
    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 | 
					    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -690,7 +690,7 @@ static void usb_hid_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_hid_handle_destroy(USBDevice *dev)
 | 
					static void usb_hid_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBHIDState *us = USB_HID(dev);
 | 
					    USBHIDState *us = USB_HID(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -785,7 +785,7 @@ static void usb_hid_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_hid_handle_reset;
 | 
					    uc->handle_reset   = usb_hid_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_hid_handle_control;
 | 
					    uc->handle_control = usb_hid_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_hid_handle_data;
 | 
					    uc->handle_data    = usb_hid_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_hid_handle_destroy;
 | 
					    uc->unrealize      = usb_hid_unrealize;
 | 
				
			||||||
    uc->handle_attach  = usb_desc_attach;
 | 
					    uc->handle_attach  = usb_desc_attach;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -497,7 +497,7 @@ static void usb_hub_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_hub_handle_destroy(USBDevice *dev)
 | 
					static void usb_hub_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBHubState *s = (USBHubState *)dev;
 | 
					    USBHubState *s = (USBHubState *)dev;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
@ -575,7 +575,7 @@ static void usb_hub_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_hub_handle_reset;
 | 
					    uc->handle_reset   = usb_hub_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_hub_handle_control;
 | 
					    uc->handle_control = usb_hub_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_hub_handle_data;
 | 
					    uc->handle_data    = usb_hub_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_hub_handle_destroy;
 | 
					    uc->unrealize      = usb_hub_unrealize;
 | 
				
			||||||
    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 | 
					    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 | 
				
			||||||
    dc->fw_name = "hub";
 | 
					    dc->fw_name = "hub";
 | 
				
			||||||
    dc->vmsd = &vmstate_usb_hub;
 | 
					    dc->vmsd = &vmstate_usb_hub;
 | 
				
			||||||
 | 
				
			|||||||
@ -1324,7 +1324,7 @@ static void usbnet_cleanup(NetClientState *nc)
 | 
				
			|||||||
    s->nic = NULL;
 | 
					    s->nic = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_net_handle_destroy(USBDevice *dev)
 | 
					static void usb_net_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBNetState *s = (USBNetState *) dev;
 | 
					    USBNetState *s = (USBNetState *) dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1428,7 +1428,7 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_net_handle_reset;
 | 
					    uc->handle_reset   = usb_net_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_net_handle_control;
 | 
					    uc->handle_control = usb_net_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_net_handle_data;
 | 
					    uc->handle_data    = usb_net_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_net_handle_destroy;
 | 
					    uc->unrealize      = usb_net_unrealize;
 | 
				
			||||||
    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 | 
					    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 | 
				
			||||||
    dc->fw_name = "network";
 | 
					    dc->fw_name = "network";
 | 
				
			||||||
    dc->vmsd = &vmstate_usb_net;
 | 
					    dc->vmsd = &vmstate_usb_net;
 | 
				
			||||||
 | 
				
			|||||||
@ -1163,7 +1163,7 @@ static void ccid_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ccid_handle_destroy(USBDevice *dev)
 | 
					static void ccid_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBCCIDState *s = USB_CCID_DEV(dev);
 | 
					    USBCCIDState *s = USB_CCID_DEV(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1470,7 +1470,7 @@ static void ccid_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = ccid_handle_reset;
 | 
					    uc->handle_reset   = ccid_handle_reset;
 | 
				
			||||||
    uc->handle_control = ccid_handle_control;
 | 
					    uc->handle_control = ccid_handle_control;
 | 
				
			||||||
    uc->handle_data    = ccid_handle_data;
 | 
					    uc->handle_data    = ccid_handle_data;
 | 
				
			||||||
    uc->handle_destroy = ccid_handle_destroy;
 | 
					    uc->unrealize      = ccid_unrealize;
 | 
				
			||||||
    dc->desc = "CCID Rev 1.1 smartcard reader";
 | 
					    dc->desc = "CCID Rev 1.1 smartcard reader";
 | 
				
			||||||
    dc->vmsd = &ccid_vmstate;
 | 
					    dc->vmsd = &ccid_vmstate;
 | 
				
			||||||
    dc->props = ccid_properties;
 | 
					    dc->props = ccid_properties;
 | 
				
			||||||
 | 
				
			|||||||
@ -891,7 +891,7 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_uas_handle_destroy(USBDevice *dev)
 | 
					static void usb_uas_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    UASDevice *uas = USB_UAS(dev);
 | 
					    UASDevice *uas = USB_UAS(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -944,7 +944,7 @@ static void usb_uas_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_uas_handle_reset;
 | 
					    uc->handle_reset   = usb_uas_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_uas_handle_control;
 | 
					    uc->handle_control = usb_uas_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_uas_handle_data;
 | 
					    uc->handle_data    = usb_uas_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_uas_handle_destroy;
 | 
					    uc->unrealize      = usb_uas_unrealize;
 | 
				
			||||||
    uc->attached_settable = true;
 | 
					    uc->attached_settable = true;
 | 
				
			||||||
    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 | 
					    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 | 
				
			||||||
    dc->fw_name = "storage";
 | 
					    dc->fw_name = "storage";
 | 
				
			||||||
 | 
				
			|||||||
@ -329,7 +329,7 @@ static void usb_wacom_handle_data(USBDevice *dev, USBPacket *p)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_wacom_handle_destroy(USBDevice *dev)
 | 
					static void usb_wacom_unrealize(USBDevice *dev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBWacomState *s = (USBWacomState *) dev;
 | 
					    USBWacomState *s = (USBWacomState *) dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -364,7 +364,7 @@ static void usb_wacom_class_init(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_reset   = usb_wacom_handle_reset;
 | 
					    uc->handle_reset   = usb_wacom_handle_reset;
 | 
				
			||||||
    uc->handle_control = usb_wacom_handle_control;
 | 
					    uc->handle_control = usb_wacom_handle_control;
 | 
				
			||||||
    uc->handle_data    = usb_wacom_handle_data;
 | 
					    uc->handle_data    = usb_wacom_handle_data;
 | 
				
			||||||
    uc->handle_destroy = usb_wacom_handle_destroy;
 | 
					    uc->unrealize      = usb_wacom_unrealize;
 | 
				
			||||||
    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 | 
					    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 | 
				
			||||||
    dc->desc = "QEMU PenPartner Tablet";
 | 
					    dc->desc = "QEMU PenPartner Tablet";
 | 
				
			||||||
    dc->vmsd = &vmstate_usb_wacom;
 | 
					    dc->vmsd = &vmstate_usb_wacom;
 | 
				
			||||||
 | 
				
			|||||||
@ -1065,7 +1065,7 @@ static void usb_host_instance_init(Object *obj)
 | 
				
			|||||||
                                  &udev->qdev, NULL);
 | 
					                                  &udev->qdev, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usb_host_handle_destroy(USBDevice *udev)
 | 
					static void usb_host_unrealize(USBDevice *udev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBHostDevice *s = USB_HOST_DEVICE(udev);
 | 
					    USBHostDevice *s = USB_HOST_DEVICE(udev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1568,7 +1568,7 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
    uc->handle_data    = usb_host_handle_data;
 | 
					    uc->handle_data    = usb_host_handle_data;
 | 
				
			||||||
    uc->handle_control = usb_host_handle_control;
 | 
					    uc->handle_control = usb_host_handle_control;
 | 
				
			||||||
    uc->handle_reset   = usb_host_handle_reset;
 | 
					    uc->handle_reset   = usb_host_handle_reset;
 | 
				
			||||||
    uc->handle_destroy = usb_host_handle_destroy;
 | 
					    uc->unrealize      = usb_host_unrealize;
 | 
				
			||||||
    uc->flush_ep_queue = usb_host_flush_ep_queue;
 | 
					    uc->flush_ep_queue = usb_host_flush_ep_queue;
 | 
				
			||||||
    uc->alloc_streams  = usb_host_alloc_streams;
 | 
					    uc->alloc_streams  = usb_host_alloc_streams;
 | 
				
			||||||
    uc->free_streams   = usb_host_free_streams;
 | 
					    uc->free_streams   = usb_host_free_streams;
 | 
				
			||||||
 | 
				
			|||||||
@ -1427,7 +1427,7 @@ static void usbredir_cleanup_device_queues(USBRedirDevice *dev)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void usbredir_handle_destroy(USBDevice *udev)
 | 
					static void usbredir_unrealize(USBDevice *udev, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    USBRedirDevice *dev = USB_REDIRECT(udev);
 | 
					    USBRedirDevice *dev = USB_REDIRECT(udev);
 | 
				
			||||||
    Chardev *chr = qemu_chr_fe_get_driver(&dev->cs);
 | 
					    Chardev *chr = qemu_chr_fe_get_driver(&dev->cs);
 | 
				
			||||||
@ -2513,7 +2513,7 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    uc->realize        = usbredir_realize;
 | 
					    uc->realize        = usbredir_realize;
 | 
				
			||||||
    uc->product_desc   = "USB Redirection Device";
 | 
					    uc->product_desc   = "USB Redirection Device";
 | 
				
			||||||
    uc->handle_destroy = usbredir_handle_destroy;
 | 
					    uc->unrealize      = usbredir_unrealize;
 | 
				
			||||||
    uc->cancel_packet  = usbredir_cancel_packet;
 | 
					    uc->cancel_packet  = usbredir_cancel_packet;
 | 
				
			||||||
    uc->handle_reset   = usbredir_handle_reset;
 | 
					    uc->handle_reset   = usbredir_handle_reset;
 | 
				
			||||||
    uc->handle_data    = usbredir_handle_data;
 | 
					    uc->handle_data    = usbredir_handle_data;
 | 
				
			||||||
 | 
				
			|||||||
@ -290,11 +290,6 @@ typedef struct USBDeviceClass {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    void (*cancel_packet)(USBDevice *dev, USBPacket *p);
 | 
					    void (*cancel_packet)(USBDevice *dev, USBPacket *p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
     * Called when device is destroyed.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    void (*handle_destroy)(USBDevice *dev);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
     * Attach the device
 | 
					     * Attach the device
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user