From patchwork Thu Nov 2 17:49:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 833463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="m4fvBjH1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ySXlM5QB3z9sMN for ; Fri, 3 Nov 2017 04:54:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933160AbdKBRxj (ORCPT ); Thu, 2 Nov 2017 13:53:39 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46009 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933558AbdKBRtz (ORCPT ); Thu, 2 Nov 2017 13:49:55 -0400 Received: by mail-wr0-f194.google.com with SMTP id y9so339406wrb.2; Thu, 02 Nov 2017 10:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SuiYuHLwNxqjQROw6Q2Bxg6RcFepty9XscictIrvbPo=; b=m4fvBjH1OC62+2IixLrW/codrg1KNC6sofAGMJvQdv2D9jEoqM1Ae+yXxf1Js+o332 ZaFIP0kjYSa1liJSFgFHHXY5/GiRQ9sqNHpz1sJSvm3cLkT9nIhjIsbCTqkbhwCXJ22e EPR7q+vRv+/WteIcKCV2OYccts3AF20Z2NiALfTHH8kAXfzWZXQUEjegIRFhHIhiJ96Q cL+pyUQUSPl45U0NEnYDR5gHtJaLigI009WXMJAEoS/h+6MGI4QZc8+vf5hmENBFHezF G/y5pFOs+TXTyDe67WV6OCz6WzRhA60Hu8fKVu2iK7UxHb7m/gYwCk3Mglnl8LT7T4So Xpyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SuiYuHLwNxqjQROw6Q2Bxg6RcFepty9XscictIrvbPo=; b=iEz0191qgOnXouLnwhG/yNXbIqhoL6+NT4JPZTcNLzmepqSCvzRJw/l7gcLBk5jK0o pRiQtG9ho6FWBwJC98vr20i2oDhJzKtLiU75cg+L2/aZg+VuBYoiFccS8Rl7ZIyJna7n JlRjO1ORmaI5bzZCJ7QDMwfNTdtydAXpDVKJHXEzjd1Hc8D3daamb9tXqOmx7SkJpRX6 RFnXVB6WMzNYiVZFQ0Z9BmPUlNVuG+4cPVaZoSBTDxfG/N+mWmM80Y+u41Gv+J2Rb65v uJONthcgCiKR/7n5w8t91L9wd//BO2U99yhZqtpFg7/hQknKiUvVBcoxNxiIKrBSL1LM 0Vfg== X-Gm-Message-State: AMCzsaXjcQGHrcbE/lFP2nHKocA8eOlWinZnX5pLTBVOV1Cb6owdQx3S IX2vnR3RUS6IDFRW5+7Hjf4= X-Google-Smtp-Source: ABhQp+Rm/zz4dUzKt6AJsjhD7ece4fFd8RZoL7vbtRlof61q8svmWqhXTEjkELtiQHzr9UzVKP73gg== X-Received: by 10.223.153.234 with SMTP id y97mr3592971wrb.165.1509644993048; Thu, 02 Nov 2017 10:49:53 -0700 (PDT) Received: from localhost (p200300E41BC8E9001FF851737372D2C2.dip0.t-ipconnect.de. [2003:e4:1bc8:e900:1ff8:5173:7372:d2c2]) by smtp.gmail.com with ESMTPSA id c82sm171749wme.20.2017.11.02.10.49.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2017 10:49:52 -0700 (PDT) From: Thierry Reding To: Linus Walleij Cc: Grygorii Strashko , Jonathan Hunter , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 06/12] gpio: Move irq_chained_parent to struct gpio_irq_chip Date: Thu, 2 Nov 2017 18:49:35 +0100 Message-Id: <20171102174941.3461-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171102174941.3461-1-thierry.reding@gmail.com> References: <20171102174941.3461-1-thierry.reding@gmail.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Thierry Reding In order to consolidate the multiple ways to associate an IRQ chip with a GPIO chip, move more fields into the new struct gpio_irq_chip. Signed-off-by: Thierry Reding --- drivers/gpio/gpiolib.c | 17 ++++++++++++----- include/linux/gpio/driver.h | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d3608cf511de..8eadae73ff20 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1570,7 +1570,8 @@ static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, irq_set_chained_handler_and_data(parent_irq, parent_handler, gpiochip); - gpiochip->irq_chained_parent = parent_irq; + gpiochip->irq.parents = &parent_irq; + gpiochip->irq.num_parents = 1; } /* Set the parent IRQ for all affected IRQs */ @@ -1719,17 +1720,23 @@ static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) */ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) { - unsigned int offset, irq; + unsigned int offset; acpi_gpiochip_free_interrupts(gpiochip); - if (gpiochip->irq_chained_parent) { - irq_set_chained_handler_and_data( - gpiochip->irq_chained_parent, NULL, NULL); + if (gpiochip->irq.num_parents > 0) { + struct gpio_irq_chip *irq = &gpiochip->irq; + unsigned int i; + + for (i = 0; i < irq->num_parents; i++) + irq_set_chained_handler_and_data(irq->parents[i], + NULL, NULL); } /* Remove all IRQ mappings and delete the domain */ if (gpiochip->irq.domain) { + unsigned int irq; + for (offset = 0; offset < gpiochip->ngpio; offset++) { if (!gpiochip_irqchip_irq_valid(gpiochip, offset)) continue; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 1367fa94105f..86f00d908e90 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -77,6 +77,21 @@ struct gpio_irq_chip { * interrupt. */ void *parent_handler_data; + + /** + * @num_parents: + * + * The number of interrupt parents of a GPIO chip. + */ + unsigned int num_parents; + + /** + * @parents: + * + * A list of interrupt parents of a GPIO chip. This is owned by the + * driver, so the core will only reference this list, not modify it. + */ + unsigned int *parents; }; static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) @@ -148,9 +163,6 @@ static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) * safely. * @bgpio_dir: shadowed direction register for generic GPIO to clear/set * direction safely. - * @irq_chained_parent: GPIO IRQ chip parent/bank linux irq number, - * provided by GPIO driver for chained interrupt (not for nested - * interrupts). * @irq_nested: True if set the interrupt handling is nested. * @irq_need_valid_mask: If set core allocates @irq_valid_mask with all * bits set to one @@ -226,7 +238,6 @@ struct gpio_chip { * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib * to handle IRQs for most practical cases. */ - unsigned int irq_chained_parent; bool irq_nested; bool irq_need_valid_mask; unsigned long *irq_valid_mask;