From patchwork Thu Sep 28 09:56:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 819517 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="WTq7dM8B"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y2qtm2vQqz9t5C for ; Thu, 28 Sep 2017 20:00:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbdI1KAF (ORCPT ); Thu, 28 Sep 2017 06:00:05 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:35890 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbdI1J4j (ORCPT ); Thu, 28 Sep 2017 05:56:39 -0400 Received: by mail-qk0-f193.google.com with SMTP id j5so103656qkd.3; Thu, 28 Sep 2017 02:56:38 -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=noYTKrbIbdYx//CAiGIRW9+9uo31/0185QPKmKee8Kc=; b=WTq7dM8B6GBwIOiZoA8jepgS6zIic+6uMmVbvF9FRalMWLiJs2c93TWFFJc/gBSn1V xLr1rB089gwvVtJtKXoboo5YZDDwniNKXmblEeHz3FcIEQ2e+36nvQFPoDzEkrSuWMWe xdYOlAMZTIwuSz5l+c074jqQ6Uozm6kR4Hwv3bbx7aKtBmuILb5io1NXFOE7E4Fbv5uM lYGmFF9TBf7EwfPc30O3oDRWXqdpsNgEUM9QrZ6h1PAF4dqQw7RZK1Eq78wAmzkaYIdI xeifGJ4Cmk3b3wW9AJV6Oal9wMr/bijS8+db+fqopF3e+B1N72iVMVIMxTlUBTFb+fYU HZCQ== 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=noYTKrbIbdYx//CAiGIRW9+9uo31/0185QPKmKee8Kc=; b=jS1bcRh1fHUUtBg8IL4RcekERydSt7U6o9sWn6Vsnw0d5XKlZ4aYhsUwZUPKSqXNJq jKJqgC2+VZCm6WgQWjwnVRZgnzlseZDCeSQBNjSvWx1QNOzQ7FS5AVMb75AgnL2o0dqJ BepVqndd0+n0hSNQZV3xt/hdwvZTLOlYcVFAAIhDAhX4uJxiJzeQnc7oAVrihpECXjdu vx/PEwOqbgMH2Ur1vQ+xps6jCSb1v17MPSAfJ4Bkz2klS5Wbb3LatlCw/ze/WSMYbw+6 kG2ONKn5gLgbIEOlTGYjB5WF1HIVuT1v2co+jGM2NySdCjQK3Fzo2VYzAZrnXrvJOtsf EVDg== X-Gm-Message-State: AMCzsaU95CPFuqJzDemcPmv/JIHUMO/pncOzMW2Ad57+JKyJ14MfhOAv cpHzjo8iNBiXiBFBJYJ5CaE= X-Google-Smtp-Source: AOwi7QAveWwTf7XOWzxgzt52kJz6dHFSsMnfwmsxlmkOKto2T54NjHAHxG56bm8XmZgPd8Y45+jZoQ== X-Received: by 10.55.18.13 with SMTP id c13mr322157qkh.81.1506592598259; Thu, 28 Sep 2017 02:56:38 -0700 (PDT) Received: from localhost (p200300E41BCC8100EA54DC343767CF80.dip0.t-ipconnect.de. [2003:e4:1bcc:8100:ea54:dc34:3767:cf80]) by smtp.gmail.com with ESMTPSA id p31sm777313qtp.12.2017.09.28.02.56.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Sep 2017 02:56:37 -0700 (PDT) From: Thierry Reding To: Linus Walleij Cc: Jonathan Hunter , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/16] gpio: Move irqchip into struct gpio_irq_chip Date: Thu, 28 Sep 2017 11:56:14 +0200 Message-Id: <20170928095628.21966-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170928095628.21966-1-thierry.reding@gmail.com> References: <20170928095628.21966-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 | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b34d9cbd5809..450007ac1fc0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1645,7 +1645,7 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, * category than their parents, so it won't report false recursion. */ irq_set_lockdep_class(irq, chip->lock_key); - irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler); + irq_set_chip_and_handler(irq, chip->irq.chip, chip->irq_handler); /* Chips that use nested thread handlers have them marked */ if (chip->irq_nested) irq_set_nested_thread(irq, 1); @@ -1718,7 +1718,7 @@ static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) */ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip) { - struct irq_chip *irqchip = gpiochip->irqchip; + struct irq_chip *irqchip = gpiochip->irq.chip; const struct irq_domain_ops *ops; struct device_node *np; unsigned int type; @@ -1847,7 +1847,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) irq_set_handler_data(gpiochip->irq_chained_parent, NULL); } - if (gpiochip->irqchip) { + if (gpiochip->irq.chip) { struct gpio_irq_chip *irq = &gpiochip->irq; unsigned int i; @@ -1868,10 +1868,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) irq_domain_remove(gpiochip->irqdomain); } - if (gpiochip->irqchip) { - gpiochip->irqchip->irq_request_resources = NULL; - gpiochip->irqchip->irq_release_resources = NULL; - gpiochip->irqchip = NULL; + if (gpiochip->irq.chip) { + gpiochip->irq.chip->irq_request_resources = NULL; + gpiochip->irq.chip->irq_release_resources = NULL; + gpiochip->irq.chip = NULL; } gpiochip_irqchip_free_valid_mask(gpiochip); @@ -1946,7 +1946,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, type = IRQ_TYPE_NONE; } - gpiochip->irqchip = irqchip; + gpiochip->irq.chip = irqchip; gpiochip->irq_handler = handler; gpiochip->irq_default_type = type; gpiochip->to_irq = gpiochip_to_irq; @@ -1955,7 +1955,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, gpiochip->ngpio, first_irq, &gpiochip_domain_ops, gpiochip); if (!gpiochip->irqdomain) { - gpiochip->irqchip = NULL; + gpiochip->irq.chip = NULL; return -EINVAL; } diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 6100b171817e..974247646886 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -24,6 +24,13 @@ struct module; * struct gpio_irq_chip - GPIO interrupt controller */ struct gpio_irq_chip { + /** + * @chip: + * + * GPIO IRQ chip implementation, provided by GPIO driver. + */ + struct irq_chip *chip; + /** * @domain_ops: * @@ -69,6 +76,11 @@ struct gpio_irq_chip { */ unsigned int *map; }; + +static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) +{ + return container_of(chip, struct gpio_irq_chip, chip); +} #endif /** @@ -132,7 +144,6 @@ struct gpio_irq_chip { * safely. * @bgpio_dir: shadowed direction register for generic GPIO to clear/set * direction safely. - * @irqchip: GPIO IRQ chip impl, provided by GPIO driver * @irqdomain: Interrupt translation domain; responsible for mapping * between GPIO hwirq number and linux irq number * @irq_base: first linux IRQ number assigned to GPIO IRQ chip (deprecated) @@ -215,7 +226,6 @@ struct gpio_chip { * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib * to handle IRQs for most practical cases. */ - struct irq_chip *irqchip; struct irq_domain *irqdomain; unsigned int irq_base; irq_flow_handler_t irq_handler;