From patchwork Fri Oct 13 15:49:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 825533 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-tegra-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="Oa/avnvr"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yDBz174WLz9sRm for ; Sat, 14 Oct 2017 02:51:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758635AbdJMPti (ORCPT ); Fri, 13 Oct 2017 11:49:38 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:54112 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758564AbdJMPtg (ORCPT ); Fri, 13 Oct 2017 11:49:36 -0400 Received: by mail-qk0-f196.google.com with SMTP id y23so5518756qkb.10; Fri, 13 Oct 2017 08:49:35 -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=V7ndZuGqOq9mke8wQCu6K6pBLt6Cus7WF0+8v+lPxCA=; b=Oa/avnvrQeJUXLOnFNViL5s6j+A18XE/m8t04fj1EPNSnSkJFZn8jBtt7cvnrs6sAO 3MGNLqjMuhry3QS5xypejpsAmbyaJ9hwyt5yut0X6pSC2r9AgVsYt9ScLA6iFeq0JIzD xVPmRFJTxam62DSkMK6ys7NrTVFmaid3OPUiwZnVq5JZLZyAg5fYWpM+7DUQAl2cCDSP RRNHgwjrIC3/L0k6Ruq9RqzJ3fOeQYXOhihZGrdUSrPX9gN00WPXaJEKobEovUTnr1Mo SPIaSOjRHrQ+/lgJoq9qNqfb6uhQH0auAfSWUEGfA0qNwFB9/WdPZPyFTbxOZOgwHI90 hUtA== 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=V7ndZuGqOq9mke8wQCu6K6pBLt6Cus7WF0+8v+lPxCA=; b=q3vLZdYOVw9IRe5XsnGjQUhXKdCY6m22WP3/TijWm4y4S60dV7L5qEip/CqUIy2kNQ WpN/5PuBj1gcoYLztz3zdE3WDMb3WMHtGZ0q/dqvBJEHRhxin+hlulVsoeDxyVX4lqrM DlyjlnN/Kn/1cOpQGLw3tgz+bldU9yoTUhUFKk3N20uoWJYUORh6GMxm6wW61cVY01VB mIqWTGo2msbpUIYv1b9hC9mwBrRIhR7cXiS6HAqPU5GPEGRab81XOTQVABK3sgVABwaz IBCBIXsUQGkUjjjCkxSsd7uHve9E1VR1U52vEqcNKiUdD9Izbqgoj2N7k9BOL1tCoV2X LRHw== X-Gm-Message-State: AMCzsaVawYMnivCdbxhim2EsACkLpG+pWsgxxSOgDlldVMf2YKCR2Kpo Sdc99Akkp0f1beIqdOEoiWUmwg== X-Google-Smtp-Source: ABhQp+TAWIYX5LK0xE04p5Lygqi8ZoNkBVhsTeR8wlrok3LV4iR+Wq2/iS/DdIY13RxJYxhdcQt9NQ== X-Received: by 10.55.39.145 with SMTP id n139mr2672629qkn.70.1507909775253; Fri, 13 Oct 2017 08:49:35 -0700 (PDT) Received: from localhost (p200300E41BE4FD00CEAD5B94E1CFD280.dip0.t-ipconnect.de. [2003:e4:1be4:fd00:cead:5b94:e1cf:d280]) by smtp.gmail.com with ESMTPSA id n20sm713119qka.1.2017.10.13.08.49.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2017 08:49:34 -0700 (PDT) From: Thierry Reding To: Linus Walleij Cc: Jonathan Hunter , Grygorii Strashko , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 07/13] gpio: Move irq_chained_parent to struct gpio_irq_chip Date: Fri, 13 Oct 2017 17:49:07 +0200 Message-Id: <20171013154913.29448-8-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013154913.29448-1-thierry.reding@gmail.com> References: <20171013154913.29448-1-thierry.reding@gmail.com> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@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 | 18 +++++++++++++----- include/linux/gpio/driver.h | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 70b33cfebf4f..1ee52070d19d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1564,7 +1564,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 */ @@ -1713,17 +1714,24 @@ 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(gpiochip->irq_chained_parent, NULL); - irq_set_handler_data(gpiochip->irq_chained_parent, 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(irq->parents[i], NULL); + irq_set_handler_data(irq->parents[i], 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 be856f003895..31785734462a 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -85,6 +85,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) @@ -154,9 +169,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 @@ -229,7 +241,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;