|
| From: | Gerd Hoffmann |
| Subject: | Re: [Qemu-devel] [PATCH 2/2] Return usb device to host on exit |
| Date: | Wed, 16 Jun 2010 10:48:23 +0200 |
| User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100505 Fedora/3.0.4-2.el6 Thunderbird/3.0.4 |
+static void usb_host_cleanup(struct Notifier* n)
+{
+ struct USBHostDevice *s;
+
+ QTAILQ_FOREACH(s,&hostdevs, next) {
+ if (s->fd != -1) {
+ ioctl(s->fd, USBDEVFS_RESET);
+ }
+ }
+}
Well. The point of exit notifiers is that you don't need global variables for your cleanup work because the notifier function gets passed in a handle to your state data.
In that specific case the global hostdevs is needed anyway for other reasons. Nevertheless I don't want usb-linux.c set a bad example, but provide a good reference implementation for others to look at.
Patch attached (untested). cheers, Gerd
0001-usb-host-make-sure-we-release-the-device.patch
Description: Text document
| [Prev in Thread] | Current Thread | [Next in Thread] |