diff options
Diffstat (limited to 'drivers/gpio/stmpe-gpio.c')
-rw-r--r-- | drivers/gpio/stmpe-gpio.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gpio/stmpe-gpio.c b/drivers/gpio/stmpe-gpio.c index 4e1f1b9d5e6..7c9e6a052c4 100644 --- a/drivers/gpio/stmpe-gpio.c +++ b/drivers/gpio/stmpe-gpio.c @@ -30,6 +30,7 @@ struct stmpe_gpio { struct mutex irq_lock; int irq_base; + unsigned norequest_mask; /* Caches of interrupt control registers for bus_lock */ u8 regs[CACHE_NR_REGS][CACHE_NR_BANKS]; @@ -103,6 +104,9 @@ static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); struct stmpe *stmpe = stmpe_gpio->stmpe; + if (stmpe_gpio->norequest_mask & (1 << offset)) + return -EINVAL; + return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); } @@ -287,8 +291,6 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev) int irq; pdata = stmpe->pdata->gpio; - if (!pdata) - return -ENODEV; irq = platform_get_irq(pdev, 0); if (irq < 0) @@ -302,6 +304,7 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev) stmpe_gpio->dev = &pdev->dev; stmpe_gpio->stmpe = stmpe; + stmpe_gpio->norequest_mask = pdata ? pdata->norequest_mask : 0; stmpe_gpio->chip = template_chip; stmpe_gpio->chip.ngpio = stmpe->num_gpios; @@ -312,11 +315,11 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev) ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO); if (ret) - return ret; + goto out_free; ret = stmpe_gpio_irq_init(stmpe_gpio); if (ret) - goto out_free; + goto out_disable; ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio); @@ -342,6 +345,8 @@ out_freeirq: free_irq(irq, stmpe_gpio); out_removeirq: stmpe_gpio_irq_remove(stmpe_gpio); +out_disable: + stmpe_disable(stmpe, STMPE_BLOCK_GPIO); out_free: kfree(stmpe_gpio); return ret; |