From: Gerd Hoffmann <kraxel@redhat.com>
To: "Gonglei (Arei)" <arei.gonglei@huawei.com>
Cc: Jan Vesely <jano.vesely@gmail.com>, QEMU <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn
Date: Fri, 26 Sep 2014 08:53:04 +0200 [thread overview]
Message-ID: <1411714384.865.2.camel@nilsson.home.kraxel.org> (raw)
In-Reply-To: <33183CC9F5247A488A2544077AF1902086DDBAE0@SZXEMA503-MBS.china.huawei.com>
Hi,
> > -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)
>
> I don't think it is a good idea that adding usb version as parameters.
> If we want to support usb3.0 tablet, we have to change usb_hid_initfn() too
> in the future and the usb-mouse, usb-kbd also need to changed despite
> usb-mouse and usb-kbd don't support it yet.
Adding a usb3 parameter should the need arise in the future (unlikely
IMO as xhci can handle all three usb speeds) isn't much of a problem I
think.
Error handling should be improved though:
> > {
> > 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"
> > + "(must be 1 or 2)", us->usb_version);
> > + return;
> > + }
This way it'll be possible to pass NULL for usb2 and have usb_hid_initfn
handle it correctly.
> > 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);
usb_hid_initfn(ev, HID_MOUSE, &desc_mouse, NULL, errp);
cheers,
Gerd
next prev parent reply other threads:[~2014-09-26 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 21:38 [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn Jan Vesely
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 [this message]
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=1411714384.865.2.camel@nilsson.home.kraxel.org \
--to=kraxel@redhat.com \
--cc=arei.gonglei@huawei.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).