gpio: don't do a pthread_kill if thread id is 0
authorBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 7 May 2014 16:45:02 +0000 (17:45 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 7 May 2014 16:45:02 +0000 (17:45 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/gpio/gpio.c

index ba5d590..e633e54 100644 (file)
@@ -187,7 +187,10 @@ maa_result_t
 maa_gpio_isr_exit(maa_gpio_context *dev)
 {
     maa_result_t ret = MAA_SUCCESS;
-    maa_gpio_edge_mode(dev, MAA_GPIO_EDGE_NONE);
+
+    if (dev->thread_id == 0) {
+        return ret;
+    }
 
     if (pthread_kill(dev->thread_id) != 0) {
        ret = MAA_ERROR_INVALID_HANDLE;
@@ -196,6 +199,11 @@ maa_gpio_isr_exit(maa_gpio_context *dev)
        ret = MAA_ERROR_INVALID_PARAMETER;
     }
 
+    // this is only required if we had an isr setup
+    if (ret == MAA_SUCCESS) {
+       ret = maa_gpio_edge_mode(dev, MAA_GPIO_EDGE_NONE);
+    }
+
     return ret;
 }