From: Jan Vesely <jano.vesely@gmail.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn
Date: Thu, 25 Sep 2014 17:38:12 -0400 [thread overview]
Message-ID: <1411681094-8474-1-git-send-email-jano.vesely@gmail.com> (raw)
v2: rebase
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
---
hw/usb/dev-hid.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 467ec86..90746ed 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -566,9 +566,23 @@ static void usb_hid_handle_destroy(USBDevice *dev)
hid_free(&us->hid);
}
-static void usb_hid_initfn(USBDevice *dev, int kind)
+static void usb_hid_initfn(USBDevice *dev, int kind,
+ const USBDesc *usb1, const USBDesc *usb2,
+ Error **errp)
{
USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
+ switch (us->usb_version) {
+ case 1:
+ dev->usb_desc = usb1;
+ break;
+ case 2:
+ dev->usb_desc = usb2;
+ break;
+ default:
+ error_setg(errp, "Invalid usb version %d for usb hid device"
+ "(must be 1 or 2)", us->usb_version);
+ return;
+ }
if (dev->serial) {
usb_desc_set_string(dev, STR_SERIALNUMBER, dev->serial);
@@ -583,32 +597,18 @@ static void usb_hid_initfn(USBDevice *dev, int kind)
static void usb_tablet_realize(USBDevice *dev, Error **errp)
{
- USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
-
- switch (us->usb_version) {
- case 1:
- dev->usb_desc = &desc_tablet;
- break;
- case 2:
- dev->usb_desc = &desc_tablet2;
- break;
- default:
- error_setg(errp, "Invalid usb version %d for usb-tablet "
- "(must be 1 or 2)", us->usb_version);
- return;
- }
- usb_hid_initfn(dev, HID_TABLET);
+ usb_hid_initfn(dev, HID_TABLET, &desc_tablet, &desc_tablet2, errp);
}
static void usb_mouse_realize(USBDevice *dev, Error **errp)
{
- usb_hid_initfn(dev, HID_MOUSE);
+ usb_hid_initfn(dev, HID_MOUSE, &desc_mouse, &desc_mouse, errp);
}
static void usb_keyboard_realize(USBDevice *dev, Error **errp)
{
- usb_hid_initfn(dev, HID_KEYBOARD);
+ usb_hid_initfn(dev, HID_KEYBOARD, &desc_keyboard, &desc_keyboard, errp);
}
static int usb_ptr_post_load(void *opaque, int version_id)
@@ -690,7 +690,6 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data)
usb_hid_class_initfn(klass, data);
uc->realize = usb_mouse_realize;
uc->product_desc = "QEMU USB Mouse";
- uc->usb_desc = &desc_mouse;
dc->vmsd = &vmstate_usb_ptr;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
@@ -715,7 +714,6 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data)
usb_hid_class_initfn(klass, data);
uc->realize = usb_keyboard_realize;
uc->product_desc = "QEMU USB Keyboard";
- uc->usb_desc = &desc_keyboard;
dc->vmsd = &vmstate_usb_kbd;
dc->props = usb_keyboard_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
--
1.9.3
next reply other threads:[~2014-09-25 21:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 21:38 Jan Vesely [this message]
2014-09-25 21:38 ` [Qemu-devel] [PATCH v4 2/3] usb-hid: Add high speed mouse configuration Jan Vesely
2014-09-26 7:06 ` Gerd Hoffmann
2014-09-26 14:43 ` Jan Vesely
2014-09-29 7:32 ` Gerd Hoffmann
2014-09-25 21:38 ` [Qemu-devel] [PATCH v2 3/3] usb-hid: Add high speed keyboard configuration Jan Vesely
2014-09-26 6:21 ` [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn Gonglei (Arei)
2014-09-26 6:53 ` Gerd Hoffmann
2014-09-26 7:11 ` Gonglei (Arei)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411681094-8474-1-git-send-email-jano.vesely@gmail.com \
--to=jano.vesely@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).