(re)introduce clear of halt on endpoints,
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index a063974..51c5e1a 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -1092,38 +1092,62 @@
 
 static void clear_stall(PTP_USB* ptp_usb)
 {
-  uint16_t status=0;
+  uint16_t status;
   int ret;
   
   /* check the inep status */
+  status = 0;
   ret = usb_get_endpoint_status(ptp_usb,ptp_usb->inep,&status);
-  if (ret<0) perror ("inep: usb_get_endpoint_status()");
-  /* and clear the HALT condition if happend */
-  else if (status) {
-    printf("Resetting input pipe!\n");
-    ret=usb_clear_stall_feature(ptp_usb,ptp_usb->inep);
-    /*usb_clear_halt(ptp_usb->handle,ptp_usb->inep); */
-    if (ret<0)perror ("usb_clear_stall_feature()");
+  if (ret<0) {
+    perror ("inep: usb_get_endpoint_status()");
+  } else if (status) {
+    printf("Clearing stall on IN endpoint\n");
+    ret = usb_clear_stall_feature(ptp_usb,ptp_usb->inep);
+    if (ret<0) {
+      perror ("usb_clear_stall_feature()");
+    }
   }
-  status=0;
   
   /* check the outep status */
-  ret=usb_get_endpoint_status(ptp_usb,ptp_usb->outep,&status);
-  if (ret<0) perror ("outep: usb_get_endpoint_status()");
-  /* and clear the HALT condition if happend */
-  else if (status) {
-    printf("Resetting output pipe!\n");
-    ret=usb_clear_stall_feature(ptp_usb,ptp_usb->outep);
-    /*usb_clear_halt(ptp_usb->handle,ptp_usb->outep); */
-    if (ret<0)perror ("usb_clear_stall_feature()");
+  status=0;
+  ret = usb_get_endpoint_status(ptp_usb,ptp_usb->outep,&status);
+  if (ret<0) {
+    perror("outep: usb_get_endpoint_status()");
+  } else if (status) {
+    printf("Clearing stall on OUT endpoint\n");
+    ret = usb_clear_stall_feature(ptp_usb,ptp_usb->outep);
+    if (ret<0) {
+      perror("usb_clear_stall_feature()");
+    }
   }
-  
-  /*usb_clear_halt(ptp_usb->handle,ptp_usb->intep); */
+
+  /* TODO: do we need this for INTERRUPT (ptp_usb->intep) too? */
+}
+
+static void clear_halt(PTP_USB* ptp_usb)
+{
+  int ret;
+
+  ret = usb_clear_halt(ptp_usb->handle,ptp_usb->inep);
+  if (ret<0) {
+    perror("usb_clear_halt() on IN endpoint");
+  }
+  ret = usb_clear_halt(ptp_usb->handle,ptp_usb->outep);
+  if (ret<0) {
+    perror("usb_clear_halt() on OUT endpoint");
+  }
+  ret = usb_clear_halt(ptp_usb->handle,ptp_usb->intep);
+  if (ret<0) {
+    perror("usb_clear_halt() on INTERRUPT endpoint");
+  }
 }
 
 static void close_usb(PTP_USB* ptp_usb, uint8_t interfaceNumber)
 {
+  // Clear any stalled endpoints
   clear_stall(ptp_usb);
+  // Clear halts on any endpoints
+  clear_halt(ptp_usb);
   // Added to clear some stuff on the OUT endpoint
   // TODO: is this good on the Mac too?
   usb_resetep(ptp_usb->handle, ptp_usb->outep);