From: Anthony Liguori <anthony@codemonkey.ws>
To: Hans de Goede <hdegoede@redhat.com>
Cc: spice-devel@lists.freedesktop.org, qemu-devel@nongnu.org,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYS
Date: Tue, 16 Nov 2010 16:25:21 -0600 [thread overview]
Message-ID: <4CE304D1.8010801@codemonkey.ws> (raw)
In-Reply-To: <1289379985-12554-2-git-send-email-hdegoede@redhat.com>
On 11/10/2010 03:06 AM, Hans de Goede wrote:
> This allows us to recreate the sysfspath used during scanning later
> (which will be used in a later patch in this series).
>
Applied all three. Thanks.
Regards,
Anthony Liguori
> ---
> usb-linux.c | 26 +++++++++++++++-----------
> 1 files changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/usb-linux.c b/usb-linux.c
> index c3c38ec..0b154c2 100644
> --- a/usb-linux.c
> +++ b/usb-linux.c
> @@ -62,8 +62,8 @@ struct usb_ctrlrequest {
> uint16_t wLength;
> };
>
> -typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id,
> - int vendor_id, int product_id,
> +typedef int USBScanFunc(void *opaque, int bus_num, int addr, int devpath,
> + int class_id, int vendor_id, int product_id,
> const char *product_name, int speed);
>
> //#define DEBUG
> @@ -141,6 +141,7 @@ typedef struct USBHostDevice {
> /* Host side address */
> int bus_num;
> int addr;
> + int devpath;
> struct USBAutoFilter match;
>
> QTAILQ_ENTRY(USBHostDevice) next;
> @@ -885,7 +886,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
> }
>
> static int usb_host_open(USBHostDevice *dev, int bus_num,
> - int addr, const char *prod_name)
> + int addr, int devpath, const char *prod_name)
> {
> int fd = -1, ret;
> struct usbdevfs_connectinfo ci;
> @@ -911,6 +912,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
>
> dev->bus_num = bus_num;
> dev->addr = addr;
> + dev->devpath = devpath;
> dev->fd = fd;
>
> /* read the device description */
> @@ -1173,7 +1175,7 @@ static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
> if (line[0] == 'T'&& line[1] == ':') {
> if (device_count&& (vendor_id || product_id)) {
> /* New device. Add the previously discovered device. */
> - ret = func(opaque, bus_num, addr, class_id, vendor_id,
> + ret = func(opaque, bus_num, addr, 0, class_id, vendor_id,
> product_id, product_name, speed);
> if (ret) {
> goto the_end;
> @@ -1226,7 +1228,7 @@ static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
> }
> if (device_count&& (vendor_id || product_id)) {
> /* Add the last device. */
> - ret = func(opaque, bus_num, addr, class_id, vendor_id,
> + ret = func(opaque, bus_num, addr, 0, class_id, vendor_id,
> product_id, product_name, speed);
> }
> the_end:
> @@ -1275,7 +1277,7 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
> {
> DIR *dir = NULL;
> char line[1024];
> - int bus_num, addr, speed, class_id, product_id, vendor_id;
> + int bus_num, addr, devpath, speed, class_id, product_id, vendor_id;
> int ret = 0;
> char product_name[512];
> struct dirent *de;
> @@ -1292,7 +1294,9 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
> if (!strncmp(de->d_name, "usb", 3)) {
> tmpstr += 3;
> }
> - bus_num = atoi(tmpstr);
> + if (sscanf(tmpstr, "%d-%d",&bus_num,&devpath)< 1) {
> + goto the_end;
> + }
>
> if (!usb_host_read_file(line, sizeof(line), "devnum", de->d_name)) {
> goto the_end;
> @@ -1343,7 +1347,7 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
> speed = USB_SPEED_FULL;
> }
>
> - ret = func(opaque, bus_num, addr, class_id, vendor_id,
> + ret = func(opaque, bus_num, addr, devpath, class_id, vendor_id,
> product_id, product_name, speed);
> if (ret) {
> goto the_end;
> @@ -1434,7 +1438,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
>
> static QEMUTimer *usb_auto_timer;
>
> -static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
> +static int usb_host_auto_scan(void *opaque, int bus_num, int addr, int devpath,
> int class_id, int vendor_id, int product_id,
> const char *product_name, int speed)
> {
> @@ -1470,7 +1474,7 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
> }
> DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
>
> - usb_host_open(s, bus_num, addr, product_name);
> + usb_host_open(s, bus_num, addr, devpath, product_name);
> }
>
> return 0;
> @@ -1630,7 +1634,7 @@ static void usb_info_device(Monitor *mon, int bus_num, int addr, int class_id,
> }
>
> static int usb_host_info_device(void *opaque, int bus_num, int addr,
> - int class_id,
> + int devpath, int class_id,
> int vendor_id, int product_id,
> const char *product_name,
> int speed)
>
next prev parent reply other threads:[~2010-11-16 22:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 9:06 [Qemu-devel] [PATCH 0/3] usb-linux do not send unnecessary GET_CONFIGURATION (v2) Hans de Goede
2010-11-10 9:06 ` [Qemu-devel] [PATCH 1/3] usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYS Hans de Goede
2010-11-16 22:25 ` Anthony Liguori [this message]
2010-11-10 9:06 ` [Qemu-devel] [PATCH 2/3] usb-linux: introduce a usb_linux_get_configuration function Hans de Goede
2010-11-10 9:06 ` [Qemu-devel] [PATCH 3/3] usb-linux: Get the active configuration from sysfs rather then asking the dev Hans de Goede
-- strict thread matches above, loose matches on Subject: below --
2010-11-08 16:26 [Qemu-devel] [PATCH 0/3] usb-linux do not send unnecessary GET_CONFIGURATION Hans de Goede
2010-11-08 16:26 ` [Qemu-devel] [PATCH 1/3] usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYS Hans de Goede
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=4CE304D1.8010801@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=hdegoede@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=spice-devel@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.