irq: add irq busy validation

return -EBUSY when this irq is occupied.

Change-Id: I75ad6c0b13e167762cab2b8f9a2b786e588b2ade
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-02-19 11:10:52 +08:00 committed by Jianhong Chen
parent 0a53d515e6
commit 8696cc3875
3 changed files with 13 additions and 2 deletions

View File

@ -64,6 +64,11 @@ void _do_generic_irq_handler(void)
gic_irq_chip->irq_eoi(irq); gic_irq_chip->irq_eoi(irq);
} }
int irq_is_busy(int irq)
{
return (irq >= 0 && irqs_desc[irq].handle_irq) ? -EBUSY : 0;
}
static int chip_irq_bad(struct irq_chip *chip) static int chip_irq_bad(struct irq_chip *chip)
{ {
if (!chip->name || if (!chip->name ||

View File

@ -57,6 +57,7 @@ static int gpio_is_valid(u32 gpio)
static int _hard_gpio_to_irq(u32 gpio) static int _hard_gpio_to_irq(u32 gpio)
{ {
int idx, bank = 0, pin = 0; int idx, bank = 0, pin = 0;
int irq;
if (!gpio_is_valid(gpio)) if (!gpio_is_valid(gpio))
return -EINVAL; return -EINVAL;
@ -65,8 +66,12 @@ static int _hard_gpio_to_irq(u32 gpio)
pin = (gpio & GPIO_PIN_MASK) >> GPIO_PIN_OFFSET; pin = (gpio & GPIO_PIN_MASK) >> GPIO_PIN_OFFSET;
for (idx = 0; idx < ARRAY_SIZE(gpio_banks); idx++) { for (idx = 0; idx < ARRAY_SIZE(gpio_banks); idx++) {
if (gpio_banks[idx].id == bank) if (gpio_banks[idx].id == bank) {
return (gpio_banks[idx].irq_base + pin); irq = (gpio_banks[idx].irq_base + pin);
if (irq_is_busy(irq))
return -EBUSY;
return irq;
}
} }
return -EINVAL; return -EINVAL;

View File

@ -69,6 +69,7 @@ int irq_handler_disable(int irq);
int irq_get_gpio_level(int irq); int irq_get_gpio_level(int irq);
int irqs_suspend(void); int irqs_suspend(void);
int irqs_resume(void); int irqs_resume(void);
int irq_is_busy(int irq);
int gpio_to_irq(struct gpio_desc *gpio); int gpio_to_irq(struct gpio_desc *gpio);
/* /*