All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shahar Havivi <shaharh@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	"David S. Ahern" <daahern@cisco.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Release usb devices on shutdown and usb_del command
Date: Fri, 21 May 2010 20:55:24 +0300	[thread overview]
Message-ID: <20100521175520.GA25276@redhat.com> (raw)
In-Reply-To: <4BF62D5B.9050809@redhat.com>

Remove usb_host_device_release and using usb_host_close to handle usb_del command.
Gerd, What do you think about the usb_cleanup()?
If it will be in usb-linux.c we will
have to ad atexit to each device, if we usb-bus.c we will have to implement in
bsd and stub...

Signed-off-by: Shahar Havivi <shaharh@redhat.com>
---
 hw/usb.h    |    1 +
 usb-bsd.c   |    5 +++++
 usb-linux.c |   12 ++++++++++++
 usb-stub.c  |    5 +++++
 vl.c        |    1 +
 5 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/hw/usb.h b/hw/usb.h
index 00d2802..7ddf63c 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -258,6 +258,7 @@ void usb_send_msg(USBDevice *dev, int msg);
 USBDevice *usb_host_device_open(const char *devname);
 int usb_host_device_close(const char *devname);
 void usb_host_info(Monitor *mon);
+void usb_cleanup(void);
 
 /* usb-hid.c */
 void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *));
diff --git a/usb-bsd.c b/usb-bsd.c
index 48567a3..c3eb891 100644
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -634,3 +634,8 @@ int usb_host_device_close(const char *devname)
 {
     return 0;
 }
+
+void usb_cleanup(void)
+{
+    return 0;
+}
diff --git a/usb-linux.c b/usb-linux.c
index 88273ff..98909b7 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -286,6 +286,17 @@ static void async_cancel(USBPacket *unused, void *opaque)
     }
 }
 
+void usb_cleanup(void)
+{
+    struct USBHostDevice *s;
+
+    QTAILQ_FOREACH(s, &hostdevs, next) {
+        if (s->fd != -1) {
+            ioctl(s->fd, USBDEVFS_RESET);
+        }
+    }
+}
+
 static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
 {
     int dev_descr_len, config_descr_len;
@@ -991,6 +1002,7 @@ static int usb_host_close(USBHostDevice *dev)
     async_complete(dev);
     dev->closing = 0;
     usb_device_detach(&dev->dev);
+    ioctl(dev->fd, USBDEVFS_RESET);
     close(dev->fd);
     dev->fd = -1;
     return 0;
diff --git a/usb-stub.c b/usb-stub.c
index 9c3fcea..bb513de 100644
--- a/usb-stub.c
+++ b/usb-stub.c
@@ -50,3 +50,8 @@ int usb_host_device_close(const char *devname)
 {
     return 0;
 }
+
+void usb_cleanup(void)
+{
+    return 0;
+}
diff --git a/vl.c b/vl.c
index d77b47c..e3f4dc9 100644
--- a/vl.c
+++ b/vl.c
@@ -3914,6 +3914,7 @@ int main(int argc, char **argv, char **envp)
     main_loop();
     quit_timers();
     net_cleanup();
+    usb_cleanup();
 
     return 0;
 }
-- 
1.7.0.4

  reply	other threads:[~2010-05-21 17:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 18:10 [Qemu-devel] [PATCH v2] Release usb devices on shutdown and usb_del command Shahar Havivi
2010-05-19 18:43 ` David S. Ahern
2010-05-21  6:33   ` Markus Armbruster
2010-05-21  6:51     ` Gerd Hoffmann
2010-05-21 17:55       ` Shahar Havivi [this message]
2010-05-25  8:58         ` [Qemu-devel] Re: [PATCH] " Gerd Hoffmann
2010-05-26  8:48           ` Shahar Havivi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100521175520.GA25276@redhat.com \
    --to=shaharh@redhat.com \
    --cc=armbru@redhat.com \
    --cc=daahern@cisco.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.