From patchwork Tue Nov 7 18:15:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 835421 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="oA2AYU0S"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yWd4b38nvz9t2h for ; Wed, 8 Nov 2017 05:19:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752111AbdKGSTA (ORCPT ); Tue, 7 Nov 2017 13:19:00 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54109 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755850AbdKGSQM (ORCPT ); Tue, 7 Nov 2017 13:16:12 -0500 Received: by mail-wm0-f66.google.com with SMTP id r196so5851364wmf.2; Tue, 07 Nov 2017 10:16:11 -0800 (PST) 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=lDuGDyg+RjutcdGLee4K7Ix7dCc/78pSLH4ETmWziYQ=; b=oA2AYU0SSINlIySu0GXiPSX5RIpHOoxgl5ZoIUhSOmgbIP3FoQrX2TjYQRH/taRGN1 LkecOdHGvXXSiFNZVmWEd2nep0hSCcfDpOvX9mlj6yfHr+ZD/OXgrBruAtC0kWT7WJIT cTxSKJcJZtW19m+25i+lA6B/UFgOCn0ZEF0kbZrV1yCHCNBwxZ6QQeU/cqZSslbY7j7y QbLh0YZ7fqkOZAz81OXT+tb9IbRmarVI3kBNrRRAPR5RZPNeirxD7UXuUN1+EQjTKHrA ADGjUondAWDBpbgVllQWzKv+53NeZBcmDZExN8mkKyH3wW8PRV6gn2k7lkW2IZ+3G+Iv BmxA== 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=lDuGDyg+RjutcdGLee4K7Ix7dCc/78pSLH4ETmWziYQ=; b=LL/5FCiAS4cD6RSqXXJbZDiq492kkS6orNkUNuY4VIJa3nDQrCo4nmm4Aybr90mAfJ Xzodcwoq+jUsAr1MluoVFlpOepzw4iH06URxVNySkTFytvsBrmnRl3j+yrZNAuW52Lc5 yPQVOq2LynZnhZ2pbYip8rWQymBxvP53Ee66jO1wuRAEOX10p2zhwP/4ysyqTwOUxHKm 9dj0QvNE9U3QssuWel0IoZ1rqiDJi/nVwQjNn1DwftT5Z2vXeYBqVicBGp+10GW7zEHe upjfdrwQ0UDoBCtrjrsZNyAzf26lVjVo9LHN51Zm3Xt948lyiwy3gPqNeXuvOPInscej ZP5g== X-Gm-Message-State: AJaThX7G53GjsbEV6MxQKEdlqzynHeElpAfUS4i3MQn9PqnGNJTB6rJg yrOcQ8KNkY0rTDR1uH6I4uDtLQ== X-Google-Smtp-Source: ABhQp+QOwr5kfR0KIzLkrJYm0zjSGMTdRlT7jHhrBqLbe4NAMZ6mqt22UDDvzvGQ9R9XA4+DRp8lhA== X-Received: by 10.28.166.143 with SMTP id p137mr29189wme.149.1510078570402; Tue, 07 Nov 2017 10:16:10 -0800 (PST) Received: from localhost (p200300E41BC8E9001FF851737372D2C2.dip0.t-ipconnect.de. [2003:e4:1bc8:e900:1ff8:5173:7372:d2c2]) by smtp.gmail.com with ESMTPSA id k14sm1296319wrc.90.2017.11.07.10.16.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 10:16:09 -0800 (PST) From: Thierry Reding To: Linus Walleij , Grygorii Strashko Cc: Jonathan Hunter , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 06/15] gpio: Move irq_chained_parent to struct gpio_irq_chip Date: Tue, 7 Nov 2017 19:15:50 +0100 Message-Id: <20171107181559.6318-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171107181559.6318-1-thierry.reding@gmail.com> References: <20171107181559.6318-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 6b0eef375b58..3edb02b54bb2 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 7bafae934112..4210aa4c11d1 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -78,6 +78,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) @@ -149,9 +164,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 @@ -227,7 +239,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;