Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198705
b: refs/heads/master
c: c4b5be9
h: refs/heads/master
i:
  198703: 8c29cf3
v: v3
  • Loading branch information
Felipe Balbi authored and Linus Torvalds committed May 27, 2010
1 parent 01bbf71 commit b6ec84e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 796a8e423ac8afe9e98ad96e668f50142bdd7825
refs/heads/master: c4b5be98fe78508e7199d6919eb712feba9a4f01
43 changes: 43 additions & 0 deletions trunk/drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,49 @@ int gpio_direction_output(unsigned gpio, int value)
}
EXPORT_SYMBOL_GPL(gpio_direction_output);

/**
* gpio_set_debounce - sets @debounce time for a @gpio
* @gpio: the gpio to set debounce time
* @debounce: debounce time is microseconds
*/
int gpio_set_debounce(unsigned gpio, unsigned debounce)
{
unsigned long flags;
struct gpio_chip *chip;
struct gpio_desc *desc = &gpio_desc[gpio];
int status = -EINVAL;

spin_lock_irqsave(&gpio_lock, flags);

if (!gpio_is_valid(gpio))
goto fail;
chip = desc->chip;
if (!chip || !chip->set || !chip->set_debounce)
goto fail;
gpio -= chip->base;
if (gpio >= chip->ngpio)
goto fail;
status = gpio_ensure_requested(desc, gpio);
if (status < 0)
goto fail;

/* now we know the gpio is valid and chip won't vanish */

spin_unlock_irqrestore(&gpio_lock, flags);

might_sleep_if(extra_checks && chip->can_sleep);

return chip->set_debounce(chip, gpio, debounce);

fail:
spin_unlock_irqrestore(&gpio_lock, flags);
if (status)
pr_debug("%s: gpio-%d status %d\n",
__func__, gpio, status);

return status;
}
EXPORT_SYMBOL_GPL(gpio_set_debounce);

/* I/O calls are only valid after configuration completed; the relevant
* "is this a valid GPIO" error checks should already have been done.
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/asm-generic/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ struct gpio_chip {
unsigned offset);
int (*direction_output)(struct gpio_chip *chip,
unsigned offset, int value);
int (*set_debounce)(struct gpio_chip *chip,
unsigned offset, unsigned debounce);

void (*set)(struct gpio_chip *chip,
unsigned offset, int value);

Expand Down Expand Up @@ -123,6 +126,8 @@ extern void gpio_free(unsigned gpio);
extern int gpio_direction_input(unsigned gpio);
extern int gpio_direction_output(unsigned gpio, int value);

extern int gpio_set_debounce(unsigned gpio, unsigned debounce);

extern int gpio_get_value_cansleep(unsigned gpio);
extern void gpio_set_value_cansleep(unsigned gpio, int value);

Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ static inline int gpio_direction_output(unsigned gpio, int value)
return -ENOSYS;
}

static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
{
return -ENOSYS;
}

static inline int gpio_get_value(unsigned gpio)
{
/* GPIO can never have been requested or set as {in,out}put */
Expand Down

0 comments on commit b6ec84e

Please sign in to comment.