From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:35102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQUX-0000U7-HO for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzQUW-00029V-7e for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzQUV-00029J-Vb for qemu-devel@nongnu.org; Fri, 02 Sep 2011 05:56:52 -0400 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.14.4/8.14.4) with ESMTP id p829uoDT010872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Sep 2011 05:56:51 -0400 From: Gerd Hoffmann Date: Fri, 2 Sep 2011 11:56:32 +0200 Message-Id: <1314957407-29508-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1314957407-29508-1-git-send-email-kraxel@redhat.com> References: <1314957407-29508-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/18] usb-host: fix halted endpoints List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Two fixes for the price of one ;) First, reinitialize the endpoint table after device reset. This is needed anyway as the reset might have switched interfaces. It also clears the endpoint halted state. Second the CLEAR_HALT ioctl wants a unsigned int passed in as argument, not uint8_t. This gets my usb sd card reader (sandisk micromate) going. Signed-off-by: Gerd Hoffmann --- usb-linux.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 12e8772..344af22 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -143,6 +143,7 @@ static int parse_filter(const char *spec, struct USBAutoFilter *f); static void usb_host_auto_check(void *unused); static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name); +static int usb_linux_update_endp_table(USBHostDevice *s); static struct endp_data *get_endp(USBHostDevice *s, int ep) { @@ -512,6 +513,7 @@ static void usb_host_handle_reset(USBDevice *dev) ioctl(s->fd, USBDEVFS_RESET); usb_host_claim_interfaces(s, s->configuration); + usb_linux_update_endp_table(s); } static void usb_host_handle_destroy(USBDevice *dev) @@ -523,8 +525,6 @@ static void usb_host_handle_destroy(USBDevice *dev) qemu_remove_exit_notifier(&s->exit); } -static int usb_linux_update_endp_table(USBHostDevice *s); - /* iso data is special, we need to keep enough urbs in flight to make sure that the controller never runs out of them, otherwise the device will likely suffer a buffer underrun / overrun. */ @@ -732,7 +732,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) } if (is_halted(s, p->devep)) { - ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &ep); + unsigned int arg = ep; + ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &arg); if (ret < 0) { perror("USBDEVFS_CLEAR_HALT"); trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK); -- 1.7.1