From patchwork Tue Apr 4 09:43:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199416 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BC12C761A6 for ; Tue, 4 Apr 2023 09:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BWPk7FpC6aqZ+wEac1xyGDAw6+s3rr3wbssrbqVhiUA=; b=P30weqjFFaX0C8 +dyY3kZQnZZB0iiD50Xc4qyBp9PLmgRHYRCOmNt2AxtRk9oPHoab50dO1RbBv+uOL3tkMuYCRejo7 +XaUtN96KpbeIdax3m0PjHjiRQlPJTaLc5MV7Mzoe/IXw2xGOT1QjwU7ubJNfobFb9McnFIgp0tso 9nyvgamoT8MQXK+cFP6ZMzDn/vt5s1cVgsUmMpBugrZtUiRZbnbjhGcCmjZv9XBUrYXyqoa163miw 3vBtEyJDGINGX22pkVe1hcJh2msqlFYongN6h+9VWZe1LcrlIlzsPYrQjU1Lgwru1CBhIKWLcYgOx 0WsaCfbgwhm2MMX0foRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCD-000kVI-2L; Tue, 04 Apr 2023 09:43:21 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC6-000kPn-26 for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:18 +0000 Received: by mail-lf1-x135.google.com with SMTP id c9so31183785lfb.1 for ; Tue, 04 Apr 2023 02:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601390; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RKK9eLgubzxWPHMWxI1yK7d1/+43BWwyQkM2tfuG2Ww=; b=x7ppiWbyNyZwwriIorzWRnpZP4rWgQx6yFQbqXqh1OXDLJel4zda/pCcS6POdONcaG 7Yv3e7fbUTqfjUrHeAtVc5xqJ4Gmz4/GtSFu4grqH+f3gGPtr0jGvRyKK6vRApV0uNNn pBO5KB050ARhuPvDhuT2MFcCNRi/fcfb9A8aqygpgQrVbjwJfG7hcodVt+q/oS/Bx9LW /fnKSlEVfDctfs5GeV3aYtiORbT1k5+p5mQ5pjXT0uBW89SPhm+5PXh2tDA/qmLebjcZ KK5Dn3f/RObhVpTmQsLbGJDuntgJHC8ftHLkH2+hc+DxBbBxb4xgIHwtdQT4P8ohou1j CfyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601390; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RKK9eLgubzxWPHMWxI1yK7d1/+43BWwyQkM2tfuG2Ww=; b=6u6UAL3WjqAo8uVVVpMrRsrwcMpPCkPhaANBG4dvgv6LLrINJC1aXZbK7iUztNSX7Z Suw9Vz4LcSW+hbTwB3z9V6avzV+8W6IU9idEt2AZWSa2GvuWxMStuz6v+WX1QJoYoc4M +Fslav2Hd0F+XubnkIPlbf8RrPKkdyKSEN6Klsqh40gFxqUzLrswzdfKn83wLhtvh+VN 8gCbRReT6ZO6SZS5rlc7fBbJhoC542IdNorYx1oK2l8iPnqw7b4HFTFGnIsRWdOgYNOW aW+/JjGEx28RAQXJ4o2Qa4Jtb1LGQBfjdv1jWeiVaqYorhE+gM97IHBSLM88BZ4BvS77 pVqA== X-Gm-Message-State: AAQBX9e5EqWxgjeVI+nI1Q6QHG8JQwOmdeUgXNP2aFOVhiWPMcMBk/Dn xey1y2KDYFO9fmdkbLEbNVewNQ== X-Google-Smtp-Source: AKy350bXU9qE5on50GOy/zA3QRbSNFs+CqcTvsLk9DkI3fNquQp8y9IwP/2sQB6t0bTIVTgIgnAjHw== X-Received: by 2002:ac2:4c92:0:b0:4df:b32b:a2a3 with SMTP id d18-20020ac24c92000000b004dfb32ba2a3mr477734lfl.47.1680601390612; Tue, 04 Apr 2023 02:43:10 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:10 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:03 +0200 Subject: [PATCH 1/9] pinctrl: iproc: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-1-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024314_690548_96E3CAB2 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c index 3df56a4ea510..cc3eb7409ab3 100644 --- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -108,7 +109,6 @@ struct iproc_gpio { raw_spinlock_t lock; - struct irq_chip irqchip; struct gpio_chip gc; unsigned num_banks; @@ -217,7 +217,7 @@ static void iproc_gpio_irq_set_mask(struct irq_data *d, bool unmask) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct iproc_gpio *chip = gpiochip_get_data(gc); - unsigned gpio = d->hwirq; + unsigned gpio = irqd_to_hwirq(d); iproc_set_bit(chip, IPROC_GPIO_INT_MSK_OFFSET, gpio, unmask); } @@ -231,6 +231,7 @@ static void iproc_gpio_irq_mask(struct irq_data *d) raw_spin_lock_irqsave(&chip->lock, flags); iproc_gpio_irq_set_mask(d, false); raw_spin_unlock_irqrestore(&chip->lock, flags); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } static void iproc_gpio_irq_unmask(struct irq_data *d) @@ -239,6 +240,7 @@ static void iproc_gpio_irq_unmask(struct irq_data *d) struct iproc_gpio *chip = gpiochip_get_data(gc); unsigned long flags; + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); raw_spin_lock_irqsave(&chip->lock, flags); iproc_gpio_irq_set_mask(d, true); raw_spin_unlock_irqrestore(&chip->lock, flags); @@ -302,6 +304,26 @@ static int iproc_gpio_irq_set_type(struct irq_data *d, unsigned int type) return 0; } +static void iproc_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct iproc_gpio *chip = gpiochip_get_data(gc); + + seq_printf(p, dev_name(chip->dev)); +} + +static const struct irq_chip iproc_gpio_irq_chip = { + .irq_ack = iproc_gpio_irq_ack, + .irq_mask = iproc_gpio_irq_mask, + .irq_unmask = iproc_gpio_irq_unmask, + .irq_set_type = iproc_gpio_irq_set_type, + .irq_enable = iproc_gpio_irq_unmask, + .irq_disable = iproc_gpio_irq_mask, + .irq_print_chip = iproc_gpio_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + /* * Request the Iproc IOMUX pinmux controller to mux individual pins to GPIO */ @@ -852,20 +874,10 @@ static int iproc_gpio_probe(struct platform_device *pdev) /* optional GPIO interrupt support */ irq = platform_get_irq_optional(pdev, 0); if (irq > 0) { - struct irq_chip *irqc; struct gpio_irq_chip *girq; - irqc = &chip->irqchip; - irqc->name = dev_name(dev); - irqc->irq_ack = iproc_gpio_irq_ack; - irqc->irq_mask = iproc_gpio_irq_mask; - irqc->irq_unmask = iproc_gpio_irq_unmask; - irqc->irq_set_type = iproc_gpio_irq_set_type; - irqc->irq_enable = iproc_gpio_irq_unmask; - irqc->irq_disable = iproc_gpio_irq_mask; - girq = &gc->irq; - girq->chip = irqc; + gpio_irq_chip_set_chip(girq, &iproc_gpio_irq_chip); girq->parent_handler = iproc_gpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(dev, 1, From patchwork Tue Apr 4 09:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199413 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3191C77B6C for ; Tue, 4 Apr 2023 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A5+TmGqDkZbKglIQXDCbFMkS2XNhfFYkWF7Xv2H3pSU=; b=nlKoA/2sRwvwa3 UfKXFLOs5Y90g4w+/y5sWWLY2gFeUZ//Ox2yNByDvzQTKhYJwj00fdF74sU/RwwdrfkGGA0HagB9a O2IeHy1rXRaYGqvrgL3eGu+OuAXkgUoFW8Q3jjnKBGTAFHgpUn263vQay8gaSoRi7gKjDV0nTl1WA aTKFQA4Bs3dYeKjMwyZWdH+ocdrR8S8ZEWaAXWBHfTdv/fdr7FK/XcjDtwD3bMFvif4iwFTHD7UN/ 5AAKfcDhb4TdANlDKCgA3rtX+vuKq8Y9fZUO9cEbrDzMJw0lcNOILTR/IS4k9Da21NwtUcqIpih91 cehEWCGTGudZzY2Iv0Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCG-000kVy-02; Tue, 04 Apr 2023 09:43:24 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC7-000kPq-2A for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:19 +0000 Received: by mail-lf1-x133.google.com with SMTP id y20so41657168lfj.2 for ; Tue, 04 Apr 2023 02:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601391; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E1U3mznWUSnJq2x7KzrZeo74yHwZxjse8U63SQkTN4k=; b=eX5ZeFcrDyeOZ/+cmIw1GthasxB336QssKMWmkFVFjzUzquTWCGLPH0q1EZGkx57D7 lMBTV4GQvDuLwdcpX7uMkCsYiT15dsHdEflv9g0w1W+ahbDSVxbyUvz5gUTVJ5sYN5nd gGSkMJIKgzuEsvJpz5qvVuUa9tXPAIFLLMxBUS9ZN6aJGEJa88cvLFIhVRzr7cFD3xO4 V/C0tVGfceLtY5T6HC9Bg5fuMQSPe39vC9gft3my7IAoHhwOGoYe386nE0RCa7Nph0FF HFz4nkApA+T03Chl0EFnlvCZrI+HrbjlWiHUeCW0UG/pPXcOb+msKYSk3REigmMJsDvV tYCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601391; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E1U3mznWUSnJq2x7KzrZeo74yHwZxjse8U63SQkTN4k=; b=qONpkz2+vx9xvOBJUJdxphf5ZU0oP3ygyse8rS9YT4FReoYoIW1i3U2nfLfngi1ATn cK17jEuJMuYdhCvet4UOqfARxEfy+paUxrHjuGogOtc8DKvHp0Bk9TfKMO+AdEKA7BRy BIPNjHBqjqU5Ad5MpmS2PQszuKlXCguZAX2szjMTaRu5ZJABRjkb8YATEOKEHxjKWRfo 2oTJA7sLGh1hum6XiYct8EfHIh3iMH6psZzfVXH4eVosardk3agsf6Qbf3YT6I/stgbx DlnhC5HOnGnQSRABi7kRNnMvbBI9e8xuXP3p701/A+NgAK+yloZJisUbB3xt840o0I+u pvqw== X-Gm-Message-State: AAQBX9epsGS/LfwKwvQWMdiBnypnt7kkXouxlYHMJ2O/90xn9w7Uc9/Q 7qgTDcker68bNlnTuru2VDVCew== X-Google-Smtp-Source: AKy350a7DLDlAx2wATbxYZ+yV4+OnJfCSexEHHMxv0+zsfQNpGxjvujPBQwRFlw396afIThPkSlLDg== X-Received: by 2002:a05:6512:118d:b0:4eb:2b62:134f with SMTP id g13-20020a056512118d00b004eb2b62134fmr4661753lfr.16.1680601391634; Tue, 04 Apr 2023 02:43:11 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:11 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:04 +0200 Subject: [PATCH 2/9] pinctrl: nsp: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-2-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024315_710148_144CAEB5 X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-nsp-gpio.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c index 3c792bf03bda..5045a7e57f1d 100644 --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c @@ -60,7 +60,6 @@ struct nsp_gpio { struct device *dev; void __iomem *base; void __iomem *io_ctrl; - struct irq_chip irqchip; struct gpio_chip gc; struct pinctrl_dev *pctl; struct pinctrl_desc pctldesc; @@ -193,6 +192,7 @@ static void nsp_gpio_irq_mask(struct irq_data *d) raw_spin_lock_irqsave(&chip->lock, flags); nsp_gpio_irq_set_mask(d, false); raw_spin_unlock_irqrestore(&chip->lock, flags); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } static void nsp_gpio_irq_unmask(struct irq_data *d) @@ -201,6 +201,7 @@ static void nsp_gpio_irq_unmask(struct irq_data *d) struct nsp_gpio *chip = gpiochip_get_data(gc); unsigned long flags; + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); raw_spin_lock_irqsave(&chip->lock, flags); nsp_gpio_irq_set_mask(d, true); raw_spin_unlock_irqrestore(&chip->lock, flags); @@ -258,6 +259,16 @@ static int nsp_gpio_irq_set_type(struct irq_data *d, unsigned int type) return 0; } +static const struct irq_chip nsp_gpio_irq_chip = { + .name = "gpio-a", + .irq_ack = nsp_gpio_irq_ack, + .irq_mask = nsp_gpio_irq_mask, + .irq_unmask = nsp_gpio_irq_unmask, + .irq_set_type = nsp_gpio_irq_set_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int nsp_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) { struct nsp_gpio *chip = gpiochip_get_data(gc); @@ -650,14 +661,6 @@ static int nsp_gpio_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq > 0) { struct gpio_irq_chip *girq; - struct irq_chip *irqc; - - irqc = &chip->irqchip; - irqc->name = "gpio-a"; - irqc->irq_ack = nsp_gpio_irq_ack; - irqc->irq_mask = nsp_gpio_irq_mask; - irqc->irq_unmask = nsp_gpio_irq_unmask; - irqc->irq_set_type = nsp_gpio_irq_set_type; val = readl(chip->base + NSP_CHIP_A_INT_MASK); val = val | NSP_CHIP_A_GPIO_INT_BIT; @@ -673,7 +676,7 @@ static int nsp_gpio_probe(struct platform_device *pdev) } girq = &chip->gc.irq; - girq->chip = irqc; + gpio_irq_chip_set_chip(girq, &nsp_gpio_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; From patchwork Tue Apr 4 09:43:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199415 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87AA2C761AF for ; Tue, 4 Apr 2023 09:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3v9/AcGl33dtOTaxWa1dLLzSq0WkND+ObmxjF9WpYjM=; b=Gydca2prcCgF8G 4JsRZbPc+Bjwqb3PEr2O61oawO1rbgSGWmgHz4l21goVL3T+P8yL0L1vUM8uyWsiTghLiJAxSrIAh RILL/MueDCJBkQ1tqOx79A5oe4NMWWz/8PmdkuIGqeiwrNXJLB46hmjjgUrL+hRGTRm+qU0r0YQcm Y18yPobftGo9WlvWAZb9yiFA6OcztK0MmjIbf6ktfzEFwAHQb5QtTgHI8/Muj+yB6Xzxmb+Qplwnl SNmQqgZFeYtlHYzAawYCNhaRwfj9R33HMP2vuRnbg42noZZoTCuVDa5Jfc3siJM/iIwes0NqC6Dfw QtVkRH9Q9YEA/EZfc6Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCC-000kUb-1z; Tue, 04 Apr 2023 09:43:20 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC6-000kPv-1J for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:17 +0000 Received: by mail-lf1-x12a.google.com with SMTP id y15so41597038lfa.7 for ; Tue, 04 Apr 2023 02:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601392; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OEIEuBxKK8j0WCwoJQ18kuVBxSDA3HKgR75PLHwlYjY=; b=QUgnZEVbU8qkLDF2ntyTZYUEn81xMGQMTF+In3pJjOtoHeA+wHfgBjiPJd3SQo2ubS EdNjEPTsTPejVfxjcQyDuBp9bw6lcgMwOYJ0hzaw94espyf5V34EXkl/ZpBlcv3D9D83 +0V2+XrzqywGLnbVfh9drT5aX/q5V4zCL36sADRuJeqAfcn/NLlq8m4DdSrZY3wG0Zi/ q8FBEDa9RQuvXQZ0GWlpOlmM6ZZK4U1qYzUppqfAYv14x6YsE1Ip3xn/3V6DSPeA1aCF FhyY2tH7hm6RIvEb2q12iB15E5zC2jQ355mxMbjoyJAliFKlrL3/5gyw+cCOHZfsai7x J1Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601392; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OEIEuBxKK8j0WCwoJQ18kuVBxSDA3HKgR75PLHwlYjY=; b=monFQVlFXtt+sGeyhHOoO2fk2ikRNcPV8hTu2OrrDDQeYUVt48lcrVyj1lWCqxUoSi vAfo7gu7K4m9ADzVx8PDtMO74m92KE75lI5/XmXMstZp/Nh0yYGperZcAZMppvLSf/5T z2SIv4ITIituEvH82RXudLOht1ifYH1s11MiTdk5DoSFV6jNW124hdX2q2VXijR0V/tb +CQxyYFZSlzwNkpL2ta/kUWyfMquPHnC+gU6iwxjINGOMOOjtSDgOVhP4OxpC4aUzZ6c 1O9Z9FenDsRNqVXfMH+ofPeFp6rQidtJm+DescR7h5vN3lvybYd5O4pJRRyQZRqPSTYT 9nHw== X-Gm-Message-State: AAQBX9d3qMtMZ+jNS+qJR6EHWGZ5F4vLj1AtIvxQUJpM0VR/dBbDXooN uAyUJ9FwdhTs9zKMlLl/U2QeRA== X-Google-Smtp-Source: AKy350Y1n4D3ouEbNQ+64kQoJU+ffHbBrLRRh0g8NH1+mtywafqluhvvLZ5sB6bllrfgJQ3/14bcqQ== X-Received: by 2002:a19:ad04:0:b0:4cb:4362:381d with SMTP id t4-20020a19ad04000000b004cb4362381dmr457830lfc.62.1680601392722; Tue, 04 Apr 2023 02:43:12 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:12 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:05 +0200 Subject: [PATCH 3/9] pinctrl: armada-37xx: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-3-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024314_459562_F33D89EC X-CRM114-Status: GOOD ( 17.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 261b46841b9f..67c6751a6f06 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -101,7 +102,6 @@ struct armada_37xx_pinctrl { const struct armada_37xx_pin_data *data; struct device *dev; struct gpio_chip gpio_chip; - struct irq_chip irq_chip; raw_spinlock_t irq_lock; struct pinctrl_desc pctl; struct pinctrl_dev *pctl_dev; @@ -548,6 +548,7 @@ static void armada_37xx_irq_mask(struct irq_data *d) val = readl(info->base + reg); writel(val & ~d->mask, info->base + reg); raw_spin_unlock_irqrestore(&info->irq_lock, flags); + gpiochip_disable_irq(chip, irqd_to_hwirq(d)); } static void armada_37xx_irq_unmask(struct irq_data *d) @@ -557,6 +558,7 @@ static void armada_37xx_irq_unmask(struct irq_data *d) u32 val, reg = IRQ_EN; unsigned long flags; + gpiochip_enable_irq(chip, irqd_to_hwirq(d)); armada_37xx_irq_update_reg(®, d); raw_spin_lock_irqsave(&info->irq_lock, flags); val = readl(info->base + reg); @@ -729,11 +731,30 @@ static unsigned int armada_37xx_irq_startup(struct irq_data *d) return 0; } +static void armada_37xx_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct armada_37xx_pinctrl *info = gpiochip_get_data(chip); + + seq_printf(p, info->data->name); +} + +static const struct irq_chip armada_37xx_irqchip = { + .irq_ack = armada_37xx_irq_ack, + .irq_mask = armada_37xx_irq_mask, + .irq_unmask = armada_37xx_irq_unmask, + .irq_set_wake = armada_37xx_irq_set_wake, + .irq_set_type = armada_37xx_irq_set_type, + .irq_startup = armada_37xx_irq_startup, + .irq_print_chip = armada_37xx_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int armada_37xx_irqchip_register(struct platform_device *pdev, struct armada_37xx_pinctrl *info) { struct gpio_chip *gc = &info->gpio_chip; - struct irq_chip *irqchip = &info->irq_chip; struct gpio_irq_chip *girq = &gc->irq; struct device_node *np = to_of_node(gc->fwnode); struct device *dev = &pdev->dev; @@ -751,14 +772,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, if (IS_ERR(info->base)) return PTR_ERR(info->base); - irqchip->irq_ack = armada_37xx_irq_ack; - irqchip->irq_mask = armada_37xx_irq_mask; - irqchip->irq_unmask = armada_37xx_irq_unmask; - irqchip->irq_set_wake = armada_37xx_irq_set_wake; - irqchip->irq_set_type = armada_37xx_irq_set_type; - irqchip->irq_startup = armada_37xx_irq_startup; - irqchip->name = info->data->name; - girq->chip = irqchip; + gpio_irq_chip_set_chip(girq, &armada_37xx_irqchip); girq->parent_handler = armada_37xx_irq_handler; /* * Many interrupts are connected to the parent interrupt From patchwork Tue Apr 4 09:43:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199411 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 428FBC761A6 for ; Tue, 4 Apr 2023 09:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0CtlqtG/wLVrWZe7jVPax55W2L690Zy8ba8rcGmTtoE=; b=ohY3m/fIZuMdSy TDPeVjUQN4H8IIFPgDzckGGp5Dp+d/w1Pqz52oZx4YB0TyL3cCr2t92mVSN60XzxoQykr9eA6uRGl ZxUi+omAOmiPvtEm+UQtcS8jbI3UZlVpw3qAlZ9vIv8rEUTjH9Qs/Gn5EYWPuDREnm/i4PruVt06H 4IdyT2z2DIL3VVl60ctBXHWEuDUKDeCk6PkzKpedbEhF3L06Vk8qJF1WQc2SvGv8uYzaJqyqJ1YH6 U+XVl0J0A9mIhn6uQbBZF3Q7EM8Yc/JGmO8Gu2QNEJJyUe8/fsMGu3wWOy+aS0S752nPt8um2zNpg a8SJool5Xd9V40yDziiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCH-000kXQ-0T; Tue, 04 Apr 2023 09:43:25 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC8-000kQR-26 for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:19 +0000 Received: by mail-lf1-x12b.google.com with SMTP id c29so41632251lfv.3 for ; Tue, 04 Apr 2023 02:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601393; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MyI3cyYnrYsvyUY9zGwb5dqwePkLtUbYm7n0o21VTww=; b=VMkSf/30AORqPOlLZAvb5ejw7HZDEOIFzuFDKLf8ZeDEbmAan3qaO3LYScbQc9IBrD z3KNKoxPvP9VCHdV5C1q+HqWqDfxyxemBOlop94fOEmJJAqCmY0oOVPnFBk/nPhvPtlD 05cg/JC4v30mUyeoMFa3DQ6+i5PU3zMgNTANV7m80Kypa8rJcPZdaNVj3Clv+EbQyGmv 20gkxiqQIEK12gDQhJezK2Wcd1NquYFNF6ihh9EykeA70XyhRIhFy+LA8cGAM1Xw96Hv c/pB1pihxmAgDsslQ7maLWBZQr3ZHcuEuY1ABY9GS6J6GKEhEMqQyUCBCfLTQXiMlf+F QDfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601393; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MyI3cyYnrYsvyUY9zGwb5dqwePkLtUbYm7n0o21VTww=; b=7UtlVCss0+vHNUNQKOg3TNsEpV8mTVyF4plWfcgarkQSu0r2eE0jyK02kbuFeETeFz QlmeHL4xEibayj7otBgX+EEnHeXrSkKbj1Z+Zk0ncFoZobtylVQ9ndR2Zg7B+PaA0qkI ojQ66huVMDCdVJzuCEVYAxUez62Vzmme7u6VbWCeVzhT8NFtppvgl+/tlU0t8sApgqQO swzrCSW9eRHA02rV/2Ec+QFeIAT5OhJzzNtdmQjNb45RQZNkMWZVXOi9sQ2IZdFuWJqk t7NnUrjxDDvtzykodaKSbv3EPD0am7uecLq7DSom2n/pwOwHfiLQDpyAuYJ5CWsyKcBx XDsw== X-Gm-Message-State: AAQBX9eMe11MX8YvcqijjX8wwsTh1wGVdXWOlU/sZ88Fs3qPRvWP1v9s DIERqNz2wkcqfCd3UEYWJwc1DA== X-Google-Smtp-Source: AKy350bAzs+k3GfXqrHrUh46WUwBaaa8Kv09rrmTTSTImYh5z6/205iT1zyUw8YZhG01/6vEVWpsVQ== X-Received: by 2002:ac2:4422:0:b0:4cc:73ff:579a with SMTP id w2-20020ac24422000000b004cc73ff579amr549570lfl.38.1680601393741; Tue, 04 Apr 2023 02:43:13 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:13 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:06 +0200 Subject: [PATCH 4/9] pinctrl: npcm7xx: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-4-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024316_691607_F34EC22C X-CRM114-Status: GOOD ( 16.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. I refactored the way the state container was accessed in the irq_chip callbacks to all look the same and switch to use irqd_to_hwirq() while we are at it. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c index ff5bcea172e8..05d39f9111c2 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -82,7 +82,6 @@ struct npcm7xx_gpio { struct gpio_chip gc; int irqbase; int irq; - struct irq_chip irq_chip; u32 pinctrl_id; int (*direction_input)(struct gpio_chip *chip, unsigned int offset); int (*direction_output)(struct gpio_chip *chip, unsigned int offset, @@ -240,9 +239,9 @@ static void npcmgpio_irq_handler(struct irq_desc *desc) static int npcmgpio_set_irq_type(struct irq_data *d, unsigned int type) { - struct npcm7xx_gpio *bank = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int gpio = BIT(d->hwirq); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct npcm7xx_gpio *bank = gpiochip_get_data(gc); + unsigned int gpio = BIT(irqd_to_hwirq(d)); dev_dbg(bank->gc.parent, "setirqtype: %u.%u = %u\n", gpio, d->irq, type); @@ -288,9 +287,9 @@ static int npcmgpio_set_irq_type(struct irq_data *d, unsigned int type) static void npcmgpio_irq_ack(struct irq_data *d) { - struct npcm7xx_gpio *bank = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int gpio = d->hwirq; + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct npcm7xx_gpio *bank = gpiochip_get_data(gc); + unsigned int gpio = irqd_to_hwirq(d); dev_dbg(bank->gc.parent, "irq_ack: %u.%u\n", gpio, d->irq); iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVST); @@ -299,23 +298,25 @@ static void npcmgpio_irq_ack(struct irq_data *d) /* Disable GPIO interrupt */ static void npcmgpio_irq_mask(struct irq_data *d) { - struct npcm7xx_gpio *bank = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int gpio = d->hwirq; + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct npcm7xx_gpio *bank = gpiochip_get_data(gc); + unsigned int gpio = irqd_to_hwirq(d); /* Clear events */ dev_dbg(bank->gc.parent, "irq_mask: %u.%u\n", gpio, d->irq); iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENC); + gpiochip_disable_irq(gc, gpio); } /* Enable GPIO interrupt */ static void npcmgpio_irq_unmask(struct irq_data *d) { - struct npcm7xx_gpio *bank = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int gpio = d->hwirq; + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct npcm7xx_gpio *bank = gpiochip_get_data(gc); + unsigned int gpio = irqd_to_hwirq(d); /* Enable events */ + gpiochip_enable_irq(gc, gpio); dev_dbg(bank->gc.parent, "irq_unmask: %u.%u\n", gpio, d->irq); iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENS); } @@ -323,7 +324,7 @@ static void npcmgpio_irq_unmask(struct irq_data *d) static unsigned int npcmgpio_irq_startup(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - unsigned int gpio = d->hwirq; + unsigned int gpio = irqd_to_hwirq(d); /* active-high, input, clear interrupt, enable interrupt */ dev_dbg(gc->parent, "startup: %u.%u\n", gpio, d->irq); @@ -341,6 +342,8 @@ static const struct irq_chip npcmgpio_irqchip = { .irq_mask = npcmgpio_irq_mask, .irq_set_type = npcmgpio_set_irq_type, .irq_startup = npcmgpio_irq_startup, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; /* pinmux handing in the pinctrl driver*/ @@ -1906,7 +1909,6 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl) return -EINVAL; } pctrl->gpio_bank[id].irq = ret; - pctrl->gpio_bank[id].irq_chip = npcmgpio_irqchip; pctrl->gpio_bank[id].irqbase = id * NPCM7XX_GPIO_PER_BANK; pctrl->gpio_bank[id].pinctrl_id = args.args[0]; pctrl->gpio_bank[id].gc.base = args.args[1]; @@ -1941,7 +1943,7 @@ static int npcm7xx_gpio_register(struct npcm7xx_pinctrl *pctrl) struct gpio_irq_chip *girq; girq = &pctrl->gpio_bank[id].gc.irq; - girq->chip = &pctrl->gpio_bank[id].irq_chip; + gpio_irq_chip_set_chip(girq, &npcmgpio_irqchip); girq->parent_handler = npcmgpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(pctrl->dev, 1, From patchwork Tue Apr 4 09:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199414 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 671C7C77B6E for ; Tue, 4 Apr 2023 09:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jIk0ehvVVrrKcbqrTwWiioKwLMSduxBJn2GWN189PRw=; b=Nnxm5fhRuJVJgD GvzTnezC/ymUb1R0j6MEJHzuL7d/w2WSG0zb6RPjBg/TZLdYM80R9lZE6KeOPuA8x8HdfCJPfVGgu K69G0SJ9+g1dbwFJrBiaj/RH0w3K0i87HagmodYu4CbXa09GBWVGOtANzxXUGbKbxhe5yjopPZncX Jq38cU3E7cq5OcroRkvVeGNYczOGYkgwSAWRVdbhChruR7Wb/i1uX1WhI6HwdwY9SyRCbXV/eHr5N 7IwFwxkyl1jObM8S7oUTkL7ibauHpIHb1p9Rmq1RnZk5Hu4a0ezqcYtx2onqegxHifUoYtRtxcBQw 23qDd2vs1u6V4ffSprWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCK-000kZN-0H; Tue, 04 Apr 2023 09:43:28 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCA-000kRF-2I for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:20 +0000 Received: by mail-lf1-x131.google.com with SMTP id j11so41569916lfg.13 for ; Tue, 04 Apr 2023 02:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601394; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IvdTyVfTrmaDBV4ot+H/Nt1e4zaa23404aJu9Xqb7mA=; b=ICxJ7YUe4hMVhguFvpnF1aY1g2Xg4mx4cDsI89BJpwkDMlqLi6qFs0qAm1gH1e7IVc H9O3qmNc5Yl380YTtScMkdC5MjYUVycM0Bb98+MNi+509Acfjw7PXF5zmVlmcPvVwWo1 VSzvfDsF84XJxs79RETY7OSH6rXLO09va/3ONasKuU5gpMrlOEgtpmSU9I3aKMf9hlEZ MtI45uH3axyfhRJyE9oc9alpGa86BWOR2IXEDjISPQDnFE2IlXgfA0jpOdqvLwkpHCWf /WUJD9ayL7tzb2YqWLxpKOysDqLIUBDz39ffyaPdXGSmgnq+rp9f7iKgRfaZBtCqKQ9z kB7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601394; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IvdTyVfTrmaDBV4ot+H/Nt1e4zaa23404aJu9Xqb7mA=; b=WSZcGqM4/vP2mBw4BM0TwRyJiV8OQd3N27TXLktqLreHwjA5aRBOXIXRaxez2aXXhj jV6w4dih81HMXiWl30vcoL2m6+kmd8VEYs2eyl6fifjR2xqk/gtNrbznAmzbFZ90jzzt B8aXiRsfUGDk2pr6vdro/lWtQM5O0tSYZW7PuQwAAbbB9ERyzzYUsMSYXrP53fxxQoY0 frgbtXS1TPDv1OHDc6efVxr51TIO0RUwytMUSDibaTeBwM3ZRsDdRPowtPZ1gO1t9sGu Ur24eDJwA2EDpez5Tyqc9Ys3q8SCxPEjEkd3+Fm1Vfp1hx44FlApPUoSDS/Os4a3ZjBa NIqA== X-Gm-Message-State: AAQBX9eDPmSQXd+GsNccVjv4AcV2ZdtcbaJYGwUjtvH7hJkTxaxMzf8p FQrnOMbjJ+TpzSwcXg0mLVXIUA== X-Google-Smtp-Source: AKy350aeLsqesUsg+RRQuKpGDi2+iTAe42ueN49XS6nl4LpQF3DdNJ5O0KERzFnZGDFb/T4668h+8A== X-Received: by 2002:a05:6512:38c2:b0:4dd:cb1d:b3cc with SMTP id p2-20020a05651238c200b004ddcb1db3ccmr446350lft.11.1680601394784; Tue, 04 Apr 2023 02:43:14 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:14 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:07 +0200 Subject: [PATCH 5/9] pinctrl: equilibrium: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-5-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024318_746985_7BAAF4CC X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-equilibrium.c | 22 ++++++++++++++-------- drivers/pinctrl/pinctrl-equilibrium.h | 2 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index 99cf24eb67ae..5b5ddf7e5d0e 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -32,6 +32,7 @@ static void eqbr_gpio_disable_irq(struct irq_data *d) raw_spin_lock_irqsave(&gctrl->lock, flags); writel(BIT(offset), gctrl->membase + GPIO_IRNENCLR); raw_spin_unlock_irqrestore(&gctrl->lock, flags); + gpiochip_disable_irq(gc, offset); } static void eqbr_gpio_enable_irq(struct irq_data *d) @@ -42,6 +43,7 @@ static void eqbr_gpio_enable_irq(struct irq_data *d) unsigned long flags; gc->direction_input(gc, offset); + gpiochip_enable_irq(gc, offset); raw_spin_lock_irqsave(&gctrl->lock, flags); writel(BIT(offset), gctrl->membase + GPIO_IRNRNSET); raw_spin_unlock_irqrestore(&gctrl->lock, flags); @@ -161,6 +163,17 @@ static void eqbr_irq_handler(struct irq_desc *desc) chained_irq_exit(ic, desc); } +static const struct irq_chip eqbr_irq_chip = { + .name = "gpio_irq", + .irq_mask = eqbr_gpio_disable_irq, + .irq_unmask = eqbr_gpio_enable_irq, + .irq_ack = eqbr_gpio_ack_irq, + .irq_mask_ack = eqbr_gpio_mask_ack_irq, + .irq_set_type = eqbr_gpio_set_irq_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int gpiochip_setup(struct device *dev, struct eqbr_gpio_ctrl *gctrl) { struct gpio_irq_chip *girq; @@ -176,15 +189,8 @@ static int gpiochip_setup(struct device *dev, struct eqbr_gpio_ctrl *gctrl) return 0; } - gctrl->ic.name = "gpio_irq"; - gctrl->ic.irq_mask = eqbr_gpio_disable_irq; - gctrl->ic.irq_unmask = eqbr_gpio_enable_irq; - gctrl->ic.irq_ack = eqbr_gpio_ack_irq; - gctrl->ic.irq_mask_ack = eqbr_gpio_mask_ack_irq; - gctrl->ic.irq_set_type = eqbr_gpio_set_irq_type; - girq = &gctrl->chip.irq; - girq->chip = &gctrl->ic; + gpio_irq_chip_set_chip(girq, &eqbr_irq_chip); girq->parent_handler = eqbr_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), GFP_KERNEL); diff --git a/drivers/pinctrl/pinctrl-equilibrium.h b/drivers/pinctrl/pinctrl-equilibrium.h index 0c635a5b79f0..83768cc8b3db 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.h +++ b/drivers/pinctrl/pinctrl-equilibrium.h @@ -103,7 +103,6 @@ struct fwnode_handle; * @fwnode: firmware node of gpio controller. * @bank: pointer to corresponding pin bank. * @membase: base address of the gpio controller. - * @ic: irq chip. * @name: gpio chip name. * @virq: irq number of the gpio chip to parent's irq domain. * @lock: spin lock to protect gpio register write. @@ -113,7 +112,6 @@ struct eqbr_gpio_ctrl { struct fwnode_handle *fwnode; struct eqbr_pin_bank *bank; void __iomem *membase; - struct irq_chip ic; const char *name; unsigned int virq; raw_spinlock_t lock; /* protect gpio register */ From patchwork Tue Apr 4 09:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199410 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D85EC6FD1D for ; Tue, 4 Apr 2023 09:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0HaLPDLTz0JRbqgDZ1gO2KaVVnz1o6hV/RIwaJ9iiuU=; b=ynpmp8BShw2HJ+ UCTUc8u752XYMLg8XLRtOrmRlOlHwTVV8W5cXD+NXU0YfxYK7ADKzIfXtheP9Q90j9J3Zy3tpFY1B O50yrrXw1v38/yyh9yVTB3MfO1kmGVzc+tCoC9i4JupoCGa+5Ws6myzO0/p4eFYoXEWqDcJWjGR5H w0hi5MKwjWzwlutMy3lFwOeS8vlBqCUBr5SHVkSGiHDIRsLTMoEikcblEbJlyXssWJ4Q4iexh8QGA SbdErICJxvE/5LzZ+clmNX+S0EkNjYlL/GVcfkOSogyAvqrOA/tlVR44ULDSqjo0PPQnKq7ZK7BxM dvmdS0wQtQSHROuZ1f6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCE-000kVf-2I; Tue, 04 Apr 2023 09:43:22 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC9-000kRy-0f for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:18 +0000 Received: by mail-lf1-x12a.google.com with SMTP id br6so41574122lfb.11 for ; Tue, 04 Apr 2023 02:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601396; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZI0FMzsrAMmwpsYMT9sQehFdyel4tmSQAHLWGYELRs8=; b=WULO+ov5ZvN0aMdbSFLuRHF9Hg/nArG1Z86PpBV0FmeBEfJHhwhWpuirvHLQEj8yX1 s6e2TO5fbOL42dXzptwaOszI/zOBZmLNSA+QEekdE2WUaTmO8cFjGrv4Lj0ry4sBrTaj TC0yQsgT2ENf3XxEPrPOZnXWAbkyzVhTcICME/O6u0W2JxdrY+BIXdqibYNnQpsAoKBV ocjTbmDv0t4TAa/xwGJKuJuP0/Whyp4sRVtOLTZSuQH+vpdkQErWF5wGTP6cwhXjn0CP 3l5Gdryn9atZ9gPxMUIYgD/kql2Jdu76PrZmSX360TsFPr0iLD45f6PLc7wfvquKEquX 5AxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601396; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZI0FMzsrAMmwpsYMT9sQehFdyel4tmSQAHLWGYELRs8=; b=W8891tUEPLRoMkAIHUWBLrwPXSp6RNNzSRWMvaXdLhIbZdlrp5wDPfm81SX0vhmSA0 w5ZX+oHyqKLqigQ2ub2d2een3zVfs5W+YZWig+vv0bQPoGK6ckYu3z+0q6qUeOKwJmOm AWuBYkH4YC6EWhEbIsSQeAhdIBw+hBQC/eXz4HP/qLUlNb4da7AY+GCDfOw3dbHF4Ard 9RTZn+ROz+BBEONuxQdH1g1n3BESVj1+RvLFIBVzQoZDgHl22Fn7WQ5V9Q10Q9rMFKj0 3Dma+yvcFiMljDNLKZDQ3oI4+Ix8GKzPTJ1hPOcXNufpdXKE98MajKKj5sATdrCYEiY/ Mpaw== X-Gm-Message-State: AAQBX9cesDuRcFiuiR53u6Mi8hTRwrKSgCB3jN2gSGaCB7nvvkyTg4IH Zci7HP/xe2p6a+rcnxjozUHUvw== X-Google-Smtp-Source: AKy350Z2HFJtQJta6/+neaHmwGqoNe/plLSFJpnmh0+koaTH205JmdH3/LyK+YRNYhtTGY9axiebiA== X-Received: by 2002:a05:6512:32ab:b0:4db:971:82cd with SMTP id q11-20020a05651232ab00b004db097182cdmr5913134lfe.17.1680601395927; Tue, 04 Apr 2023 02:43:15 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:15 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:08 +0200 Subject: [PATCH 6/9] pinctrl: mcp23s08: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-6-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024317_270995_ABB47D70 X-CRM114-Status: GOOD ( 17.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. I switched to using irqd_to_hwirq() consistently while we are at it. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-mcp23s08.c | 36 ++++++++++++++++++++++++++---------- drivers/pinctrl/pinctrl-mcp23s08.h | 1 - 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index 5f356edfd0fd..7b7764c04327 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -436,17 +437,19 @@ static void mcp23s08_irq_mask(struct irq_data *data) { struct gpio_chip *gc = irq_data_get_irq_chip_data(data); struct mcp23s08 *mcp = gpiochip_get_data(gc); - unsigned int pos = data->hwirq; + unsigned int pos = irqd_to_hwirq(data); mcp_set_bit(mcp, MCP_GPINTEN, pos, false); + gpiochip_disable_irq(gc, pos); } static void mcp23s08_irq_unmask(struct irq_data *data) { struct gpio_chip *gc = irq_data_get_irq_chip_data(data); struct mcp23s08 *mcp = gpiochip_get_data(gc); - unsigned int pos = data->hwirq; + unsigned int pos = irqd_to_hwirq(data); + gpiochip_enable_irq(gc, pos); mcp_set_bit(mcp, MCP_GPINTEN, pos, true); } @@ -454,7 +457,7 @@ static int mcp23s08_irq_set_type(struct irq_data *data, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(data); struct mcp23s08 *mcp = gpiochip_get_data(gc); - unsigned int pos = data->hwirq; + unsigned int pos = irqd_to_hwirq(data); if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { mcp_set_bit(mcp, MCP_INTCON, pos, false); @@ -523,6 +526,25 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) return 0; } +static void mcp23s08_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct mcp23s08 *mcp = gpiochip_get_data(gc); + + seq_printf(p, dev_name(mcp->dev)); +} + +static const struct irq_chip mcp23s08_irq_chip = { + .irq_mask = mcp23s08_irq_mask, + .irq_unmask = mcp23s08_irq_unmask, + .irq_set_type = mcp23s08_irq_set_type, + .irq_bus_lock = mcp23s08_irq_bus_lock, + .irq_bus_sync_unlock = mcp23s08_irq_bus_unlock, + .irq_print_chip = mcp23s08_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + /*----------------------------------------------------------------------*/ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, @@ -538,12 +560,6 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, mcp->addr = addr; mcp->irq_active_high = false; - mcp->irq_chip.name = dev_name(dev); - mcp->irq_chip.irq_mask = mcp23s08_irq_mask; - mcp->irq_chip.irq_unmask = mcp23s08_irq_unmask; - mcp->irq_chip.irq_set_type = mcp23s08_irq_set_type; - mcp->irq_chip.irq_bus_lock = mcp23s08_irq_bus_lock; - mcp->irq_chip.irq_bus_sync_unlock = mcp23s08_irq_bus_unlock; mcp->chip.direction_input = mcp23s08_direction_input; mcp->chip.get = mcp23s08_get; @@ -603,7 +619,7 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, if (mcp->irq && mcp->irq_controller) { struct gpio_irq_chip *girq = &mcp->chip.irq; - girq->chip = &mcp->irq_chip; + gpio_irq_chip_set_chip(girq, &mcp23s08_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; diff --git a/drivers/pinctrl/pinctrl-mcp23s08.h b/drivers/pinctrl/pinctrl-mcp23s08.h index b8d15939e0c2..b15516af7783 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.h +++ b/drivers/pinctrl/pinctrl-mcp23s08.h @@ -36,7 +36,6 @@ struct mcp23s08 { struct mutex lock; struct gpio_chip chip; - struct irq_chip irq_chip; struct regmap *regmap; struct device *dev; From patchwork Tue Apr 4 09:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199412 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4907BC77B62 for ; Tue, 4 Apr 2023 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q644VJyLR8mygfTfYztAPprMPBoAGgjT9d9MWp7Y84Y=; b=aKrn8/2vFH0DxM FuJL2uOfEkEObANC/Jm4GkPa9motmn7JS0GgJ/XcJieiW+98ihkXqYdtP8XdD1ERD5Hy8G+FHQxIa MEoy1l1u+uAakpN412sTuuTPVrbzFqaLW2O61L3qCSTmjtcKMMQWjCuuLdQEBcgT8pCohJJuSTh0R WEBhzc1otutHvFD3GEcZ9cJQmh++55zMDwQhbLZ/bnj1BoCZ8NiB8xqLkjcAPOg+MG3DxS5KKCWJf XjbNbocWYapXYCA1/Y6TzrWhtFsQ2m2PG/LfKIpEbOTwBuzq7425QcHSInMpT+VKtToDvo/PxYalT 7nVEWVC5Iz6kl9036XBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCI-000kY4-0n; Tue, 04 Apr 2023 09:43:26 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdC9-000kPk-1p for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:20 +0000 Received: by mail-lf1-x12a.google.com with SMTP id q16so41585258lfe.10 for ; Tue, 04 Apr 2023 02:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601397; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MNYdQtD12ErxW9Tb9ALuTo8L9TpmlxX4Klxpk5H7jnk=; b=jYDIjklTKr8Cj1T9VYHcmDrIMw8h/xDvQ8AMsEyXG+GrHhNO6IT9GJzRVnpgvE4yOr bQ0iZBI8TaAJOXFbpWzOtgJL6eO+DTNoYJoUFm1SpNwJRbx4KIdU7BzH5hvCEIQROCfV UO7TGmAGOtDwu2qtnobq3CJ12F7/QAEvf9COV1OTAtdZvsQ9njcN3WU1ziJ2Tlk6Hbyv DdSrZZcOGKQvQVaF/j5ZLtSOL01ixH6Jb0wKyxDe9LegyLQ/2P6VG5YtKct2uf4iAp3B 6y8YnqYVJX/tsuFKs/z1r9qs7y/ylL6o40MaYO4Cg+S0mBerit+PSnXLxbzR2a9eNyVi l1GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601397; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MNYdQtD12ErxW9Tb9ALuTo8L9TpmlxX4Klxpk5H7jnk=; b=pfk2rBmh+hH67je87h/1fsknDeBI1cRNTjF/ILGafAgHRJt5CmwRLQXmrRnAK9czS1 4rTkKA6E6WeKtinsEoS2wr6mXzV3IWDsoxgB0+FD884rO4U5RPDLxQedTbfJJmFO+Z/f LBlNxuapv6f8QMXRuEGIvTgBQ6+APzxtCG6PO0ls9/Q0WqFj1T2fYV2Nvjb2ZRsi5nn2 FRfKtiY86RLJAOYCYDa05MuorvxUzbhaPBO6PAiix0VLF6NjzjoovH5eb1vdnUp017Te XyR32yS3ljywKrXhgVfJBAa05SLDQkHA7YRb6nMDHaB1Flnd0miuzK38+gxSOpzA/63q U+qQ== X-Gm-Message-State: AAQBX9cPcHwq2UyujOTJt864BbmaqzwYEl3ObDKwrDOH9TjJm9qWbb2W zsZIL488DQcejnkJHvrb2140sg== X-Google-Smtp-Source: AKy350aGvdFi+RZKjqDDMQzvmBaZ/OiWcvh3hUJR1pdqaSXWZoxf8OpalMpYOO2vxe4OeQZKqKjv7g== X-Received: by 2002:ac2:43a5:0:b0:4b0:2a2f:ea6d with SMTP id t5-20020ac243a5000000b004b02a2fea6dmr444334lfl.35.1680601397119; Tue, 04 Apr 2023 02:43:17 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:16 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:09 +0200 Subject: [PATCH 7/9] pinctrl: st: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-7-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024317_626647_C9220F12 X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. I switched to using irqd_to_hwirq() consistently while we are at it. This driver does not use the GPIOCHIP_IRQ_RESOURCE_HELPERS as it defines its own resource reservations, simply in order to turn IRQ lines into inputs on initialization. Also switched the open coded calls to gpiochip_lock_as_irq() to gpiochip_reqres_irq() so we also get the right module reference counting. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 1409339f0279..c1f36b164ea5 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1313,7 +1313,8 @@ static void st_gpio_irq_mask(struct irq_data *d) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct st_gpio_bank *bank = gpiochip_get_data(gc); - writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); + writel(BIT(irqd_to_hwirq(d)), bank->base + REG_PIO_CLR_PMASK); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } static void st_gpio_irq_unmask(struct irq_data *d) @@ -1321,7 +1322,8 @@ static void st_gpio_irq_unmask(struct irq_data *d) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct st_gpio_bank *bank = gpiochip_get_data(gc); - writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); + writel(BIT(irqd_to_hwirq(d)), bank->base + REG_PIO_SET_PMASK); } static int st_gpio_irq_request_resources(struct irq_data *d) @@ -1330,14 +1332,14 @@ static int st_gpio_irq_request_resources(struct irq_data *d) st_gpio_direction_input(gc, d->hwirq); - return gpiochip_lock_as_irq(gc, d->hwirq); + return gpiochip_reqres_irq(gc, d->hwirq); } static void st_gpio_irq_release_resources(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - gpiochip_unlock_as_irq(gc, d->hwirq); + gpiochip_relres_irq(gc, d->hwirq); } static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) @@ -1492,7 +1494,7 @@ static const struct gpio_chip st_gpio_template = { .ngpio = ST_GPIO_PINS_PER_BANK, }; -static struct irq_chip st_gpio_irqchip = { +static const struct irq_chip st_gpio_irqchip = { .name = "GPIO", .irq_request_resources = st_gpio_irq_request_resources, .irq_release_resources = st_gpio_irq_release_resources, @@ -1500,7 +1502,7 @@ static struct irq_chip st_gpio_irqchip = { .irq_mask = st_gpio_irq_mask, .irq_unmask = st_gpio_irq_unmask, .irq_set_type = st_gpio_irq_set_type, - .flags = IRQCHIP_SKIP_SET_WAKE, + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, }; static int st_gpiolib_register_bank(struct st_pinctrl *info, @@ -1570,7 +1572,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, } girq = &bank->gpio_chip.irq; - girq->chip = &st_gpio_irqchip; + gpio_irq_chip_set_chip(girq, &st_gpio_irqchip); girq->parent_handler = st_gpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), From patchwork Tue Apr 4 09:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199418 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44FBAC761A6 for ; Tue, 4 Apr 2023 09:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CCQW6h9DE8oQqs17Jertsg4gZw50JtjXeHe6knuZpk8=; b=doouhYcfCA7TDS fSfDY6nvdrIxw+L7Ji+dPn8Is/1772tX4BxVsQLLJiuJ4acnljKEvBJzQsluJk2v2wRIv57ifVDoc U+ROOfAZxk1EjxYbNcQ+3EhZKxXQM+v9NdyeBqGr0r4lJ1y3ntbgkBB7jSjn9hKxR4AuNdKHI/Qnl Z2xr3AnqbvItS09YCaXON+im9R0VZ8YZ8/7kxphw2iWrnpMBnB11eJdSD2gal9OYpihmEhRtoDGtP VwfhmEDCelWZKw4tfTnYf9pjbzqFrK8aL+vmhFYLQyCLDFhRx1sbhe42j3clBYlvsUgwZmZEG2g6M UctJ0L7lVAXQIneB1GUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCL-000kZw-0j; Tue, 04 Apr 2023 09:43:29 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCB-000kTQ-20 for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:21 +0000 Received: by mail-lf1-x133.google.com with SMTP id br6so41574220lfb.11 for ; Tue, 04 Apr 2023 02:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601398; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qbp5jveZuzO4r+Wb5Hve1cqOR9sHInUuZ3dFCFmIV6M=; b=soPMTVlcwLFSs/PtZ3xuloR1YprIJgq5gnITeQFsZZ0gFh8y81eUPT66DmPN1Ioph6 ZwBOqwfx8CdK8ca/r3w2gNgIfi7tQzoVbuAxkFg+uo2Nc+DhRNA0cXXo7zQ52ILg8+/E aW2LqJCckiXThRcvxfrV7Tz6wakK5dDXqbUs8y/zAtswTW/RqkLtPIYxRnB9UB/pn/6+ KHGGIZL0443cRzjzYCB2w4rkdnWVZbBLVpmf75qQRKZKjj4X1sj4F38KWomG9kk6HhDs eJdX8+4RaBVDgo4D21ZXyn84AYqQoCxu+fksVURS7Up9i008GG19+MEL9NjwDsVc8me3 clVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601398; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qbp5jveZuzO4r+Wb5Hve1cqOR9sHInUuZ3dFCFmIV6M=; b=gKDeACZG9gxSetBtNviO3dG35+IeE7teabydUwbjeG0MULLa8jPyrqKjzF/H4hAfOE Fj+nFRYOtATs8IPhFH/9jrIF4zQyTlgF7etZG6UrGXD+detKpQtrxoVPdBOPgVH6uIka PqnbJhBOxJ5K/vXwNbPhnyK7gZjllC1s0cqHgpNU22dav7J7l5A/g0/O7FZ2tkebUEIa zgsdSO2FiGy0qZQuCnkZ8QpHrz3uI7EIPjQgD/jn3Uw+V8s0pe3cenc9GvcflW77zl9y BVv5HA8rrIIjjtlu4eGXyBy/txCFyWb3IvbGJglwE2vjaHTuCir9IUjiWA7ozCMUIFW2 LAUg== X-Gm-Message-State: AAQBX9fR0UIsP72WtDephrSN13UgdtdQUJ/0JtR9BANSWpFy4Kcm03zT jIcNrYRGvw6EJDMKXKyjHPMD6A== X-Google-Smtp-Source: AKy350aaSf2WBwWmJ44plhwCi9IO+IsKnfCj7W2KXi50QhxuaoXCfqADvAQkBEz1VIBbYXmZlXoj7Q== X-Received: by 2002:ac2:424d:0:b0:4d8:71dd:5c5e with SMTP id m13-20020ac2424d000000b004d871dd5c5emr409630lfl.37.1680601398122; Tue, 04 Apr 2023 02:43:18 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:17 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:10 +0200 Subject: [PATCH 8/9] pinctrl: stmfx: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-8-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024319_687254_DD5F99C8 X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. This driver rolls it's own resource handling and does not use GPIOCHIP_IRQ_RESOURCE_HELPERS. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-stmfx.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c index 1181c4b506b1..eba7d8d9c753 100644 --- a/drivers/pinctrl/pinctrl-stmfx.c +++ b/drivers/pinctrl/pinctrl-stmfx.c @@ -85,7 +85,6 @@ struct stmfx_pinctrl { struct pinctrl_dev *pctl_dev; struct pinctrl_desc pctl_desc; struct gpio_chip gpio_chip; - struct irq_chip irq_chip; struct mutex lock; /* IRQ bus lock */ unsigned long gpio_valid_mask; /* Cache of IRQ_GPI_* registers for bus_lock */ @@ -427,6 +426,7 @@ static void stmfx_pinctrl_irq_mask(struct irq_data *data) u32 mask = get_mask(data->hwirq); pctl->irq_gpi_src[reg] &= ~mask; + gpiochip_disable_irq(gpio_chip, irqd_to_hwirq(data)); } static void stmfx_pinctrl_irq_unmask(struct irq_data *data) @@ -436,6 +436,7 @@ static void stmfx_pinctrl_irq_unmask(struct irq_data *data) u32 reg = get_reg(data->hwirq); u32 mask = get_mask(data->hwirq); + gpiochip_enable_irq(gpio_chip, irqd_to_hwirq(data)); pctl->irq_gpi_src[reg] |= mask; } @@ -592,6 +593,26 @@ static irqreturn_t stmfx_pinctrl_irq_thread_fn(int irq, void *dev_id) return IRQ_HANDLED; } +static void stmfx_pinctrl_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(d); + struct stmfx_pinctrl *pctl = gpiochip_get_data(gpio_chip); + + seq_printf(p, dev_name(pctl->dev)); +} + +static const struct irq_chip stmfx_pinctrl_irq_chip = { + .irq_mask = stmfx_pinctrl_irq_mask, + .irq_unmask = stmfx_pinctrl_irq_unmask, + .irq_set_type = stmfx_pinctrl_irq_set_type, + .irq_bus_lock = stmfx_pinctrl_irq_bus_lock, + .irq_bus_sync_unlock = stmfx_pinctrl_irq_bus_sync_unlock, + .irq_request_resources = stmfx_gpio_irq_request_resources, + .irq_release_resources = stmfx_gpio_irq_release_resources, + .irq_print_chip = stmfx_pinctrl_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, +}; + static int stmfx_pinctrl_gpio_function_enable(struct stmfx_pinctrl *pctl) { struct pinctrl_gpio_range *gpio_range; @@ -678,17 +699,8 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev) pctl->gpio_chip.ngpio = pctl->pctl_desc.npins; pctl->gpio_chip.can_sleep = true; - pctl->irq_chip.name = dev_name(pctl->dev); - pctl->irq_chip.irq_mask = stmfx_pinctrl_irq_mask; - pctl->irq_chip.irq_unmask = stmfx_pinctrl_irq_unmask; - pctl->irq_chip.irq_set_type = stmfx_pinctrl_irq_set_type; - pctl->irq_chip.irq_bus_lock = stmfx_pinctrl_irq_bus_lock; - pctl->irq_chip.irq_bus_sync_unlock = stmfx_pinctrl_irq_bus_sync_unlock; - pctl->irq_chip.irq_request_resources = stmfx_gpio_irq_request_resources; - pctl->irq_chip.irq_release_resources = stmfx_gpio_irq_release_resources; - girq = &pctl->gpio_chip.irq; - girq->chip = &pctl->irq_chip; + gpio_irq_chip_set_chip(girq, &stmfx_pinctrl_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; @@ -710,7 +722,7 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev) ret = devm_request_threaded_irq(pctl->dev, irq, NULL, stmfx_pinctrl_irq_thread_fn, IRQF_ONESHOT, - pctl->irq_chip.name, pctl); + dev_name(pctl->dev), pctl); if (ret) { dev_err(pctl->dev, "cannot request irq%d\n", irq); return ret; From patchwork Tue Apr 4 09:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13199419 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23BFDC77B62 for ; Tue, 4 Apr 2023 09:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Izm0f+eElW7aPYTxnMs5DJvzBEW1IWfASLeT3c+tVJ4=; b=dV/XA2NhNGSBlr dNblnbYkgtbvfVe4AeM0Hged6diUCNW8mdO/1+rc8/koq2f9dpiD0Tnbsv4bvQ7uzyHiaMXL4LuQe E0wMdyHulZbtjIF2SNONW8UD+C5FuGDAIae8l/wT7XjBkn3W0Y92xD2SCznA+71RQs0ehnHBboEMH +6pxFfRSmtveEjDo8O/raL9GwNwxC9wf11smcrCACRiD84L4qqI1gVkpbZUoQ5XIv8PaWk8bQEkQ/ 9KNjSiHkboNogRDLcsdeIBfa1Rq4EgcCi8Y44V6+fX6HfbZwFejuu0up86y4p9yOdoA/YB4UVV18K SooF+FCoOg+MlOtbHJGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCN-000kbR-0e; Tue, 04 Apr 2023 09:43:31 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdCE-000kUJ-0i for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 09:43:23 +0000 Received: by mail-lf1-x134.google.com with SMTP id bi9so41584433lfb.12 for ; Tue, 04 Apr 2023 02:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680601399; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RNcW0+JGFul/r7gTdVaVYsY6oiF69IsvdynyWjh+xH4=; b=IqiscGQIO7vvpA7PHEppUJtobdxHepbMUx6GNwDfHGIpDOZJG/8BLcmKFApHwQd+cy /ZoysvY8PM3jpBWKDq8C3E6DvCqNS24xASrDSBdO/8kEozm+lmFgZ+c0nwK9VZq2uatj cDSATL8++/5ds6m+vsT5QFlSjt9bjr17lLmhLW2phdaWVBU5SV32aqsZoT2S/9DaVKx8 0ua+hmO/doBPifDKuTTcAUAUbRZdQEUH8CuZTIii9/tqyX8mjzjg4S5joY258LjcJbXm AeCeL47eYslepdPd7/EPqfSbdDuOvgp95hvVT0lRnFt3kjd6rJi3I2JcozXcUr9E00Wz jF3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680601399; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RNcW0+JGFul/r7gTdVaVYsY6oiF69IsvdynyWjh+xH4=; b=tfu+1Rgf1iePsEAvnMfIccoXxU8wMK+AVgj8SYCraPnP4ZkgXC24oWA+ajfmTE8mcW 0REA4pPBVkCxmdh9MtSS7R89KGa0r6usk3IE+AqXRXxxBHbligZ9wU6gme7kAOaSyF1L 6ur5cCArdf1NgucbK9fKcBkoEKOG5IriHggM2VG8uPGc0nLj7RuGq2l72pGfKJBX2E8D HeA+hXzNlyH3tHZwatv0kQK9Slew9RsXaBY1q6adHdN0VWoL/Zle4iWso84eanDBLH+6 E2BWeky/SqSEBOAtTCNAcdPt+oTWOObSubdiR8p0HMSOeZjSZ/yhAx7nO6RSUjj5C/nY s+4Q== X-Gm-Message-State: AAQBX9fOgAtylQx3NQhjwzhec625zHThkd/f4w5W+1DAwEyUofzi/Aca 3/0Tw7NFUyRtxdeXMr3BJjM4/w== X-Google-Smtp-Source: AKy350bHtWLWxkw8v/3gtXShSIG6n42OYlnsV/lCyqHmYlMKXuVm423gkCgVUETn229gxABvBap0QQ== X-Received: by 2002:ac2:59d9:0:b0:4ea:fa87:7a8a with SMTP id x25-20020ac259d9000000b004eafa877a8amr445870lfn.37.1680601399242; Tue, 04 Apr 2023 02:43:19 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l25-20020a19c219000000b004eb258f73a9sm2218443lfc.163.2023.04.04.02.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 02:43:18 -0700 (PDT) From: Linus Walleij Date: Tue, 04 Apr 2023 11:43:11 +0200 Subject: [PATCH 9/9] pinctrl: sx150x: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230403-immutable-irqchips-v1-9-503788a7f6e6@linaro.org> References: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> In-Reply-To: <20230403-immutable-irqchips-v1-0-503788a7f6e6@linaro.org> To: Ray Jui , Scott Branden , Broadcom internal kernel review list , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Patrice Chotard , Maxime Coquelin , Alexandre Torgue Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_024322_261643_11B25C6C X-CRM114-Status: GOOD ( 20.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. I switched to consistently using irqd_to_hwirq() consistently while we are at it. As the driver now needs to get the gpio_chip in the .irq_mask and .irq_unmask callbacks, I switched to a pattern where we first fetch the gpio_chip and then the state container from that in two steps. The compiler will do the same thing anyway. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-sx150x.c | 64 +++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c index 0b5ff99641e1..e49c7be2b47b 100644 --- a/drivers/pinctrl/pinctrl-sx150x.c +++ b/drivers/pinctrl/pinctrl-sx150x.c @@ -99,7 +99,6 @@ struct sx150x_pinctrl { struct pinctrl_dev *pctldev; struct pinctrl_desc pinctrl_desc; struct gpio_chip gpio; - struct irq_chip irq_chip; struct regmap *regmap; struct { u32 sense; @@ -487,19 +486,21 @@ static int sx150x_gpio_direction_output(struct gpio_chip *chip, static void sx150x_irq_mask(struct irq_data *d) { - struct sx150x_pinctrl *pctl = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int n = d->hwirq; + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); + unsigned int n = irqd_to_hwirq(d); pctl->irq.masked |= BIT(n); + gpiochip_disable_irq(gc, n); } static void sx150x_irq_unmask(struct irq_data *d) { - struct sx150x_pinctrl *pctl = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - unsigned int n = d->hwirq; + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); + unsigned int n = irqd_to_hwirq(d); + gpiochip_enable_irq(gc, n); pctl->irq.masked &= ~BIT(n); } @@ -520,14 +521,14 @@ static void sx150x_irq_set_sense(struct sx150x_pinctrl *pctl, static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type) { - struct sx150x_pinctrl *pctl = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); unsigned int n, val = 0; if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) return -EINVAL; - n = d->hwirq; + n = irqd_to_hwirq(d); if (flow_type & IRQ_TYPE_EDGE_RISING) val |= SX150X_IRQ_TYPE_EDGE_RISING; @@ -562,22 +563,42 @@ static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id) static void sx150x_irq_bus_lock(struct irq_data *d) { - struct sx150x_pinctrl *pctl = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); mutex_lock(&pctl->lock); } static void sx150x_irq_bus_sync_unlock(struct irq_data *d) { - struct sx150x_pinctrl *pctl = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); regmap_write(pctl->regmap, pctl->data->reg_irq_mask, pctl->irq.masked); regmap_write(pctl->regmap, pctl->data->reg_sense, pctl->irq.sense); mutex_unlock(&pctl->lock); } + +static void sx150x_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); + + seq_printf(p, pctl->client->name); +} + +static const struct irq_chip sx150x_irq_chip = { + .irq_mask = sx150x_irq_mask, + .irq_unmask = sx150x_irq_unmask, + .irq_set_type = sx150x_irq_set_type, + .irq_bus_lock = sx150x_irq_bus_lock, + .irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock, + .irq_print_chip = sx150x_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, unsigned long *config) { @@ -1181,19 +1202,8 @@ static int sx150x_probe(struct i2c_client *client) if (client->irq > 0) { struct gpio_irq_chip *girq; - pctl->irq_chip.irq_mask = sx150x_irq_mask; - pctl->irq_chip.irq_unmask = sx150x_irq_unmask; - pctl->irq_chip.irq_set_type = sx150x_irq_set_type; - pctl->irq_chip.irq_bus_lock = sx150x_irq_bus_lock; - pctl->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock; - pctl->irq_chip.name = devm_kstrdup(dev, client->name, - GFP_KERNEL); - if (!pctl->irq_chip.name) - return -ENOMEM; - pctl->irq.masked = ~0; pctl->irq.sense = 0; - /* * Because sx150x_irq_threaded_fn invokes all of the * nested interrupt handlers via handle_nested_irq, @@ -1206,7 +1216,7 @@ static int sx150x_probe(struct i2c_client *client) * called (should not happen) */ girq = &pctl->gpio.irq; - girq->chip = &pctl->irq_chip; + gpio_irq_chip_set_chip(girq, &sx150x_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; @@ -1219,7 +1229,7 @@ static int sx150x_probe(struct i2c_client *client) sx150x_irq_thread_fn, IRQF_ONESHOT | IRQF_SHARED | IRQF_TRIGGER_FALLING, - pctl->irq_chip.name, pctl); + client->name, pctl); if (ret < 0) return ret; }