Re: [PATCH] gpio: tegra: use new gpio_lock_as_irq() API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Stephen,

On 10/16/2013 12:25 PM, Stephen Warren wrote:
From: Stephen Warren <swarren@xxxxxxxxxx>

Whenever an IRQ is claimed or freed, call gpio_lock_as_irq() or
gpio_unlock_as_irq() on the associated GPIO, to prevent that GPIO from
being configured in a manner incompatible with an interrupt.

Signed-off-by: Stephen Warren <swarren@xxxxxxxxxx>
---
  drivers/gpio/gpio-tegra.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 9a62672..cfd3b90 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -75,6 +75,7 @@ struct tegra_gpio_bank {
  #endif
  };

+static struct device *dev;
  static struct irq_domain *irq_domain;
  static void __iomem *regs;
  static u32 tegra_gpio_bank_count;
@@ -205,6 +206,7 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
  	int lvl_type;
  	int val;
  	unsigned long flags;
+	int ret;

  	switch (type & IRQ_TYPE_SENSE_MASK) {
  	case IRQ_TYPE_EDGE_RISING:
@@ -231,6 +233,12 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
  		return -EINVAL;
  	}

+	ret = gpio_lock_as_irq(&tegra_gpio_chip, gpio);
+	if (ret) {
+		dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio);

As a suggestion, you could add a pointer to dev on tegra gpio priv data
and recover it using ira_data_get_irq_chip_data(), instead of using
static file-scope variable.

Br, David Cohen

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux