From patchwork Sat Nov 17 11:47:16 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: 199841 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 405582C0090 for ; Sat, 17 Nov 2012 22:57:41 +1100 (EST) Received: from localhost ([::1]:37711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZgqj-0007tU-49 for incoming@patchwork.ozlabs.org; Sat, 17 Nov 2012 06:46:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZgq0-00065O-A8 for qemu-devel@nongnu.org; Sat, 17 Nov 2012 06:45:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZgpx-00064i-8b for qemu-devel@nongnu.org; Sat, 17 Nov 2012 06:45:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZgpx-00064S-0f for qemu-devel@nongnu.org; Sat, 17 Nov 2012 06:45:25 -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 qAHBjOjU004956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 17 Nov 2012 06:45:24 -0500 Received: from shalem.localdomain.com (vpn1-5-33.ams2.redhat.com [10.36.5.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAHBjJM8009872; Sat, 17 Nov 2012 06:45:23 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Sat, 17 Nov 2012 12:47:16 +0100 Message-Id: <1353152838-26886-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1353152838-26886-1-git-send-email-hdegoede@redhat.com> References: <1353152838-26886-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 3/5] usb: Allow overriding of usb_desc at the device level 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 This allows devices to present a different set of descriptors based on device properties. Signed-off-by: Hans de Goede --- hw/usb.h | 1 + hw/usb/bus.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/hw/usb.h b/hw/usb.h index 58f812f..268e653 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -230,6 +230,7 @@ struct USBDevice { USBEndpoint ep_out[USB_MAX_ENDPOINTS]; QLIST_HEAD(, USBDescString) strings; + const USBDesc *usb_desc; /* Overrides class usb_desc if not NULL */ const USBDescDevice *device; int configuration; diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 99aac7a..fe26998 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -166,6 +166,9 @@ const char *usb_device_get_product_desc(USBDevice *dev) const USBDesc *usb_device_get_usb_desc(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); + if (dev->usb_desc) { + return dev->usb_desc; + } return klass->usb_desc; }