From patchwork Fri Dec 14 13:35:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 206501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 105492C00A3 for ; Sat, 15 Dec 2012 01:14:11 +1100 (EST) Received: from localhost ([::1]:48396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVQ5-0005yC-96 for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 08:35:17 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOp-0004N7-K6 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:34:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjVOo-0005LI-9x for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:33:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOo-0005LA-2k for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:33:58 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBEDXvX4021627 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 08:33:57 -0500 Received: from shalem.localdomain.com (vpn1-6-137.ams2.redhat.com [10.36.6.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBEDXST1028567; Fri, 14 Dec 2012 08:33:56 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Fri, 14 Dec 2012 14:35:42 +0100 Message-Id: <1355492147-5023-22-git-send-email-hdegoede@redhat.com> In-Reply-To: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> References: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 21/26] usbredir: Add USBEP2I and I2USBEP helper macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Hans de Goede --- hw/usb/redirect.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 4cf8780..7b2cd8c 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -43,6 +43,11 @@ #define NO_INTERFACE_INFO 255 /* Valid interface_count always <= 32 */ #define EP2I(ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f)) #define I2EP(i) (((i & 0x10) << 3) | (i & 0x0f)) +#define USBEP2I(usb_ep) (((usb_ep)->pid == USB_TOKEN_IN) ? \ + ((usb_ep)->nr | 0x10) : ((usb_ep)->nr)) +#define I2USBEP(d, i) (usb_ep_get(&(d)->dev, \ + ((i) & 0x10) ? USB_TOKEN_IN : USB_TOKEN_OUT, \ + (i) & 0x0f)) typedef struct USBRedirDevice USBRedirDevice; @@ -1373,11 +1378,10 @@ static void usbredir_set_pipeline(USBRedirDevice *dev, struct USBEndpoint *uep) static void usbredir_setup_usb_eps(USBRedirDevice *dev) { struct USBEndpoint *usb_ep; - int i, pid; + int i; for (i = 0; i < MAX_ENDPOINTS; i++) { - pid = (i & 0x10) ? USB_TOKEN_IN : USB_TOKEN_OUT; - usb_ep = usb_ep_get(&dev->dev, pid, i & 0x0f); + usb_ep = I2USBEP(dev, i); usb_ep->type = dev->endpoint[i].type; usb_ep->ifnum = dev->endpoint[i].interface; usb_ep->max_packet_size = dev->endpoint[i].max_packet_size;