From: Jan Vesely <jano.vesely@gmail.com>
To: Gerd Hoffmann <kraxel@redhat.com>, QEMU <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 1/3] usb-hid: Move descriptor decision to usb-hid initfn
Date: Thu, 11 Sep 2014 00:58:32 -0400 [thread overview]
Message-ID: <1410411514-20582-1-git-send-email-jano.vesely@gmail.com> (raw)
In-Reply-To: <1410411448.19969.1.camel@gmail.com>
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
---
hw/usb/dev-hid.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 67a57f1..b3d02b2 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -566,9 +566,22 @@ static void usb_hid_handle_destroy(USBDevice *dev)
hid_free(&us->hid);
}
-static int usb_hid_initfn(USBDevice *dev, int kind)
+static int usb_hid_initfn(USBDevice *dev, int kind,
+ const USBDesc *usb1, const USBDesc *usb2)
{
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_report("Invalid usb version %d for hid device (must be 1 or 2)",
+ us->usb_version);
+ return -1;
+ }
if (dev->serial) {
usb_desc_set_string(dev, STR_SERIALNUMBER, dev->serial);
@@ -584,32 +597,17 @@ static int usb_hid_initfn(USBDevice *dev, int kind)
static int usb_tablet_initfn(USBDevice *dev)
{
- 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_report("Invalid usb version %d for usb-tabler (must be 1 or 2)",
- us->usb_version);
- return -1;
- }
-
- return usb_hid_initfn(dev, HID_TABLET);
+ return usb_hid_initfn(dev, HID_TABLET, &desc_tablet, &desc_tablet2);
}
static int usb_mouse_initfn(USBDevice *dev)
{
- return usb_hid_initfn(dev, HID_MOUSE);
+ return usb_hid_initfn(dev, HID_MOUSE, &desc_mouse, &desc_mouse);
}
static int usb_keyboard_initfn(USBDevice *dev)
{
- return usb_hid_initfn(dev, HID_KEYBOARD);
+ return usb_hid_initfn(dev, HID_KEYBOARD, &desc_keyboard, &desc_keyboard);
}
static int usb_ptr_post_load(void *opaque, int version_id)
@@ -691,7 +689,6 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data)
usb_hid_class_initfn(klass, data);
uc->init = usb_mouse_initfn;
uc->product_desc = "QEMU USB Mouse";
- uc->usb_desc = &desc_mouse;
dc->vmsd = &vmstate_usb_ptr;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
@@ -716,7 +713,6 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data)
usb_hid_class_initfn(klass, data);
uc->init = usb_keyboard_initfn;
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 prev parent reply other threads:[~2014-09-11 4:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-16 5:41 [Qemu-devel] [PATCH 1/2] usb-hid: Add high speed mouse configuration Jan Vesely
2014-02-16 5:41 ` [Qemu-devel] [PATCH 2/2] usb-hid: Add high speed keyboard configuration Jan Vesely
2014-02-17 12:10 ` [Qemu-devel] [PATCH 1/2] usb-hid: Add high speed mouse configuration Gerd Hoffmann
2014-02-23 7:37 ` [Qemu-devel] [PATCH v2 " Jan Vesely
2014-02-23 7:37 ` [Qemu-devel] [PATCH v2 2/2] usb-hid: Add high speed keyboard configuration Jan Vesely
2014-03-17 17:53 ` [Qemu-devel] [PATCH v2 1/2] usb-hid: Add high speed mouse configuration Ján Veselý
2014-04-03 5:27 ` Ján Veselý
2014-04-07 8:02 ` Gerd Hoffmann
[not found] ` <CA+K+NcQZf-__sqSBTewBooUTUWMDP_m34iDVQX7YsHtUzAwb6g@mail.gmail.com>
[not found] ` <1397629640.23535.7.camel@nilsson.home.kraxel.org>
2014-09-11 4:57 ` Jan Vesely
2014-09-11 4:58 ` Jan Vesely [this message]
2014-09-11 4:58 ` [Qemu-devel] [PATCH v3 2/3] " Jan Vesely
2014-09-11 4:58 ` [Qemu-devel] [PATCH 3/3] usb-hid: Add high speed keyboard configuration Jan Vesely
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=1410411514-20582-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).