From patchwork Mon Mar 20 09:55: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: 72061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1124541wrt; Mon, 20 Mar 2023 03:06:17 -0700 (PDT) X-Google-Smtp-Source: AK7set8VbDmlIW32dyN+BVLyWEy0kiwdSdDbABQMelDSEUnZ+gCT1LkCXxD/9PDnv6syZCi0Fnh4 X-Received: by 2002:aa7:9f5b:0:b0:627:6328:79f1 with SMTP id h27-20020aa79f5b000000b00627632879f1mr7453396pfr.34.1679306777160; Mon, 20 Mar 2023 03:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679306777; cv=none; d=google.com; s=arc-20160816; b=jzUK+rTqYgLaVs6G6QJnzjqLrb0X+6CYdXLrwfTEayCcIO0DB2CNxLq/yl/qu7wqEg FWVYdBgL9mNCMjcc/CKatoU7agaFhiRU1QCSo6lp8E75FX1FqE+gNf+OPObQX7Md4PFx 1Qqi+Il5dzwzOwauQBCfIHU3Ess3xSjyaS6TT2E+8PAFQyS0pBo8UF1++5oZXCmBx2BG cENRgNDiLZWSH919HXmGg9y+qDy0aTau8p7J5/S35r4EsSPK28/VhGtaGdv7v5iC5r7a glYfU8LgT9DzsI4cN3SX1UrL3JQPFNxhLJWmGh54UhuR1PKILeG6j6mEWtd+3zoB1CBt jlIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=HAnQzgricg8Usxd+K390Bg6GFFRXEBuJfLaA0TdP+hw=; b=QvgJiDqarWYD05lV+qq+PRzPVzhtaiL5XN031gMlPXwZUw6uyYnBq1gB6hIg6YO9UY 0thcRw81JQAdcUFDm/FD/JCZtHuvsZ86Q5muZM9BiqMj86xCeOA2BvEDFaUk54GaGrP3 qixRucQvUTeChCbZ+Mrxgqj84AxtLB+XDDMWAWhYRoX7puFrbSy/h0R6X+gaCcs4rDzP Bfpkq6QszuRKO5Q6PiraE7vwjNlQMpFEDTsd4DwnN9oDKMi3I3MQaV+NmgvT9dcQoji9 U4llz/HK8oiTX8ZlPbf++UFxgCFlDBwgQrXv12cWqwGj+mCRFL2wp2+/ZMsoxOL44vDn Reaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lq7l5aeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a630f5d000000b0050bf0c6b2f4si9569622pgp.379.2023.03.20.03.06.00; Mon, 20 Mar 2023 03:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lq7l5aeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbjCTJza (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbjCTJzT (ORCPT ); Mon, 20 Mar 2023 05:55:19 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 032881EBF8 for ; Mon, 20 Mar 2023 02:55:17 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id g17so14142300lfv.4 for ; Mon, 20 Mar 2023 02:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306115; 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=HAnQzgricg8Usxd+K390Bg6GFFRXEBuJfLaA0TdP+hw=; b=Lq7l5aeg8t6BBYbxGtC4sNU5S8fQuBBWobHnJIxj686s6RIddNS7y5zLxX+6jjMGVJ q8Np1dVHSXaDhxJexJ3Cja6w9ffPRDiUNb2OCSJjWDBk8iPYyzUx4mqlgiuxNGhbPTtW YgefU03E4fhoSdZAaNiHoKR5mnYkWlR3BKHnfv3+iy5d0VlNKlNoq94/wG1YS0LQJFvI iP3GQHkCA7ZHxNmQTsiY5N6CqU1lk5gzClIkEC/3IZNMZqhHeiQbRLgZrW+nHe80Qnak xmkD+VTW2eLGoVWT+mSMA5tyo3H4ysglh5BTU+FVTbIGQvvg5T111RiXWhyQ6HalDpq2 BhvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306115; 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=HAnQzgricg8Usxd+K390Bg6GFFRXEBuJfLaA0TdP+hw=; b=xXhiQu/TnmPwbdj4PGW33jyvJ2dXc4a1uvRTAPA9BJpAt65K4eQCzVzQ5dMScsnxDj 53L0JcwSaaN+Lw2kxeShcSl11YgCLCI4Jg+3T97zOZfEOtVRT0daSWP1lzh7XCspucBz V9wu0NaspFMYJ5wOTaO2blx9rv6qvi0V4SaMH1D+N4dAh6M2+LJ+s1x7viESfqco6dsD iy2SgEWOBQ1Arh1jjRvLdCg7m3t/Lmc7octUzqiy5tNc8/LH+8/CLLqP/QmN7s+bu8+5 5vduyAYMwBJ4fyZavdkR/l6x5EOjEMKRYjkrO8odZMRqCpMgtvWn/pLiPLtN6hQ62ux1 4bcQ== X-Gm-Message-State: AO0yUKX341Skw2LRBJUVdtcIvW01MB7LOmY1MZomOveL2K7kwU4ffqbF vcXinUbo7axa2XYxHJAit5lJkQ== X-Received: by 2002:ac2:44ab:0:b0:4de:d16f:3938 with SMTP id c11-20020ac244ab000000b004ded16f3938mr7279084lfm.53.1679306115099; Mon, 20 Mar 2023 02:55:15 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.219]) by smtp.gmail.com with ESMTPSA id c3-20020ac244a3000000b004e792045b3dsm1640104lfm.106.2023.03.20.02.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:14 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:08 +0100 Subject: [PATCH 1/9] gpio: rda: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-1-053d6ede831b@linaro.org> References: <20230316-immutable-chips-2-v1-0-053d6ede831b@linaro.org> In-Reply-To: <20230316-immutable-chips-2-v1-0-053d6ede831b@linaro.org> To: linux-gpio@vger.kernel.org, Bartosz Golaszewski , Manivannan Sadhasivam , Thorsten Scherer , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Pengutronix Kernel Team , Maxime Coquelin , Alexandre Torgue , Robert Richter , Nobuhiro Iwamatsu , Ray Jui , Scott Branden , Broadcom internal kernel review list , Shubhrajyoti Datta , Srinivas Neeli , Michal Simek Cc: linux-arm-kernel@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linus Walleij , Marc Zyngier X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760880783470875467?= X-GMAIL-MSGID: =?utf-8?q?1760880783470875467?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij Acked-by: Manivannan Sadhasivam --- drivers/gpio/gpio-rda.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c index 62ba18b3a602..dd568907d389 100644 --- a/drivers/gpio/gpio-rda.c +++ b/drivers/gpio/gpio-rda.c @@ -38,7 +38,6 @@ struct rda_gpio { struct gpio_chip chip; void __iomem *base; spinlock_t lock; - struct irq_chip irq_chip; int irq; }; @@ -74,6 +73,7 @@ static void rda_gpio_irq_mask(struct irq_data *data) value |= BIT(offset) << RDA_GPIO_IRQ_FALL_SHIFT; writel_relaxed(value, base + RDA_GPIO_INT_CTRL_CLR); + gpiochip_disable_irq(chip, offset); } static void rda_gpio_irq_ack(struct irq_data *data) @@ -154,6 +154,7 @@ static void rda_gpio_irq_unmask(struct irq_data *data) u32 offset = irqd_to_hwirq(data); u32 trigger = irqd_get_trigger_type(data); + gpiochip_enable_irq(chip, offset); rda_gpio_set_irq(chip, offset, trigger); } @@ -195,6 +196,16 @@ static void rda_gpio_irq_handler(struct irq_desc *desc) chained_irq_exit(ic, desc); } +static const struct irq_chip rda_gpio_irq_chip = { + .name = "rda-gpio", + .irq_ack = rda_gpio_irq_ack, + .irq_mask = rda_gpio_irq_mask, + .irq_unmask = rda_gpio_irq_unmask, + .irq_set_type = rda_gpio_irq_set_type, + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int rda_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -241,15 +252,8 @@ static int rda_gpio_probe(struct platform_device *pdev) rda_gpio->chip.base = -1; if (rda_gpio->irq >= 0) { - rda_gpio->irq_chip.name = "rda-gpio", - rda_gpio->irq_chip.irq_ack = rda_gpio_irq_ack, - rda_gpio->irq_chip.irq_mask = rda_gpio_irq_mask, - rda_gpio->irq_chip.irq_unmask = rda_gpio_irq_unmask, - rda_gpio->irq_chip.irq_set_type = rda_gpio_irq_set_type, - rda_gpio->irq_chip.flags = IRQCHIP_SKIP_SET_WAKE, - girq = &rda_gpio->chip.irq; - girq->chip = &rda_gpio->irq_chip; + gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip); girq->handler = handle_bad_irq; girq->default_type = IRQ_TYPE_NONE; girq->parent_handler = rda_gpio_irq_handler;