Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114822
b: refs/heads/master
c: 0f6d504
h: refs/heads/master
v: v3
  • Loading branch information
David Brownell authored and Linus Torvalds committed Oct 16, 2008
1 parent 990bfa4 commit c5b8dbf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f8d11971b9f54362437ce70f4d1911f0996d542
refs/heads/master: 0f6d504e73b49374c6093efe6aa60ab55058248a
5 changes: 3 additions & 2 deletions trunk/Documentation/gpio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ map between them using calls like:
/* map GPIO numbers to IRQ numbers */
int gpio_to_irq(unsigned gpio);

/* map IRQ numbers to GPIO numbers */
/* map IRQ numbers to GPIO numbers (avoid using this) */
int irq_to_gpio(unsigned irq);

Those return either the corresponding number in the other namespace, or
Expand All @@ -284,7 +284,8 @@ system wakeup capabilities.

Non-error values returned from irq_to_gpio() would most commonly be used
with gpio_get_value(), for example to initialize or update driver state
when the IRQ is edge-triggered.
when the IRQ is edge-triggered. Note that some platforms don't support
this reverse mapping, so you should avoid using it.


Emulating Open Drain Signals
Expand Down
18 changes: 18 additions & 0 deletions trunk/drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,24 @@ int __gpio_cansleep(unsigned gpio)
}
EXPORT_SYMBOL_GPL(__gpio_cansleep);

/**
* __gpio_to_irq() - return the IRQ corresponding to a GPIO
* @gpio: gpio whose IRQ will be returned (already requested)
* Context: any
*
* This is used directly or indirectly to implement gpio_to_irq().
* It returns the number of the IRQ signaled by this (input) GPIO,
* or a negative errno.
*/
int __gpio_to_irq(unsigned gpio)
{
struct gpio_chip *chip;

chip = gpio_to_chip(gpio);
return chip->to_irq ? chip->to_irq(chip, gpio - chip->base) : -ENXIO;
}
EXPORT_SYMBOL_GPL(__gpio_to_irq);



/* There's no value in making it easy to inline GPIO calls that may sleep.
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/asm-generic/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct module;
* returns either the value actually sensed, or zero
* @direction_output: configures signal "offset" as output, or returns error
* @set: assigns output value for signal "offset"
* @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
* implementation may not sleep
* @dbg_show: optional routine to show contents in debugfs; default code
* will be used when this is omitted, but custom code can show extra
* state (such as pullup/pulldown configuration).
Expand Down Expand Up @@ -73,6 +75,10 @@ struct gpio_chip {
unsigned offset, int value);
void (*set)(struct gpio_chip *chip,
unsigned offset, int value);

int (*to_irq)(struct gpio_chip *chip,
unsigned offset);

void (*dbg_show)(struct seq_file *s,
struct gpio_chip *chip);
int base;
Expand Down Expand Up @@ -112,6 +118,7 @@ extern void __gpio_set_value(unsigned gpio, int value);

extern int __gpio_cansleep(unsigned gpio);

extern int __gpio_to_irq(unsigned gpio);

#ifdef CONFIG_GPIO_SYSFS

Expand Down

0 comments on commit c5b8dbf

Please sign in to comment.