From: Juergen Gross <jgross@suse.com>
To: kraxel@redhat.com, stefano.stabellini@eu.citrix.com,
xen-devel@lists.xensource.com
Cc: Juergen Gross <jgross@suse.com>
Subject: [Patch RFC 1/4] usb: support device specification via <bus>-<port>
Date: Thu, 16 Jul 2015 17:47:35 +0200 [thread overview]
Message-ID: <1437061658-11769-2-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1437061658-11769-1-git-send-email-jgross@suse.com>
Today a host usb device can be specified either via <vendor>:<product>
or via <bus>.<device> syntax. Add the possibility to specify it via
<bus>-<port> as this is needed for the support of xen pvusb backend.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
hw/usb/host-legacy.c | 56 +++++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/hw/usb/host-legacy.c b/hw/usb/host-legacy.c
index 3cc9c42..526108c 100644
--- a/hw/usb/host-legacy.c
+++ b/hw/usb/host-legacy.c
@@ -53,11 +53,6 @@ static int parse_filter(const char *spec, struct USBAutoFilter *f)
const char *p = spec;
int i;
- f->bus_num = 0;
- f->addr = 0;
- f->vendor_id = 0;
- f->product_id = 0;
-
for (i = BUS; i < DONE; i++) {
p = strpbrk(p, ":.");
if (!p) {
@@ -100,32 +95,47 @@ USBDevice *usb_host_device_open(USBBus *bus, const char *devname)
dev = usb_create(bus, "usb-host");
+ memset(&filter, 0, sizeof(filter));
+
if (strstr(devname, "auto:")) {
if (parse_filter(devname, &filter) < 0) {
goto fail;
}
- } else {
- p = strchr(devname, '.');
- if (p) {
- filter.bus_num = strtoul(devname, NULL, 0);
- filter.addr = strtoul(p + 1, NULL, 0);
- filter.vendor_id = 0;
- filter.product_id = 0;
- } else {
- p = strchr(devname, ':');
- if (p) {
- filter.bus_num = 0;
- filter.addr = 0;
- filter.vendor_id = strtoul(devname, NULL, 16);
- filter.product_id = strtoul(p + 1, NULL, 16);
- } else {
- goto fail;
- }
- }
+ goto out;
}
+ /* Check for <bus>-<port> specification. */
+ p = strchr(devname, '-');
+ if (p && p != devname) {
+ filter.bus_num = strtoul(devname, NULL, 0);
+ filter.port = p + 1;
+ goto out;
+ }
+
+ /* Check for <bus>.<addr> specification. */
+ p = strchr(devname, '.');
+ if (p) {
+ filter.bus_num = strtoul(devname, NULL, 0);
+ filter.addr = strtoul(p + 1, NULL, 0);
+ goto out;
+ }
+
+ /* Check for <vendorid>:<productid> specification. */
+ p = strchr(devname, ':');
+ if (p) {
+ filter.vendor_id = strtoul(devname, NULL, 16);
+ filter.product_id = strtoul(p + 1, NULL, 16);
+ goto out;
+ }
+
+ goto fail;
+
+out:
qdev_prop_set_uint32(&dev->qdev, "hostbus", filter.bus_num);
qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr);
+ if (filter.port) {
+ qdev_prop_set_string(&dev->qdev, "port", filter.port);
+ }
qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id);
qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
qdev_init_nofail(&dev->qdev);
--
2.1.4
next prev parent reply other threads:[~2015-07-16 15:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 15:47 [Patch RFC 0/4] usb, xen: add pvUSB backend Juergen Gross
2015-07-16 15:47 ` Juergen Gross [this message]
2015-07-17 6:59 ` [Patch RFC 1/4] usb: support device specification via <bus>-<port> Gerd Hoffmann
2015-07-17 7:32 ` Juergen Gross
2015-07-17 8:28 ` Gerd Hoffmann
2015-07-17 10:06 ` Juergen Gross
2015-07-17 10:23 ` Gerd Hoffmann
2015-07-17 10:25 ` Juergen Gross
2015-07-16 15:47 ` [Patch RFC 2/4] usb: add flag to USBPacket to request complete callback after isoc transfer Juergen Gross
2015-07-17 8:12 ` Gerd Hoffmann
2015-07-17 8:44 ` Juergen Gross
2015-07-17 9:23 ` Gerd Hoffmann
2015-07-17 10:14 ` Juergen Gross
2015-07-16 15:47 ` [Patch RFC 3/4] xen: introduce dummy system device Juergen Gross
2015-07-16 15:47 ` [Patch RFC 4/4] xen: add pvUSB backend Juergen Gross
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=1437061658-11769-2-git-send-email-jgross@suse.com \
--to=jgross@suse.com \
--cc=kraxel@redhat.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).