From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Gerd Hoffmann 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> Subject: [Qemu-devel] [PATCH v4 23/32] usb: add attach callback List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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); -- 1.7.1