Skip to content

Commit

Permalink
blackfin: GPIO: Implement more GPIO APIs
Browse files Browse the repository at this point in the history
Implement more GPIO APIs in case GPIOLIB is disabled.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Bob Liu <[email protected]>
  • Loading branch information
sonicz authored and aet00 committed May 21, 2012
1 parent 494b794 commit 45abc49
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions arch/blackfin/include/asm/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef __ASSEMBLY__

#include <linux/compiler.h>
#include <linux/gpio.h>

/***********************************************************
*
Expand Down Expand Up @@ -244,6 +245,49 @@ static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
return -EINVAL;
}

static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
int err;

err = bfin_gpio_request(gpio, label);
if (err)
return err;

if (flags & GPIOF_DIR_IN)
err = bfin_gpio_direction_input(gpio);
else
err = bfin_gpio_direction_output(gpio,
(flags & GPIOF_INIT_HIGH) ? 1 : 0);

if (err)
bfin_gpio_free(gpio);

return err;
}

static inline int gpio_request_array(const struct gpio *array, size_t num)
{
int i, err;

for (i = 0; i < num; i++, array++) {
err = gpio_request_one(array->gpio, array->flags, array->label);
if (err)
goto err_free;
}
return 0;

err_free:
while (i--)
bfin_gpio_free((--array)->gpio);
return err;
}

static inline void gpio_free_array(const struct gpio *array, size_t num)
{
while (num--)
bfin_gpio_free((array++)->gpio);
}

static inline int __gpio_get_value(unsigned gpio)
{
return bfin_gpio_get_value(gpio);
Expand Down

0 comments on commit 45abc49

Please sign in to comment.