From patchwork Fri Sep 26 11:52:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 393698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7E3E5140092 for ; Fri, 26 Sep 2014 21:52:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754141AbaIZLwg (ORCPT ); Fri, 26 Sep 2014 07:52:36 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:35922 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753851AbaIZLwg (ORCPT ); Fri, 26 Sep 2014 07:52:36 -0400 Received: by mail-wg0-f45.google.com with SMTP id x13so8886189wgg.28 for ; Fri, 26 Sep 2014 04:52:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PociTz/5DRnFFXof3nsW2MMgcTbuOZvelH5VVhF7lMo=; b=KvFGtMIJb6D+XpD67UCp+C0CF7Ke5OnWavvj/tS2LFjRV7daLMCdxjW6ffi8DwT3Fy Y+t45YUx9I88spieDCAeAe6X7IWd6QfpLtkowo7g2MmVJ4ku1zh7NotPrHRO3iEScZDg l/bU/4KD+HrBL3FOu7jjreWYAPA0JD76Cq4wX6bZnji6Huc6uyPVaeS9AeDLJvmwl2hj 9Tjp6eGd/PvgYAHkIo65+1c7IZyDBXohA+nwD5dOlJEEFCCRbVTPlluwkUYDcJkxm5p4 ya7e9XNHqFWmxfCre4uHzHK5idD5V2aJBkLe7IRwL9YE4igEoFuj8hQ7pqiUyq3GDVCo g1/A== X-Gm-Message-State: ALoCoQl0fowSftt8C3SM7HaizDqbbmxUqF98iFFj0H1/cqy+8id9NYRQWeFGx+TF1egsQ/gF3kFv X-Received: by 10.180.36.141 with SMTP id q13mr26214612wij.32.1411732354829; Fri, 26 Sep 2014 04:52:34 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id nf2sm1954395wic.4.2014.09.26.04.52.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Sep 2014 04:52:34 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH] gpio: set parent irq on chained handlers Date: Fri, 26 Sep 2014 13:52:29 +0200 Message-Id: <1411732349-19178-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org If the IRQ from the parent is nested the IRQ may need to be resent under certain conditions. Currently the chained IRQ handler in gpiolib does not handle connecting nested IRQs but it is conceptually correct to indicate the actual parent IRQ. Reported-by: Grygorii Strashko Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 550e575c6ffb..9362b5b817af 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -398,17 +398,30 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, int parent_irq, irq_flow_handler_t parent_handler) { + unsigned int offset; + if (gpiochip->can_sleep) { chip_err(gpiochip, "you cannot have chained interrupts on a chip that may sleep\n"); return; } + if (!gpiochip->irqdomain) { + chip_err(gpiochip, "called %s before setting up irqchip\n", + __func__); + return; + } irq_set_chained_handler(parent_irq, parent_handler); + /* * The parent irqchip is already using the chip_data for this * irqchip, so our callbacks simply use the handler_data. */ irq_set_handler_data(parent_irq, gpiochip); + + /* Set the parent IRQ for all affected IRQs */ + for (offset = 0; offset < gpiochip->ngpio; offset++) + irq_set_parent(irq_find_mapping(gpiochip->irqdomain, offset), + parent_irq); } EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip);