summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-davinci.c
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2013-12-18 14:07:51 +0400
committerSekhar Nori <nsekhar@ti.com>2013-12-25 22:32:12 +0400
commit6075a8b2b6c32ddcb99b85189ae41ab2903e560f (patch)
tree76b301c58257041ed0b7444965a6c5a26c5792fc /drivers/gpio/gpio-davinci.c
parent0d978eb7349941139241a99acf05de6dd49b78d1 (diff)
downloadlinux-6075a8b2b6c32ddcb99b85189ae41ab2903e560f.tar.xz
gpio: davinci: don't create irq_domain in case of unbanked irqs
The system may crash if: - there are more than 1 banks - unbanked irqs are enabled - someone will call gpio_to_irq() for GPIO from bank2 or above Hence, fix it by not creating irq_domain if unbanked irqs are enabled and correct gpio_to_irq_banked() to handle this properly. Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: Sekhar Nori <nsekhar@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'drivers/gpio/gpio-davinci.c')
-rw-r--r--drivers/gpio/gpio-davinci.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 5d163c0d0a74..7629b4f12b7f 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -351,7 +351,10 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
{
struct davinci_gpio_controller *d = chip2controller(chip);
- return irq_create_mapping(d->irq_domain, d->chip.base + offset);
+ if (d->irq_domain)
+ return irq_create_mapping(d->irq_domain, d->chip.base + offset);
+ else
+ return -ENXIO;
}
static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
@@ -429,7 +432,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
struct davinci_gpio_platform_data *pdata = dev->platform_data;
struct davinci_gpio_regs __iomem *g;
- struct irq_domain *irq_domain;
+ struct irq_domain *irq_domain = NULL;
ngpio = pdata->ngpio;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -453,18 +456,20 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
}
clk_prepare_enable(clk);
- irq = irq_alloc_descs(-1, 0, ngpio, 0);
- if (irq < 0) {
- dev_err(dev, "Couldn't allocate IRQ numbers\n");
- return irq;
- }
+ if (!pdata->gpio_unbanked) {
+ irq = irq_alloc_descs(-1, 0, ngpio, 0);
+ if (irq < 0) {
+ dev_err(dev, "Couldn't allocate IRQ numbers\n");
+ return irq;
+ }
- irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
- &davinci_gpio_irq_ops,
- chips);
- if (!irq_domain) {
- dev_err(dev, "Couldn't register an IRQ domain\n");
- return -ENODEV;
+ irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
+ &davinci_gpio_irq_ops,
+ chips);
+ if (!irq_domain) {
+ dev_err(dev, "Couldn't register an IRQ domain\n");
+ return -ENODEV;
+ }
}
/*
@@ -475,8 +480,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
*/
for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) {
chips[bank].chip.to_irq = gpio_to_irq_banked;
- if (!pdata->gpio_unbanked)
- chips[bank].irq_domain = irq_domain;
+ chips[bank].irq_domain = irq_domain;
}
/*