Skip to content

Commit 683ab8f

Browse files
pabigotgalak
authored andcommitted
gpio: add error return when blocking might occur
External GPIO drivers may not be supported from interrupt context because they involve blocking bus transactions. Describe the return value for this situation, and add the I/O error to operations where it was missing. Signed-off-by: Peter Bigot <[email protected]>
1 parent 8f68efb commit 683ab8f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/drivers/gpio.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ static inline int z_impl_gpio_disable_callback(struct device *port,
584584
* @retval -EINVAL Invalid argument.
585585
* @retval -EBUSY Interrupt line required to configure pin interrupt is
586586
* already in use.
587+
* @retval -EIO I/O error when accessing an external GPIO chip.
588+
* @retval -EWOULDBLOCK if operation would block.
587589
*/
588590
__syscall int gpio_pin_interrupt_configure(struct device *port,
589591
unsigned int pin, unsigned int flags);
@@ -629,6 +631,8 @@ static inline int z_impl_gpio_pin_interrupt_configure(struct device *port,
629631
* @retval 0 If successful.
630632
* @retval -ENOTSUP if any of the configuration options is not supported.
631633
* @retval -EINVAL Invalid argument.
634+
* @retval -EIO I/O error when accessing an external GPIO chip.
635+
* @retval -EWOULDBLOCK if operation would block.
632636
*/
633637
static inline int gpio_pin_configure(struct device *port, u32_t pin,
634638
unsigned int flags)
@@ -679,6 +683,7 @@ static inline int gpio_pin_configure(struct device *port, u32_t pin,
679683
*
680684
* @retval 0 If successful.
681685
* @retval -EIO I/O error when accessing an external GPIO chip.
686+
* @retval -EWOULDBLOCK if operation would block.
682687
*/
683688
__syscall int gpio_port_get_raw(struct device *port, gpio_port_value_t *value);
684689

@@ -707,6 +712,7 @@ static inline int z_impl_gpio_port_get_raw(struct device *port,
707712
*
708713
* @retval 0 If successful.
709714
* @retval -EIO I/O error when accessing an external GPIO chip.
715+
* @retval -EWOULDBLOCK if operation would block.
710716
*/
711717
static inline int gpio_port_get(struct device *port, gpio_port_value_t *value)
712718
{
@@ -737,6 +743,7 @@ static inline int gpio_port_get(struct device *port, gpio_port_value_t *value)
737743
*
738744
* @retval 0 If successful.
739745
* @retval -EIO I/O error when accessing an external GPIO chip.
746+
* @retval -EWOULDBLOCK if operation would block.
740747
*/
741748
__syscall int gpio_port_set_masked_raw(struct device *port,
742749
gpio_port_pins_t mask, gpio_port_value_t value);
@@ -768,6 +775,7 @@ static inline int z_impl_gpio_port_set_masked_raw(struct device *port,
768775
*
769776
* @retval 0 If successful.
770777
* @retval -EIO I/O error when accessing an external GPIO chip.
778+
* @retval -EWOULDBLOCK if operation would block.
771779
*/
772780
static inline int gpio_port_set_masked(struct device *port,
773781
gpio_port_pins_t mask, gpio_port_value_t value)
@@ -788,6 +796,7 @@ static inline int gpio_port_set_masked(struct device *port,
788796
*
789797
* @retval 0 If successful.
790798
* @retval -EIO I/O error when accessing an external GPIO chip.
799+
* @retval -EWOULDBLOCK if operation would block.
791800
*/
792801
__syscall int gpio_port_set_bits_raw(struct device *port,
793802
gpio_port_pins_t pins);
@@ -809,6 +818,7 @@ static inline int z_impl_gpio_port_set_bits_raw(struct device *port,
809818
*
810819
* @retval 0 If successful.
811820
* @retval -EIO I/O error when accessing an external GPIO chip.
821+
* @retval -EWOULDBLOCK if operation would block.
812822
*/
813823
static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins)
814824
{
@@ -823,6 +833,7 @@ static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins)
823833
*
824834
* @retval 0 If successful.
825835
* @retval -EIO I/O error when accessing an external GPIO chip.
836+
* @retval -EWOULDBLOCK if operation would block.
826837
*/
827838
__syscall int gpio_port_clear_bits_raw(struct device *port,
828839
gpio_port_pins_t pins);
@@ -844,6 +855,7 @@ static inline int z_impl_gpio_port_clear_bits_raw(struct device *port,
844855
*
845856
* @retval 0 If successful.
846857
* @retval -EIO I/O error when accessing an external GPIO chip.
858+
* @retval -EWOULDBLOCK if operation would block.
847859
*/
848860
static inline int gpio_port_clear_bits(struct device *port,
849861
gpio_port_pins_t pins)
@@ -859,6 +871,7 @@ static inline int gpio_port_clear_bits(struct device *port,
859871
*
860872
* @retval 0 If successful.
861873
* @retval -EIO I/O error when accessing an external GPIO chip.
874+
* @retval -EWOULDBLOCK if operation would block.
862875
*/
863876
__syscall int gpio_port_toggle_bits(struct device *port, gpio_port_pins_t pins);
864877

@@ -880,6 +893,7 @@ static inline int z_impl_gpio_port_toggle_bits(struct device *port,
880893
*
881894
* @retval 0 If successful.
882895
* @retval -EIO I/O error when accessing an external GPIO chip.
896+
* @retval -EWOULDBLOCK if operation would block.
883897
*/
884898
static inline int gpio_port_set_clr_bits_raw(struct device *port,
885899
gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
@@ -898,6 +912,7 @@ static inline int gpio_port_set_clr_bits_raw(struct device *port,
898912
*
899913
* @retval 0 If successful.
900914
* @retval -EIO I/O error when accessing an external GPIO chip.
915+
* @retval -EWOULDBLOCK if operation would block.
901916
*/
902917
static inline int gpio_port_set_clr_bits(struct device *port,
903918
gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
@@ -920,6 +935,7 @@ static inline int gpio_port_set_clr_bits(struct device *port,
920935
* @retval 1 If pin physical level is high.
921936
* @retval 0 If pin physical level is low.
922937
* @retval -EIO I/O error when accessing an external GPIO chip.
938+
* @retval -EWOULDBLOCK if operation would block.
923939
*/
924940
static inline int gpio_pin_get_raw(struct device *port, unsigned int pin)
925941
{
@@ -953,6 +969,7 @@ static inline int gpio_pin_get_raw(struct device *port, unsigned int pin)
953969
* @retval 1 If pin logical value is 1 / active.
954970
* @retval 0 If pin logical value is 0 / inactive.
955971
* @retval -EIO I/O error when accessing an external GPIO chip.
972+
* @retval -EWOULDBLOCK if operation would block.
956973
*/
957974
static inline int gpio_pin_get(struct device *port, unsigned int pin)
958975
{
@@ -982,6 +999,7 @@ static inline int gpio_pin_get(struct device *port, unsigned int pin)
982999
*
9831000
* @retval 0 If successful.
9841001
* @retval -EIO I/O error when accessing an external GPIO chip.
1002+
* @retval -EWOULDBLOCK if operation would block.
9851003
*/
9861004
static inline int gpio_pin_set_raw(struct device *port, unsigned int pin,
9871005
int value)
@@ -1018,6 +1036,7 @@ static inline int gpio_pin_set_raw(struct device *port, unsigned int pin,
10181036
*
10191037
* @retval 0 If successful.
10201038
* @retval -EIO I/O error when accessing an external GPIO chip.
1039+
* @retval -EWOULDBLOCK if operation would block.
10211040
*/
10221041
static inline int gpio_pin_set(struct device *port, unsigned int pin, int value)
10231042
{
@@ -1041,6 +1060,7 @@ static inline int gpio_pin_set(struct device *port, unsigned int pin, int value)
10411060
*
10421061
* @retval 0 If successful.
10431062
* @retval -EIO I/O error when accessing an external GPIO chip.
1063+
* @retval -EWOULDBLOCK if operation would block.
10441064
*/
10451065
static inline int gpio_pin_toggle(struct device *port, unsigned int pin)
10461066
{

0 commit comments

Comments
 (0)