From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Walleij Subject: Re: [PATCH] gpio: mcp23s08: Add irq functionality for i2c chips Date: Tue, 7 Jan 2014 19:50:47 +0100 Message-ID: References: <1389103548-23458-1-git-send-email-larsi@wh2.tu-dresden.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: In-Reply-To: <1389103548-23458-1-git-send-email-larsi@wh2.tu-dresden.de> Sender: linux-gpio-owner@vger.kernel.org To: Lars Poeschel Cc: Lars Poeschel , Rob Herring , Pawel Moll , Mark Rutland , "ijc+devicetree@hellion.org.uk" , Kumar Gala , Rob Landley , Alexandre Courbot , "devicetree@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" List-Id: devicetree@vger.kernel.org On Tue, Jan 7, 2014 at 3:05 PM, Lars Poeschel wrote: > From: Lars Poeschel > > 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 (...) > 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