From patchwork Tue Nov 7 18:15:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 835419 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="BObeuvnm"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yWd3t1gprz9t2m for ; Wed, 8 Nov 2017 05:19:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755756AbdKGSQI (ORCPT ); Tue, 7 Nov 2017 13:16:08 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:46355 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755528AbdKGSQF (ORCPT ); Tue, 7 Nov 2017 13:16:05 -0500 Received: by mail-wm0-f67.google.com with SMTP id r68so5662703wmr.1; Tue, 07 Nov 2017 10:16:04 -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=3MIwRAKyN2e/zScXGNlZvq2OScITNMGo4D6LYgq8hsY=; b=BObeuvnmViTF5X5WZHhKocQxgf04vo11BBwxuDYq5/M92DvIevGUKxks+JsnLrpM98 e258DsWfubskIS1OCT1ub6OJoi9MPlpAU0abDr7qW3/Rts0X0a6sJcaDZrr1hmWEQbTx zsuYW6dvtq3HLecVw3rYnj2AjbVgLroRvp4TX4V4NjmG6w0qrgFyViWVc/gKFn9bqrx3 OyaJXSOylUdW4AR0LGUh9vo6ykSKPjDiN0oWakeYjH0dLn8pgA37Jcdn3foztpszaOSK 8jEBpW2DoV7GNlqyY/XpK9CUypEUabGeuNRRAekRgekqxOCsogAE1Vx5Tht/jFhlFZQL VkSg== 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=3MIwRAKyN2e/zScXGNlZvq2OScITNMGo4D6LYgq8hsY=; b=hkTWzkVdiOlZ7/YWUyjzZviRQ4qmW3NTGnEFyrJNqLz0tlxpaeqhWX5ySRqFd6hRfp taLxChhzdH1GyhJzIEWfkPtfALngYQMnUnLxeNGaJsp8Vmvd8prsVDaV2Lmqrnnk8nW/ NHiBSoUq1Tao2zqQPc+XJmyWIIRLoUQunbbd71W+WnpBFIpuVLgIuPuE3yGtCY2+cpLZ MImVFPiutge3q3SGPZcSdS22YgxcTUC3YvxvnqrJht8kovNNXXAR81BOpZ4y26/iq42m 1uO2PRiePupRh7gbLoNoLymCMHQTCdlwl7ETSSOpnAtg/H7913kusF+2aHKgwSv1C2HT 33ww== X-Gm-Message-State: AJaThX6KqCUdlw6kMAlHlcmphiMWMT9zpJ1L0gxUFT2J1Ry7rStsSmye OFOnJcCQX2ahSw2XtvIMpt4= X-Google-Smtp-Source: ABhQp+Q9ptRA5tmxDN/6hmsA0JpQUIDyN/y4RO+U6dXuA/E3K/bcVbm+ujioOrkFUcKEO6vIMp4dMQ== X-Received: by 10.28.15.5 with SMTP id 5mr45178wmp.43.1510078564160; Tue, 07 Nov 2017 10:16:04 -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 m128sm883897wmm.3.2017.11.07.10.16.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 10:16:03 -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 02/15] gpio: Move irqchip into struct gpio_irq_chip Date: Tue, 7 Nov 2017 19:15:46 +0100 Message-Id: <20171107181559.6318-3-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-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 | 14 +++++++------- include/linux/gpio/driver.h | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 029ad1a0a0d5..741f2e4d7c43 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1646,7 +1646,7 @@ static 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); @@ -1739,10 +1739,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); @@ -1817,7 +1817,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; @@ -1826,7 +1826,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 c25d058e6c71..cc40f1199e63 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -25,6 +25,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: * @@ -48,6 +55,11 @@ struct gpio_irq_chip { */ void *parent_handler_data; }; + +static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) +{ + return container_of(chip, struct gpio_irq_chip, chip); +} #endif /** @@ -113,7 +125,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_handler: the irq handler to use (often a predefined irq core function) @@ -198,7 +209,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; irq_flow_handler_t irq_handler; unsigned int irq_default_type;