From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qa471-0007As-Re for qemu-devel@nongnu.org; Fri, 24 Jun 2011 06:59:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qa46w-0001Wo-Iw for qemu-devel@nongnu.org; Fri, 24 Jun 2011 06:59:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qa46v-0001WS-ON for qemu-devel@nongnu.org; Fri, 24 Jun 2011 06:59:42 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5OAxe3m012744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Jun 2011 06:59:40 -0400 From: Gerd Hoffmann Date: Fri, 24 Jun 2011 12:59:23 +0200 Message-Id: <1308913175-10454-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1308913175-10454-1-git-send-email-kraxel@redhat.com> References: <1308913175-10454-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 01/13] usb-linux: add get_endp() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add a helper function to get the endpoint data structure and put it into use. Signed-off-by: Gerd Hoffmann --- usb-linux.c | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 5d2ec5c..3c6156a 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -142,74 +142,79 @@ 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 struct endp_data *get_endp(USBHostDevice *s, int ep) +{ + return s->endp_table + ep - 1; +} + static int is_isoc(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].type == USBDEVFS_URB_TYPE_ISO; + return get_endp(s, ep)->type == USBDEVFS_URB_TYPE_ISO; } static int is_valid(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].type != INVALID_EP_TYPE; + return get_endp(s, ep)->type != INVALID_EP_TYPE; } static int is_halted(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].halted; + return get_endp(s, ep)->halted; } static void clear_halt(USBHostDevice *s, int ep) { - s->endp_table[ep - 1].halted = 0; + get_endp(s, ep)->halted = 0; } static void set_halt(USBHostDevice *s, int ep) { - s->endp_table[ep - 1].halted = 1; + get_endp(s, ep)->halted = 1; } static int is_iso_started(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].iso_started; + return get_endp(s, ep)->iso_started; } static void clear_iso_started(USBHostDevice *s, int ep) { - s->endp_table[ep - 1].iso_started = 0; + get_endp(s, ep)->iso_started = 0; } static void set_iso_started(USBHostDevice *s, int ep) { - s->endp_table[ep - 1].iso_started = 1; + get_endp(s, ep)->iso_started = 1; } static void set_iso_urb(USBHostDevice *s, int ep, AsyncURB *iso_urb) { - s->endp_table[ep - 1].iso_urb = iso_urb; + get_endp(s, ep)->iso_urb = iso_urb; } static AsyncURB *get_iso_urb(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].iso_urb; + return get_endp(s, ep)->iso_urb; } static void set_iso_urb_idx(USBHostDevice *s, int ep, int i) { - s->endp_table[ep - 1].iso_urb_idx = i; + get_endp(s, ep)->iso_urb_idx = i; } static int get_iso_urb_idx(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].iso_urb_idx; + return get_endp(s, ep)->iso_urb_idx; } static void set_iso_buffer_used(USBHostDevice *s, int ep, int i) { - s->endp_table[ep - 1].iso_buffer_used = i; + get_endp(s, ep)->iso_buffer_used = i; } static int get_iso_buffer_used(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].iso_buffer_used; + return get_endp(s, ep)->iso_buffer_used; } static void set_max_packet_size(USBHostDevice *s, int ep, uint8_t *descriptor) @@ -223,14 +228,12 @@ static void set_max_packet_size(USBHostDevice *s, int ep, uint8_t *descriptor) case 2: microframes = 3; break; default: microframes = 1; break; } - DPRINTF("husb: max packet size: 0x%x -> %d x %d\n", - raw, microframes, size); - s->endp_table[ep - 1].max_packet_size = size * microframes; + get_endp(s, ep)->max_packet_size = size * microframes; } static int get_max_packet_size(USBHostDevice *s, int ep) { - return s->endp_table[ep - 1].max_packet_size; + return get_endp(s, ep)->max_packet_size; } /* -- 1.7.1