Skip to content

Commit

Permalink
gpio: add error return when blocking might occur
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pabigot committed Sep 25, 2019
1 parent e5ed5c6 commit dc20b2b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/drivers/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ static inline int z_impl_gpio_disable_callback(struct device *port,
* @retval -EINVAL Invalid argument.
* @retval -EBUSY Interrupt line required to configure pin interrupt is
* already in use.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_pin_interrupt_configure(struct device *port,
unsigned int pin, unsigned int flags);
Expand Down Expand Up @@ -629,6 +631,8 @@ static inline int z_impl_gpio_pin_interrupt_configure(struct device *port,
* @retval 0 If successful.
* @retval -ENOTSUP if any of the configuration options is not supported.
* @retval -EINVAL Invalid argument.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_configure(struct device *port, u32_t pin,
unsigned int flags)
Expand Down Expand Up @@ -679,6 +683,7 @@ static inline int gpio_pin_configure(struct device *port, u32_t pin,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_port_get_raw(struct device *port, gpio_port_value_t *value);

Expand Down Expand Up @@ -707,6 +712,7 @@ static inline int z_impl_gpio_port_get_raw(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_get(struct device *port, gpio_port_value_t *value)
{
Expand Down Expand Up @@ -737,6 +743,7 @@ static inline int gpio_port_get(struct device *port, gpio_port_value_t *value)
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_port_set_masked_raw(struct device *port,
gpio_port_pins_t mask, gpio_port_value_t value);
Expand Down Expand Up @@ -768,6 +775,7 @@ static inline int z_impl_gpio_port_set_masked_raw(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_set_masked(struct device *port,
gpio_port_pins_t mask, gpio_port_value_t value)
Expand All @@ -788,6 +796,7 @@ static inline int gpio_port_set_masked(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_port_set_bits_raw(struct device *port,
gpio_port_pins_t pins);
Expand All @@ -809,6 +818,7 @@ static inline int z_impl_gpio_port_set_bits_raw(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins)
{
Expand All @@ -823,6 +833,7 @@ static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins)
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_port_clear_bits_raw(struct device *port,
gpio_port_pins_t pins);
Expand All @@ -844,6 +855,7 @@ static inline int z_impl_gpio_port_clear_bits_raw(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_clear_bits(struct device *port,
gpio_port_pins_t pins)
Expand All @@ -859,6 +871,7 @@ static inline int gpio_port_clear_bits(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
__syscall int gpio_port_toggle_bits(struct device *port, gpio_port_pins_t pins);

Expand All @@ -880,6 +893,7 @@ static inline int z_impl_gpio_port_toggle_bits(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_set_clr_bits_raw(struct device *port,
gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
Expand All @@ -898,6 +912,7 @@ static inline int gpio_port_set_clr_bits_raw(struct device *port,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_port_set_clr_bits(struct device *port,
gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
Expand All @@ -920,6 +935,7 @@ static inline int gpio_port_set_clr_bits(struct device *port,
* @retval 1 If pin physical level is high.
* @retval 0 If pin physical level is low.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_get_raw(struct device *port, unsigned int pin)
{
Expand Down Expand Up @@ -953,6 +969,7 @@ static inline int gpio_pin_get_raw(struct device *port, unsigned int pin)
* @retval 1 If pin logical value is 1 / active.
* @retval 0 If pin logical value is 0 / inactive.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_get(struct device *port, unsigned int pin)
{
Expand Down Expand Up @@ -982,6 +999,7 @@ static inline int gpio_pin_get(struct device *port, unsigned int pin)
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_set_raw(struct device *port, unsigned int pin,
int value)
Expand Down Expand Up @@ -1018,6 +1036,7 @@ static inline int gpio_pin_set_raw(struct device *port, unsigned int pin,
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_set(struct device *port, unsigned int pin, int value)
{
Expand All @@ -1041,6 +1060,7 @@ static inline int gpio_pin_set(struct device *port, unsigned int pin, int value)
*
* @retval 0 If successful.
* @retval -EIO I/O error when accessing an external GPIO chip.
* @retval -EWOULDBLOCK if operation would block.
*/
static inline int gpio_pin_toggle(struct device *port, unsigned int pin)
{
Expand Down

0 comments on commit dc20b2b

Please sign in to comment.