From patchwork Tue Nov 29 16:23:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 629734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C6B6C4167B for ; Tue, 29 Nov 2022 16:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235700AbiK2QXd (ORCPT ); Tue, 29 Nov 2022 11:23:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232155AbiK2QXc (ORCPT ); Tue, 29 Nov 2022 11:23:32 -0500 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0386D28724 for ; Tue, 29 Nov 2022 08:23:30 -0800 (PST) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id qGPT2802r4C55Sk06GPTuz; Tue, 29 Nov 2022 17:23:28 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1p03OJ-0023Kq-56; Tue, 29 Nov 2022 17:23:27 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1p03OI-003Lee-OO; Tue, 29 Nov 2022 17:23:26 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski , Conor Dooley , Daire McNamara , Marc Zyngier Cc: linux-gpio@vger.kernel.org, linux-riscv@lists.infradead.org, Geert Uytterhoeven Subject: [PATCH] gpio: mpfs: Make the irqchip immutable Date: Tue, 29 Nov 2022 17:23:22 +0100 Message-Id: <4ee1a396acc34871dbae73a5b032915f745795ec.1669738949.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips. Following this change the following warning is now observed for the gpio-mpfs driver: gpio gpiochip0: (20122000.gpio): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the gpio-mpfs driver immutable. While at it, drop of the unneeded masking of the hwirq number, as it is always smaller than the number of GPIOs/interrupts handled by the controller. Signed-off-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- Not tested with interrupts, as there are no inputs described in the Icicle DTS yet. --- drivers/gpio/gpio-mpfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-mpfs.c b/drivers/gpio/gpio-mpfs.c index 168be0b90cf8c656..fd294b581ae77369 100644 --- a/drivers/gpio/gpio-mpfs.c +++ b/drivers/gpio/gpio-mpfs.c @@ -168,8 +168,9 @@ static void mpfs_gpio_irq_unmask(struct irq_data *data) { struct gpio_chip *gc = irq_data_get_irq_chip_data(data); struct mpfs_gpio_chip *mpfs_gpio = gpiochip_get_data(gc); - int gpio_index = irqd_to_hwirq(data) % MAX_NUM_GPIO; + int gpio_index = irqd_to_hwirq(data); + gpiochip_enable_irq(gc, gpio_index); mpfs_gpio_direction_input(gc, gpio_index); mpfs_gpio_assign_bit(mpfs_gpio->base + MPFS_IRQ_REG, gpio_index, 1); mpfs_gpio_assign_bit(mpfs_gpio->base + MPFS_GPIO_CTRL(gpio_index), @@ -180,11 +181,12 @@ static void mpfs_gpio_irq_mask(struct irq_data *data) { struct gpio_chip *gc = irq_data_get_irq_chip_data(data); struct mpfs_gpio_chip *mpfs_gpio = gpiochip_get_data(gc); - int gpio_index = irqd_to_hwirq(data) % MAX_NUM_GPIO; + int gpio_index = irqd_to_hwirq(data); mpfs_gpio_assign_bit(mpfs_gpio->base + MPFS_IRQ_REG, gpio_index, 1); mpfs_gpio_assign_bit(mpfs_gpio->base + MPFS_GPIO_CTRL(gpio_index), MPFS_GPIO_EN_INT, 0); + gpiochip_disable_irq(gc, gpio_index); } static const struct irq_chip mpfs_gpio_irqchip = { @@ -192,7 +194,8 @@ static const struct irq_chip mpfs_gpio_irqchip = { .irq_set_type = mpfs_gpio_irq_set_type, .irq_mask = mpfs_gpio_irq_mask, .irq_unmask = mpfs_gpio_irq_unmask, - .flags = IRQCHIP_MASK_ON_SUSPEND, + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static void mpfs_gpio_irq_handler(struct irq_desc *desc)