Re: [PATCH] gpio: mcp23s08: Add irq functionality for i2c chips

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

 



On Tue, Jan 7, 2014 at 3:05 PM, Lars Poeschel <larsi@xxxxxxxxxxxxxxxxx> wrote:

> From: Lars Poeschel <poeschel@xxxxxxxxxxx>
>
> This adds interrupt functionality for i2c chips to the driver.
> They can act as a interrupt-controller and generate interrupts, if
> the inputs change.
> This is tested on a mcp23017 chip.
>
> Signed-off-by: Lars Poeschel <poeschel@xxxxxxxxxxx>
(...)
>         u8                      addr;
>
>         u16                     cache[11];
> +       u16                     irq_rise;
> +       u16                     irq_fall;
> +       int                     irq;
>         /* lock protects the cached values */
>         struct mutex            lock;
> +       struct mutex            irq_lock;
> +       struct irq_domain       *irq_domain;

(...)
> +static int mcp23s08_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
> +{
> +       struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip);
> +
> +       return irq_create_mapping(mcp->irq_domain, offset);

We have recently established that the mapping shall not be created in
gpio_to_irq().
Instead call irq_create_mapping() for all valid IRQ lines in probe() and
use irq_find_mapping() here.

> +static struct irq_chip mcp23s08_irq_chip = {
> +       .name = "gpio-mcp23xxx",
> +       .irq_mask = mcp23s08_irq_mask,
> +       .irq_unmask = mcp23s08_irq_unmask,
> +       .irq_set_type = mcp23s08_irq_set_type,
> +       .irq_bus_lock = mcp23s08_irq_bus_lock,
> +       .irq_bus_sync_unlock = mcp23s08_irq_bus_unlock,
> +};

Add irq_startup() and irq_shutdown() hooks in accordance with something
like this patch:
http://marc.info/?l=linux-gpio&m=138571851304612&w=2

The important thing is that you call
gpio_lock_as_irq()/gpio_unlock_as_irq()

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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux