]> sigrok.org Git - libsigrok.git/commitdiff
Sigma: Check state in hw_closedev
authorHåvard Espeland <redacted>
Sat, 15 Jan 2011 13:03:08 +0000 (14:03 +0100)
committerHåvard Espeland <redacted>
Sat, 15 Jan 2011 13:13:23 +0000 (14:13 +0100)
If the device is closed without previously running hw_openedev
the driver crashes (happens in cleanup). This patch checks
if the device has been opened.

hardware/asix-sigma/asix-sigma.c

index d4d9fddfdaf6a765ffc50c52d134c832b8008549..cac386200f12a488f68a1ce4c371c6c7a3362e99 100644 (file)
@@ -644,9 +644,15 @@ static int configure_probes(GSList *probes)
 
 static void hw_closedev(int device_index)
 {
-       device_index = device_index;
+       struct sigrok_device_instance *sdi;
 
-       ftdi_usb_close(&ftdic);
+       if ((sdi = get_sigrok_device_instance(device_instances, device_index)))
+       {
+               if (sdi->status == ST_ACTIVE)
+                       ftdi_usb_close(&ftdic);
+
+               sdi->status = ST_INACTIVE;
+       }
 }
 
 static void hw_cleanup(void)