[Spice-devel] [RFC PATCH] usbclerk: remove device from devs list upon driver removal
Uri Lublin
uril at redhat.com
Wed Oct 24 03:23:58 PDT 2012
---
This implements comment 1.
Maybe better to remove it from the list only if driver uninstall was successful
(check reply->status)
---
usbclerk.cpp | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/usbclerk.cpp b/usbclerk.cpp
index b5771b7..c95766f 100644
--- a/usbclerk.cpp
+++ b/usbclerk.cpp
@@ -34,6 +34,16 @@ typedef struct USBDev {
typedef std::list<USBDev> USBDevs;
+// compare two USBDevs
+class USBDevCompare
+{
+public:
+ USBDevCompare(USBDev &ud) : d(ud) {}
+ bool operator() (const USBDev& o) { return (d.vid == o.vid && d.pid == o.pid); }
+private:
+ const UsbDev& d;
+};
+
class USBClerk {
public:
static USBClerk* get();
@@ -398,6 +408,7 @@ bool USBClerk::dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply,
case USB_CLERK_DRIVER_REMOVE:
vd_printf("Removing winusb driver for %04x:%04x", dev.vid, dev.pid);
reply->status = remove_winusb_driver(dev.vid, dev.pid);
+ devs->remove_if((USBDevCompare(dev)));
break;
default:
vd_printf("Unknown message received, type %u", hdr->type);
--
1.7.1
More information about the Spice-devel
mailing list