mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
usb: kill handle_packet callback
All drivers except usb-hub use usb_generic_handle_packet. The only reason the usb hub has its own function is that it used to be called with packets which are intended for downstream devices. With the new, separate device lookup step this doesn't happen any more, so the need for a different handle_packet callback is gone. So we can kill the handle_packet callback and just call usb_generic_handle_packet directly. The special hub handling in usb_handle_packet() can go away for the same reason. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
e74495e3ad
commit
7f74a56b14
15 changed files with 4 additions and 83 deletions
|
@ -691,7 +691,6 @@ static void usb_audio_class_init(ObjectClass *klass, void *data)
|
|||
k->product_desc = "QEMU USB Audio Interface";
|
||||
k->usb_desc = &desc_audio;
|
||||
k->init = usb_audio_initfn;
|
||||
k->handle_packet = usb_generic_handle_packet;
|
||||
k->handle_reset = usb_audio_handle_reset;
|
||||
k->handle_control = usb_audio_handle_control;
|
||||
k->handle_data = usb_audio_handle_data;
|
||||
|
|
|
@ -535,7 +535,6 @@ static void usb_bt_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usb_bt_initfn;
|
||||
uc->product_desc = "QEMU BT dongle";
|
||||
uc->usb_desc = &desc_bluetooth;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_bt_handle_reset;
|
||||
uc->handle_control = usb_bt_handle_control;
|
||||
uc->handle_data = usb_bt_handle_data;
|
||||
|
|
|
@ -91,15 +91,6 @@ static void usb_device_handle_destroy(USBDevice *dev)
|
|||
}
|
||||
}
|
||||
|
||||
int usb_device_handle_packet(USBDevice *dev, USBPacket *p)
|
||||
{
|
||||
USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
|
||||
if (klass->handle_packet) {
|
||||
return klass->handle_packet(dev, p);
|
||||
}
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
void usb_device_cancel_packet(USBDevice *dev, USBPacket *p)
|
||||
{
|
||||
USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
|
||||
|
|
|
@ -1320,7 +1320,6 @@ static void ccid_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = ccid_initfn;
|
||||
uc->product_desc = "QEMU USB CCID";
|
||||
uc->usb_desc = &desc_ccid;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = ccid_handle_reset;
|
||||
uc->handle_control = ccid_handle_control;
|
||||
uc->handle_data = ccid_handle_data;
|
||||
|
|
|
@ -557,7 +557,6 @@ static void usb_hid_class_initfn(ObjectClass *klass, void *data)
|
|||
{
|
||||
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
||||
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_hid_handle_reset;
|
||||
uc->handle_control = usb_hid_handle_control;
|
||||
uc->handle_data = usb_hid_handle_data;
|
||||
|
|
39
hw/usb-hub.c
39
hw/usb-hub.c
|
@ -455,44 +455,6 @@ static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int usb_hub_broadcast_packet(USBHubState *s, USBPacket *p)
|
||||
{
|
||||
USBHubPort *port;
|
||||
USBDevice *dev;
|
||||
int i, ret;
|
||||
|
||||
for(i = 0; i < NUM_PORTS; i++) {
|
||||
port = &s->ports[i];
|
||||
dev = port->port.dev;
|
||||
if (dev && dev->attached && (port->wPortStatus & PORT_STAT_ENABLE)) {
|
||||
ret = usb_handle_packet(dev, p);
|
||||
if (ret != USB_RET_NODEV) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return USB_RET_NODEV;
|
||||
}
|
||||
|
||||
static int usb_hub_handle_packet(USBDevice *dev, USBPacket *p)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
|
||||
#if defined(DEBUG) && 0
|
||||
printf("usb_hub: pid=0x%x\n", pid);
|
||||
#endif
|
||||
if (dev->state == USB_STATE_DEFAULT &&
|
||||
dev->addr != 0 &&
|
||||
p->devaddr != dev->addr &&
|
||||
(p->pid == USB_TOKEN_SETUP ||
|
||||
p->pid == USB_TOKEN_OUT ||
|
||||
p->pid == USB_TOKEN_IN)) {
|
||||
/* broadcast the packet to the devices */
|
||||
return usb_hub_broadcast_packet(s, p);
|
||||
}
|
||||
return usb_generic_handle_packet(dev, p);
|
||||
}
|
||||
|
||||
static void usb_hub_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
|
@ -562,7 +524,6 @@ static void usb_hub_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->product_desc = "QEMU USB Hub";
|
||||
uc->usb_desc = &desc_hub;
|
||||
uc->find_device = usb_hub_find_device;
|
||||
uc->handle_packet = usb_hub_handle_packet;
|
||||
uc->handle_reset = usb_hub_handle_reset;
|
||||
uc->handle_control = usb_hub_handle_control;
|
||||
uc->handle_data = usb_hub_handle_data;
|
||||
|
|
|
@ -651,7 +651,6 @@ static void usb_msd_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usb_msd_initfn;
|
||||
uc->product_desc = "QEMU USB MSD";
|
||||
uc->usb_desc = &desc;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->cancel_packet = usb_msd_cancel_io;
|
||||
uc->handle_attach = usb_desc_attach;
|
||||
uc->handle_reset = usb_msd_handle_reset;
|
||||
|
|
|
@ -1398,7 +1398,6 @@ static void usb_net_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usb_net_initfn;
|
||||
uc->product_desc = "QEMU USB Network Interface";
|
||||
uc->usb_desc = &desc_net;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_net_handle_reset;
|
||||
uc->handle_control = usb_net_handle_control;
|
||||
uc->handle_data = usb_net_handle_data;
|
||||
|
|
|
@ -583,7 +583,6 @@ static void usb_serial_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usb_serial_initfn;
|
||||
uc->product_desc = "QEMU USB Serial";
|
||||
uc->usb_desc = &desc_serial;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_serial_handle_reset;
|
||||
uc->handle_control = usb_serial_handle_control;
|
||||
uc->handle_data = usb_serial_handle_data;
|
||||
|
@ -612,7 +611,6 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usb_serial_initfn;
|
||||
uc->product_desc = "QEMU USB Braille";
|
||||
uc->usb_desc = &desc_braille;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_serial_handle_reset;
|
||||
uc->handle_control = usb_serial_handle_control;
|
||||
uc->handle_data = usb_serial_handle_data;
|
||||
|
|
|
@ -357,7 +357,6 @@ static void usb_wacom_class_init(ObjectClass *klass, void *data)
|
|||
uc->product_desc = "QEMU PenPartner Tablet";
|
||||
uc->usb_desc = &desc_wacom;
|
||||
uc->init = usb_wacom_initfn;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_wacom_handle_reset;
|
||||
uc->handle_control = usb_wacom_handle_control;
|
||||
uc->handle_data = usb_wacom_handle_data;
|
||||
|
|
15
hw/usb.c
15
hw/usb.c
|
@ -227,7 +227,7 @@ static int do_token_out(USBDevice *s, USBPacket *p)
|
|||
*
|
||||
* Returns length of the transaction or one of the USB_RET_XXX codes.
|
||||
*/
|
||||
int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
|
||||
static int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
|
||||
{
|
||||
/* Rest of the PIDs must match our address */
|
||||
if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr)
|
||||
|
@ -318,18 +318,12 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
|
|||
if (dev == NULL) {
|
||||
return USB_RET_NODEV;
|
||||
}
|
||||
assert(dev->addr == p->devaddr);
|
||||
|
||||
assert(p->owner == NULL);
|
||||
ret = usb_device_handle_packet(dev, p);
|
||||
ret = usb_generic_handle_packet(dev, p);
|
||||
if (ret == USB_RET_ASYNC) {
|
||||
if (p->owner == NULL) {
|
||||
p->owner = usb_ep_get(dev, p->pid, p->devep);
|
||||
} else {
|
||||
/* We'll end up here when usb_handle_packet is called
|
||||
* recursively due to a hub being in the chain. Nothing
|
||||
* to do. Leave p->owner pointing to the device, not the
|
||||
* hub. */;
|
||||
}
|
||||
p->owner = usb_ep_get(dev, p->pid, p->devep);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -339,7 +333,6 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
|
|||
handle_packet. */
|
||||
void usb_packet_complete(USBDevice *dev, USBPacket *p)
|
||||
{
|
||||
/* Note: p->owner != dev is possible in case dev is a hub */
|
||||
assert(p->owner != NULL);
|
||||
p->owner = NULL;
|
||||
dev->port->ops->complete(dev->port, p);
|
||||
|
|
12
hw/usb.h
12
hw/usb.h
|
@ -234,15 +234,6 @@ typedef struct USBDeviceClass {
|
|||
*/
|
||||
USBDevice *(*find_device)(USBDevice *dev, uint8_t addr);
|
||||
|
||||
/*
|
||||
* Process USB packet.
|
||||
* Called by the HC (Host Controller).
|
||||
*
|
||||
* Returns length of the transaction
|
||||
* or one of the USB_RET_XXX codes.
|
||||
*/
|
||||
int (*handle_packet)(USBDevice *dev, USBPacket *p);
|
||||
|
||||
/*
|
||||
* Called when a packet is canceled.
|
||||
*/
|
||||
|
@ -360,7 +351,6 @@ void usb_detach(USBPort *port);
|
|||
void usb_port_reset(USBPort *port);
|
||||
void usb_device_reset(USBDevice *dev);
|
||||
void usb_wakeup(USBDevice *dev);
|
||||
int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
|
||||
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
|
||||
int set_usb_string(uint8_t *buf, const char *str);
|
||||
|
||||
|
@ -456,8 +446,6 @@ extern const VMStateDescription vmstate_usb_device;
|
|||
|
||||
USBDevice *usb_device_find_device(USBDevice *dev, uint8_t addr);
|
||||
|
||||
int usb_device_handle_packet(USBDevice *dev, USBPacket *p);
|
||||
|
||||
void usb_device_cancel_packet(USBDevice *dev, USBPacket *p);
|
||||
|
||||
void usb_device_handle_attach(USBDevice *dev);
|
||||
|
|
|
@ -403,7 +403,6 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data)
|
|||
|
||||
uc->product_desc = "USB Host Device";
|
||||
uc->init = usb_host_initfn;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->handle_reset = usb_host_handle_reset;
|
||||
uc->handle_control = usb_host_handle_control;
|
||||
uc->handle_data = usb_host_handle_data;
|
||||
|
|
|
@ -1419,7 +1419,6 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data)
|
|||
|
||||
uc->init = usb_host_initfn;
|
||||
uc->product_desc = "USB Host Device";
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->cancel_packet = usb_host_async_cancel;
|
||||
uc->handle_data = usb_host_handle_data;
|
||||
uc->handle_control = usb_host_handle_control;
|
||||
|
|
|
@ -1424,7 +1424,6 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data)
|
|||
uc->init = usbredir_initfn;
|
||||
uc->product_desc = "USB Redirection Device";
|
||||
uc->handle_destroy = usbredir_handle_destroy;
|
||||
uc->handle_packet = usb_generic_handle_packet;
|
||||
uc->cancel_packet = usbredir_cancel_packet;
|
||||
uc->handle_reset = usbredir_handle_reset;
|
||||
uc->handle_data = usbredir_handle_data;
|
||||
|
|
Loading…
Reference in a new issue