From: Adrian Szyndela Date: Thu, 22 Jul 2021 06:53:12 +0000 (+0200) Subject: gpio: don't allow direction change if there is poll/callback set X-Git-Tag: submit/tizen/20210813.142813~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F261656%2F5;p=platform%2Fcore%2Fapi%2Fperipheral-io.git gpio: don't allow direction change if there is poll/callback set This was missing. The function that sets the callback (peripheral_gpio_set_interrupted_cb()) exits with error if the direction is not "in". Therefore, the callback makes sense only when the direction is "in". Therefore, we don't want to allow changing the direction if there is a callback set. Change-Id: Ib21746ee4c32706a4114a76fbd0f6bd80bc9b787 --- diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 15cf494..b36f384 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -344,6 +344,9 @@ int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direct RETV_IF(gpio->direction == direction, PERIPHERAL_ERROR_NONE); RETV_IF(gpio->edge != PERIPHERAL_GPIO_EDGE_NONE, PERIPHERAL_ERROR_IO_ERROR); + RETVM_IF(gpio->cb_info.status != GPIO_INTERRUPTED_CALLBACK_UNSET, PERIPHERAL_ERROR_IO_ERROR, + "Can't change direction to OUT while 'interrupted_cb' is set"); + static const predefined_type_s types[3] = { {"in", 2}, {"high", 4},