From 356c7afacd6eacc278ce15d8facf4284c83215a4 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 7 May 2014 17:45:02 +0100 Subject: [PATCH] gpio: don't do a pthread_kill if thread id is 0 Signed-off-by: Brendan Le Foll --- src/gpio/gpio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index ba5d590..e633e54 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -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; } -- 2.7.4