From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jan Vesely <jano.vesely@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 1/4] usb-hid: Move descriptor decision to usb-hid initfn
Date: Wed, 15 Oct 2014 13:52:30 +0200 [thread overview]
Message-ID: <1413373953-19493-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1413373953-19493-1-git-send-email-kraxel@redhat.com>
From: Jan Vesely <jano.vesely@gmail.com>
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/dev-hid.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 467ec86..5d37d63 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -566,9 +566,26 @@ 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:
+ dev->usb_desc = NULL;
+ }
+ if (!dev->usb_desc) {
+ error_setg(errp, "Invalid usb version %d for usb hid device",
+ us->usb_version);
+ return;
+ }
if (dev->serial) {
usb_desc_set_string(dev, STR_SERIALNUMBER, dev->serial);
@@ -583,32 +600,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, NULL, errp);
}
static void usb_keyboard_realize(USBDevice *dev, Error **errp)
{
- usb_hid_initfn(dev, HID_KEYBOARD);
+ usb_hid_initfn(dev, HID_KEYBOARD, &desc_keyboard, NULL, errp);
}
static int usb_ptr_post_load(void *opaque, int version_id)
@@ -690,7 +693,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 +717,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.8.3.1
next prev parent reply other threads:[~2014-10-15 11:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 11:52 [Qemu-devel] [PULL 0/4] usb: add high speed mouse & keyboard configuration Gerd Hoffmann
2014-10-15 11:52 ` Gerd Hoffmann [this message]
2014-10-15 11:52 ` [Qemu-devel] [PULL 2/4] usb-hid: Add high speed mouse configuration Gerd Hoffmann
2014-10-15 11:52 ` [Qemu-devel] [PULL 3/4] usb-hid: Add high speed keyboard configuration Gerd Hoffmann
2014-10-15 11:52 ` [Qemu-devel] [PULL 4/4] xhci: remove dead code Gerd Hoffmann
2014-10-22 15:39 ` [Qemu-devel] [PULL 0/4] usb: add high speed mouse & keyboard configuration Peter Maydell
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=1413373953-19493-2-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=jano.vesely@gmail.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).