From patchwork Mon Nov 8 16:26:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 70433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 49956B6F07 for ; Tue, 9 Nov 2010 03:30:12 +1100 (EST) Received: from localhost ([127.0.0.1]:52364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFUbh-0004me-4F for incoming@patchwork.ozlabs.org; Mon, 08 Nov 2010 11:30:09 -0500 Received: from [140.186.70.92] (port=42625 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFUXH-0002G8-6z for qemu-devel@nongnu.org; Mon, 08 Nov 2010 11:25:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFUXC-0007wN-KS for qemu-devel@nongnu.org; Mon, 08 Nov 2010 11:25:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFUXC-0007vi-DZ for qemu-devel@nongnu.org; Mon, 08 Nov 2010 11:25:30 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA8GPR7N017373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Nov 2010 11:25:27 -0500 Received: from shalem.localdomain (vpn2-10-78.ams2.redhat.com [10.36.10.78]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA8GPN4A019743; Mon, 8 Nov 2010 11:25:25 -0500 From: Hans de Goede To: qemu-devel@nongnu.org Date: Mon, 8 Nov 2010 17:26:08 +0100 Message-Id: <1289233570-6529-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1289233570-6529-1-git-send-email-hdegoede@redhat.com> References: <1289233570-6529-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: spice-devel@lists.freedesktop.org, Gerd Hoffmann , Hans de Goede Subject: [Qemu-devel] [PATCH 1/3] usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This allows us to recreate the sysfspath used during scanning later (which will be used in a later patch in this series). --- usb-linux.c | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index c3c38ec..61e8ec6 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; @@ -1300,6 +1302,13 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func) if (sscanf(line, "%d", &addr) != 1) { goto the_end; } + if (!usb_host_read_file(line, sizeof(line), "devpath", + de->d_name)) { + goto the_end; + } + if (sscanf(line, "%d", &devpath) != 1) { + goto the_end; + } if (!usb_host_read_file(line, sizeof(line), "bDeviceClass", de->d_name)) { goto the_end; @@ -1343,7 +1352,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 +1443,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 +1479,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 +1639,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)