提交 98401ae4 编写于 作者: T Thomas Gleixner 提交者: Matthew Garrett

platform-drivers: x86: pmic: Use request_irq instead of chained handler

There is no need to install a chained handler for this hardware. This
is a plain x86 IOAPIC interrupt which is handled by the core code
perfectly fine. There is nothing special about demultiplexing these
gpio interrupts which justifies a custom hack. Replace it by a plain
old interrupt handler installed with request_irq. That makes the code
agnostic about the underlying primary interrupt hardware. The overhead
for this is minimal, but it gives us the advantage of accounting,
balancing and to detect interrupt storms. gpio interrupts are not
really that performance critical.

Patch fixups from akpm
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NMatthew Garrett <mjg@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
上级 d4b7de61
...@@ -74,19 +74,6 @@ struct pmic_gpio { ...@@ -74,19 +74,6 @@ struct pmic_gpio {
u32 trigger_type; u32 trigger_type;
}; };
static void pmic_program_irqtype(int gpio, int type)
{
if (type & IRQ_TYPE_EDGE_RISING)
intel_scu_ipc_update_register(GPIO0 + gpio, 0x20, 0x20);
else
intel_scu_ipc_update_register(GPIO0 + gpio, 0x00, 0x20);
if (type & IRQ_TYPE_EDGE_FALLING)
intel_scu_ipc_update_register(GPIO0 + gpio, 0x10, 0x10);
else
intel_scu_ipc_update_register(GPIO0 + gpio, 0x00, 0x10);
};
static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{ {
if (offset > 8) { if (offset > 8) {
...@@ -179,26 +166,6 @@ static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned offset) ...@@ -179,26 +166,6 @@ static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
return pg->irq_base + offset; return pg->irq_base + offset;
} }
static void pmic_bus_lock(struct irq_data *data)
{
struct pmic_gpio *pg = irq_data_get_irq_chip_data(data);
mutex_lock(&pg->buslock);
}
static void pmic_bus_sync_unlock(struct irq_data *data)
{
struct pmic_gpio *pg = irq_data_get_irq_chip_data(data);
if (pg->update_type) {
unsigned int gpio = pg->update_type & ~GPIO_UPDATE_TYPE;
pmic_program_irqtype(gpio, pg->trigger_type);
pg->update_type = 0;
}
mutex_unlock(&pg->buslock);
}
/* the gpiointr register is read-clear, so just do nothing. */ /* the gpiointr register is read-clear, so just do nothing. */
static void pmic_irq_unmask(struct irq_data *data) { } static void pmic_irq_unmask(struct irq_data *data) { }
...@@ -211,19 +178,21 @@ static struct irq_chip pmic_irqchip = { ...@@ -211,19 +178,21 @@ static struct irq_chip pmic_irqchip = {
.irq_set_type = pmic_irq_type, .irq_set_type = pmic_irq_type,
}; };
static void pmic_irq_handler(unsigned irq, struct irq_desc *desc) static irqreturn_t pmic_irq_handler(int irq, void *data)
{ {
struct pmic_gpio *pg = (struct pmic_gpio *)get_irq_data(irq); struct pmic_gpio *pg = data;
u8 intsts = *((u8 *)pg->gpiointr + 4); u8 intsts = *((u8 *)pg->gpiointr + 4);
int gpio; int gpio;
irqreturn_t ret = IRQ_NONE;
for (gpio = 0; gpio < 8; gpio++) { for (gpio = 0; gpio < 8; gpio++) {
if (intsts & (1 << gpio)) { if (intsts & (1 << gpio)) {
pr_debug("pmic pin %d triggered\n", gpio); pr_debug("pmic pin %d triggered\n", gpio);
generic_handle_irq(pg->irq_base + gpio); generic_handle_irq(pg->irq_base + gpio);
ret = IRQ_HANDLED;
} }
} }
desc->chip->irq_eoi(get_irq_desc_chip_data(desc)); return ret;
} }
static int __devinit platform_pmic_gpio_probe(struct platform_device *pdev) static int __devinit platform_pmic_gpio_probe(struct platform_device *pdev)
...@@ -280,8 +249,13 @@ static int __devinit platform_pmic_gpio_probe(struct platform_device *pdev) ...@@ -280,8 +249,13 @@ static int __devinit platform_pmic_gpio_probe(struct platform_device *pdev)
printk(KERN_ERR "%s: Can not add pmic gpio chip.\n", __func__); printk(KERN_ERR "%s: Can not add pmic gpio chip.\n", __func__);
goto err; goto err;
} }
set_irq_data(pg->irq, pg);
set_irq_chained_handler(pg->irq, pmic_irq_handler); retval = request_irq(pg->irq, pmic_irq_handler, 0, "pmic", pg);
if (retval) {
printk(KERN_WARNING "pmic: Interrupt request failed\n");
goto err;
}
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
set_irq_chip_and_handler_name(i + pg->irq_base, &pmic_irqchip, set_irq_chip_and_handler_name(i + pg->irq_base, &pmic_irqchip,
handle_simple_irq, "demux"); handle_simple_irq, "demux");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册