From nobody Wed Sep 17 10:04:55 2025 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 80C0FC4167B for ; Tue, 20 Dec 2022 13:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbiLTNYq (ORCPT ); Tue, 20 Dec 2022 08:24:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233569AbiLTNYi (ORCPT ); Tue, 20 Dec 2022 08:24:38 -0500 Received: from out-240.mta0.migadu.com (out-240.mta0.migadu.com [91.218.175.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 930DA1A062 for ; Tue, 20 Dec 2022 05:24:31 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1671542668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fn0UF29ExGYYN9yHRFeunYSNii70MOtxu0VxA0YXtZ0=; b=kk5+xyAdhqa7F/Y44XI4OmXWGv5J79aUGUXJM/GdeMganWT0T3IxSKYmx/fpakKWhGMDFp gQ252f3zZw++8ODeAhzOdUdt9R3p5U157LDfMv3xX2Iz6o5gUJBMfFB0XtNS2UC54QdMup 771d7OU13kOxS/DxkOce5ARnUEr997o= From: Cixi Geng To: linus.walleij@linaro.org, brgl@bgdev.pl, orsonzhai@gmail.com, baolin.wang@linux.alibaba.com, zhang.lyra@gmail.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 1/3] gpio: eic-sprd: Make the irqchip immutable Date: Tue, 20 Dec 2022 21:23:39 +0800 Message-Id: <20221220132341.19383-2-cixi.geng@linux.dev> In-Reply-To: <20221220132341.19383-1-cixi.geng@linux.dev> References: <20221220132341.19383-1-cixi.geng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Cixi Geng Remove the irq_chip from pmic_eic structure, use the various calls by defining the statically irq_chip structure. Signed-off-by: Cixi Geng --- drivers/gpio/gpio-eic-sprd.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c index 8d722e026e9c..86563c0604e8 100644 --- a/drivers/gpio/gpio-eic-sprd.c +++ b/drivers/gpio/gpio-eic-sprd.c @@ -91,7 +91,6 @@ enum sprd_eic_type { =20 struct sprd_eic { struct gpio_chip chip; - struct irq_chip intc; void __iomem *base[SPRD_EIC_MAX_BANK]; enum sprd_eic_type type; spinlock_t lock; @@ -255,6 +254,8 @@ static void sprd_eic_irq_mask(struct irq_data *data) default: dev_err(chip->parent, "Unsupported EIC type.\n"); } + + gpiochip_disable_irq(chip, offset); } =20 static void sprd_eic_irq_unmask(struct irq_data *data) @@ -263,6 +264,8 @@ static void sprd_eic_irq_unmask(struct irq_data *data) struct sprd_eic *sprd_eic =3D gpiochip_get_data(chip); u32 offset =3D irqd_to_hwirq(data); =20 + gpiochip_enable_irq(chip, offset); + switch (sprd_eic->type) { case SPRD_EIC_DEBOUNCE: sprd_eic_update(chip, offset, SPRD_EIC_DBNC_IE, 1); @@ -564,6 +567,15 @@ static void sprd_eic_irq_handler(struct irq_desc *desc) chained_irq_exit(ic, desc); } =20 +static const struct irq_chip sprd_eic_irq =3D { + .name =3D "sprd-eic-gpio", + .irq_ack =3D sprd_eic_irq_ack, + .irq_mask =3D sprd_eic_irq_mask, + .irq_unmask =3D sprd_eic_irq_unmask, + .irq_set_type =3D sprd_eic_irq_set_type, + .flags =3D IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; static int sprd_eic_probe(struct platform_device *pdev) { const struct sprd_eic_variant_data *pdata; @@ -626,15 +638,8 @@ static int sprd_eic_probe(struct platform_device *pdev) break; } =20 - sprd_eic->intc.name =3D dev_name(&pdev->dev); - sprd_eic->intc.irq_ack =3D sprd_eic_irq_ack; - sprd_eic->intc.irq_mask =3D sprd_eic_irq_mask; - sprd_eic->intc.irq_unmask =3D sprd_eic_irq_unmask; - sprd_eic->intc.irq_set_type =3D sprd_eic_irq_set_type; - sprd_eic->intc.flags =3D IRQCHIP_SKIP_SET_WAKE; - irq =3D &sprd_eic->chip.irq; - irq->chip =3D &sprd_eic->intc; + gpio_irq_chip_set_chip(irq, &sprd_eic_irq); irq->handler =3D handle_bad_irq; irq->default_type =3D IRQ_TYPE_NONE; irq->parent_handler =3D sprd_eic_irq_handler; --=20 2.34.1 From nobody Wed Sep 17 10:04:55 2025 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 C5C43C4332F for ; Tue, 20 Dec 2022 13:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbiLTNY5 (ORCPT ); Tue, 20 Dec 2022 08:24:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbiLTNYl (ORCPT ); Tue, 20 Dec 2022 08:24:41 -0500 Received: from out-5.mta0.migadu.com (out-5.mta0.migadu.com [91.218.175.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 463091A22D for ; Tue, 20 Dec 2022 05:24:34 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1671542672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X5m8HaHVkvDRo1mPS0/MegFApoCHSK8vTZSy37tpuxA=; b=bMhBhzREa8LFUKTi7jvKCPMM9ZxX3BOa/y3Og2IKQ1kER3NV4S0LH/o6Es2qZiWbGLijPC 8T0TF/qx8STftC2y6qB0Eu5HhmN8G01jM0dHU38X7tFpCdXnYv9kqBtg6GcBRuQv02JGoB cbmcdeWTiSwKTIYl9bSYoAW8pwQ65SU= From: Cixi Geng To: linus.walleij@linaro.org, brgl@bgdev.pl, orsonzhai@gmail.com, baolin.wang@linux.alibaba.com, zhang.lyra@gmail.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/3] gpio: gpio-pmic-eic-sprd: Make the irqchip immutable Date: Tue, 20 Dec 2022 21:23:40 +0800 Message-Id: <20221220132341.19383-3-cixi.geng@linux.dev> In-Reply-To: <20221220132341.19383-1-cixi.geng@linux.dev> References: <20221220132341.19383-1-cixi.geng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Cixi Geng Remove the irq_chip from pmic_eic structure, use the various calls by defining the statically irq_chip structure. Signed-off-by: Cixi Geng --- drivers/gpio/gpio-pmic-eic-sprd.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-pmic-eic-sprd.c b/drivers/gpio/gpio-pmic-eic= -sprd.c index e518490c4b68..add15416f7a6 100644 --- a/drivers/gpio/gpio-pmic-eic-sprd.c +++ b/drivers/gpio/gpio-pmic-eic-sprd.c @@ -47,7 +47,6 @@ enum { /** * struct sprd_pmic_eic - PMIC EIC controller * @chip: the gpio_chip structure. - * @intc: the irq_chip structure. * @map: the regmap from the parent device. * @offset: the EIC controller's offset address of the PMIC. * @reg: the array to cache the EIC registers. @@ -56,7 +55,6 @@ enum { */ struct sprd_pmic_eic { struct gpio_chip chip; - struct irq_chip intc; struct regmap *map; u32 offset; u8 reg[CACHE_NR_REGS]; @@ -151,15 +149,21 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *d= ata) { struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); struct sprd_pmic_eic *pmic_eic =3D gpiochip_get_data(chip); + irq_hw_number_t hwirq =3D irqd_to_hwirq(data); =20 pmic_eic->reg[REG_IE] =3D 0; pmic_eic->reg[REG_TRIG] =3D 0; + + gpiochip_disable_irq(chip, hwirq); } =20 static void sprd_pmic_eic_irq_unmask(struct irq_data *data) { struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); struct sprd_pmic_eic *pmic_eic =3D gpiochip_get_data(chip); + irq_hw_number_t hwirq =3D irqd_to_hwirq(data); + + gpiochip_enable_irq(chip, hwirq); =20 pmic_eic->reg[REG_IE] =3D 1; pmic_eic->reg[REG_TRIG] =3D 1; @@ -292,6 +296,17 @@ static irqreturn_t sprd_pmic_eic_irq_handler(int irq, = void *data) return IRQ_HANDLED; } =20 +static const struct irq_chip pmic_eic_irq_chip =3D { + .name =3D "sprd-pmic-eic-gpio", + .irq_mask =3D sprd_pmic_eic_irq_mask, + .irq_unmask =3D sprd_pmic_eic_irq_unmask, + .irq_set_type =3D sprd_pmic_eic_irq_set_type, + .irq_bus_lock =3D sprd_pmic_eic_bus_lock, + .irq_bus_sync_unlock =3D sprd_pmic_eic_bus_sync_unlock, + .flags =3D IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int sprd_pmic_eic_probe(struct platform_device *pdev) { struct gpio_irq_chip *irq; @@ -338,16 +353,8 @@ static int sprd_pmic_eic_probe(struct platform_device = *pdev) pmic_eic->chip.set =3D sprd_pmic_eic_set; pmic_eic->chip.get =3D sprd_pmic_eic_get; =20 - pmic_eic->intc.name =3D dev_name(&pdev->dev); - pmic_eic->intc.irq_mask =3D sprd_pmic_eic_irq_mask; - pmic_eic->intc.irq_unmask =3D sprd_pmic_eic_irq_unmask; - pmic_eic->intc.irq_set_type =3D sprd_pmic_eic_irq_set_type; - pmic_eic->intc.irq_bus_lock =3D sprd_pmic_eic_bus_lock; - pmic_eic->intc.irq_bus_sync_unlock =3D sprd_pmic_eic_bus_sync_unlock; - pmic_eic->intc.flags =3D IRQCHIP_SKIP_SET_WAKE; - irq =3D &pmic_eic->chip.irq; - irq->chip =3D &pmic_eic->intc; + gpio_irq_chip_set_chip(irq, &pmic_eic_irq_chip); irq->threaded =3D true; =20 ret =3D devm_gpiochip_add_data(&pdev->dev, &pmic_eic->chip, pmic_eic); --=20 2.34.1 From nobody Wed Sep 17 10:04:55 2025 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 F0CC8C4332F for ; Tue, 20 Dec 2022 13:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233725AbiLTNZR (ORCPT ); Tue, 20 Dec 2022 08:25:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbiLTNYn (ORCPT ); Tue, 20 Dec 2022 08:24:43 -0500 Received: from out-75.mta0.migadu.com (out-75.mta0.migadu.com [91.218.175.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E18631A3B6 for ; Tue, 20 Dec 2022 05:24:39 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1671542676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5jk//G82XoL09MdS2UpCztzol1TvVIpJTF0T1a5iUsA=; b=VNG68UwF28BevfhLvQx2lMbX6+djqfTVhe+/Sw8paS2LAl/4PDuT/S6buJZAVPe22JXukj l31oQjNSqJqNcA+y62hTxFoYIf7BUT417DX8sYYR5uBMsFvBvgz3fu2GVR/tEC8wWvPbRv 8gOvqXxm5RZCCGNWenwsfgemmjct0Dw= From: Cixi Geng To: linus.walleij@linaro.org, brgl@bgdev.pl, orsonzhai@gmail.com, baolin.wang@linux.alibaba.com, zhang.lyra@gmail.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 3/3] gpio: gpio-sprd: Make the irqchip immutable Date: Tue, 20 Dec 2022 21:23:41 +0800 Message-Id: <20221220132341.19383-4-cixi.geng@linux.dev> In-Reply-To: <20221220132341.19383-1-cixi.geng@linux.dev> References: <20221220132341.19383-1-cixi.geng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Cixi Geng Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE, add the new helper functions, and call the appropriate gpiolib functions. Signed-off-by: Cixi Geng --- drivers/gpio/gpio-sprd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-sprd.c b/drivers/gpio/gpio-sprd.c index 9bff63990eee..e6e48606a302 100644 --- a/drivers/gpio/gpio-sprd.c +++ b/drivers/gpio/gpio-sprd.c @@ -120,6 +120,7 @@ static void sprd_gpio_irq_mask(struct irq_data *data) u32 offset =3D irqd_to_hwirq(data); =20 sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 0); + gpiochip_disable_irq(chip, offset); } =20 static void sprd_gpio_irq_ack(struct irq_data *data) @@ -136,6 +137,7 @@ static void sprd_gpio_irq_unmask(struct irq_data *data) u32 offset =3D irqd_to_hwirq(data); =20 sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 1); + gpiochip_enable_irq(chip, offset); } =20 static int sprd_gpio_irq_set_type(struct irq_data *data, @@ -205,13 +207,15 @@ static void sprd_gpio_irq_handler(struct irq_desc *de= sc) chained_irq_exit(ic, desc); } =20 -static struct irq_chip sprd_gpio_irqchip =3D { +static const struct irq_chip sprd_gpio_irqchip =3D { .name =3D "sprd-gpio", .irq_ack =3D sprd_gpio_irq_ack, .irq_mask =3D sprd_gpio_irq_mask, .irq_unmask =3D sprd_gpio_irq_unmask, .irq_set_type =3D sprd_gpio_irq_set_type, .flags =3D IRQCHIP_SKIP_SET_WAKE, + .flags =3D IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; =20 static int sprd_gpio_probe(struct platform_device *pdev) @@ -245,7 +249,7 @@ static int sprd_gpio_probe(struct platform_device *pdev) sprd_gpio->chip.direction_output =3D sprd_gpio_direction_output; =20 irq =3D &sprd_gpio->chip.irq; - irq->chip =3D &sprd_gpio_irqchip; + gpio_irq_chip_set_chip(irq, &sprd_gpio_irqchip); irq->handler =3D handle_bad_irq; irq->default_type =3D IRQ_TYPE_NONE; irq->parent_handler =3D sprd_gpio_irq_handler; --=20 2.34.1