usb-hid: simplify class initialization a bit
We can probably model USBHidDevice as a base class to get even better code sharing but for now, just use a common function to initialize the common class members. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
4c32fe66b9
commit
7f595609b4
27
hw/usb-hid.c
27
hw/usb-hid.c
@ -553,13 +553,10 @@ static const VMStateDescription vmstate_usb_kbd = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usb_tablet_class_initfn(ObjectClass *klass, void *data)
|
static void usb_hid_class_initfn(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
uc->init = usb_tablet_initfn;
|
|
||||||
uc->product_desc = "QEMU USB Tablet";
|
|
||||||
uc->usb_desc = &desc_tablet;
|
|
||||||
uc->handle_packet = usb_generic_handle_packet;
|
uc->handle_packet = usb_generic_handle_packet;
|
||||||
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;
|
||||||
@ -567,6 +564,16 @@ static void usb_tablet_class_initfn(ObjectClass *klass, void *data)
|
|||||||
uc->handle_destroy = usb_hid_handle_destroy;
|
uc->handle_destroy = usb_hid_handle_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usb_tablet_class_initfn(ObjectClass *klass, void *data)
|
||||||
|
{
|
||||||
|
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
|
usb_hid_class_initfn(klass, data);
|
||||||
|
uc->init = usb_tablet_initfn;
|
||||||
|
uc->product_desc = "QEMU USB Tablet";
|
||||||
|
uc->usb_desc = &desc_tablet;
|
||||||
|
}
|
||||||
|
|
||||||
static struct DeviceInfo usb_tablet_info = {
|
static struct DeviceInfo usb_tablet_info = {
|
||||||
.name = "usb-tablet",
|
.name = "usb-tablet",
|
||||||
.size = sizeof(USBHIDState),
|
.size = sizeof(USBHIDState),
|
||||||
@ -578,14 +585,10 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data)
|
|||||||
{
|
{
|
||||||
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
|
usb_hid_class_initfn(klass, data);
|
||||||
uc->init = usb_mouse_initfn;
|
uc->init = usb_mouse_initfn;
|
||||||
uc->product_desc = "QEMU USB Mouse";
|
uc->product_desc = "QEMU USB Mouse";
|
||||||
uc->usb_desc = &desc_mouse;
|
uc->usb_desc = &desc_mouse;
|
||||||
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;
|
|
||||||
uc->handle_destroy = usb_hid_handle_destroy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DeviceInfo usb_mouse_info = {
|
static struct DeviceInfo usb_mouse_info = {
|
||||||
@ -599,14 +602,10 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data)
|
|||||||
{
|
{
|
||||||
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
|
usb_hid_class_initfn(klass, data);
|
||||||
uc->init = usb_keyboard_initfn;
|
uc->init = usb_keyboard_initfn;
|
||||||
uc->product_desc = "QEMU USB Keyboard";
|
uc->product_desc = "QEMU USB Keyboard";
|
||||||
uc->usb_desc = &desc_keyboard;
|
uc->usb_desc = &desc_keyboard;
|
||||||
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;
|
|
||||||
uc->handle_destroy = usb_hid_handle_destroy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DeviceInfo usb_keyboard_info = {
|
static struct DeviceInfo usb_keyboard_info = {
|
||||||
|
Loading…
Reference in New Issue
Block a user