From patchwork Wed Jan 12 11:20:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 78571 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 67040B6F14 for ; Thu, 13 Jan 2011 00:33:56 +1100 (EST) Received: from localhost ([127.0.0.1]:45508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PczGs-0007oc-U3 for incoming@patchwork.ozlabs.org; Wed, 12 Jan 2011 06:53:47 -0500 Received: from [140.186.70.92] (port=56068 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pcyl1-00068i-Ie for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:20:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pcykz-0001Zf-Hc for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:20:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pcykz-0001ZN-6I for qemu-devel@nongnu.org; Wed, 12 Jan 2011 06:20:49 -0500 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.13.8/8.13.8) with ESMTP id p0CBKmE8002747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Jan 2011 06:20:48 -0500 Received: from rincewind.home.kraxel.org (vpn2-8-125.ams2.redhat.com [10.36.8.125]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0CBKjjY029932; Wed, 12 Jan 2011 06:20:47 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 0B9C041620; Wed, 12 Jan 2011 12:20:16 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 12 Jan 2011 12:20:05 +0100 Message-Id: <1294831214-4499-24-git-send-email-kraxel@redhat.com> In-Reply-To: <1294831214-4499-1-git-send-email-kraxel@redhat.com> References: <1294831214-4499-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v4 23/32] usb: add attach callback 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 Add handle_attach() callback to USBDeviceInfo which is called by the generic package handler when the device is attached to the usb bus (i.e. plugged into a port). Signed-off-by: Gerd Hoffmann --- hw/usb.c | 7 ++++++- hw/usb.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/hw/usb.c b/hw/usb.c index ba720b4..82a6217 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -194,6 +194,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p) switch(p->pid) { case USB_MSG_ATTACH: s->state = USB_STATE_ATTACHED; + if (s->info->handle_attach) { + s->info->handle_attach(s); + } return 0; case USB_MSG_DETACH: @@ -204,7 +207,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p) s->remote_wakeup = 0; s->addr = 0; s->state = USB_STATE_DEFAULT; - s->info->handle_reset(s); + if (s->info->handle_reset) { + s->info->handle_reset(s); + } return 0; } diff --git a/hw/usb.h b/hw/usb.h index 407a114..892ff72 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -194,6 +194,11 @@ struct USBDeviceInfo { void (*handle_destroy)(USBDevice *dev); /* + * Attach the device + */ + void (*handle_attach)(USBDevice *dev); + + /* * Reset the device */ void (*handle_reset)(USBDevice *dev);