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; From patchwork Mon Mar 20 09:55: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: 72074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1132744wrt; Mon, 20 Mar 2023 03:26:41 -0700 (PDT) X-Google-Smtp-Source: AK7set9LA2WeU2bb7lSlw+dJ74L0yD1rbO4oNEA/RpvidZVkGS8bwf9Z8eS2JH1YHuOr+zkYCDiD X-Received: by 2002:a17:903:280f:b0:1a1:b656:2149 with SMTP id kp15-20020a170903280f00b001a1b6562149mr7125108plb.50.1679308001417; Mon, 20 Mar 2023 03:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679308001; cv=none; d=google.com; s=arc-20160816; b=Bu5UnMQO5Hex9Ie81x2sLcqitNB/Aj0iU2/vzXe+oAazlSJfFu5TjY6BEpkuYDmUZO fWr8n+TthwKnOFQn1N5qmhhPzva88YxmX4h/xlKOtuxaG29IWEdu2fyP56J8YNz40z3c +Kj8BkIGtTbdQFp5XZsutc7HR6R5swot4kxfWo+6QLfz7x1sULaLrx/Jq3QCZWfZKNxm EQAm/l4lRhiLA4Bbitlz3oAuiXXeqs/0ikaMEfZK31o8GRLMIZ26QsUcF9tisdTkPTPF aqbswZgmQNZUetH9BFzSCRGtRygyrVH1k7DMLpGD0pWFt4ETEFT48dSUT+PRsScGbvIv rU9w== 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=sWq14yt3BM/27dxCw3WEXlHO0Q3kdzBlpwclk4xm8Qw=; b=02BvNSxVthKhm1mWjmni8AnaR1oSJ0OfpKt/VoQnenPOcrmF0leC3qNJ8644E9Kkyq PZfL84E16B6r+LGnmG8EZ3Sir12AsZ4YPGjRVCQpJSFWBgOPvqOfQ3KCU3LBdbDp6Gu/ L/aN9O5Aep3uieGSU/1z18jrOHC2tyLrfXOiYKvsH05h7BLeeD7Y+/qtEt2+aVNkTGH/ 4M77ba/nldYpitKxysrxZ0OOr+TSig06FQrir7FXVOjYtgSA3DH4VUyOd6bggvSfmW6N E+Jkh8dW+I9OLFPX2H7Kb+T9gGCQWPf2hX9yiRW2lAPPfh1Uox1AjGPfZfWkSZCUwqPr yLFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AvmgwK5r; 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 d11-20020a170902b70b00b0019acd30dc69si9484190pls.115.2023.03.20.03.26.26; Mon, 20 Mar 2023 03:26:41 -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=AvmgwK5r; 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 S230327AbjCTJzl (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjCTJzX (ORCPT ); Mon, 20 Mar 2023 05:55:23 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C0E1ADCC for ; Mon, 20 Mar 2023 02:55:17 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id f18so14138085lfa.3 for ; Mon, 20 Mar 2023 02:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306116; 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=sWq14yt3BM/27dxCw3WEXlHO0Q3kdzBlpwclk4xm8Qw=; b=AvmgwK5rhJ0aNG1XjY08pQJKKVLHdXA/4v5bKJS7/IdtwJAIMbgJLhAcrcecABl/Wg v+mDTWY2Kbr3UrNZAVREs3kw9LoKSInoux97YMBtE+ZjiMEJDiSz39VMK4LrI2Dfei+u 0qH3wbJ23WHOyCqtNtNq1eJ3I31hv8Tlr8c11N1GpCStIuNuVZoLmRaxF7tPuQ09ye4/ 4q4dlq43UBB+72o9bw/Gtf7hTatbE60UF7ka9EyTkSd4ocOnJs3g0d3DLYIibi2p1v9u 3gh1IBhLsCS+9S6uOvyQ0ciGJYTaQW+o/XxjF7qSMPXaPC15GcWOI9FZzTNGeH1g3/KF Q2Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306116; 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=sWq14yt3BM/27dxCw3WEXlHO0Q3kdzBlpwclk4xm8Qw=; b=MhIMFI12Bb7QH8pJUQz+7iEeiAU4Jb3BTGZZ67kvsfIFD9zZI02Vr17f57sTNKy7wN GDHqWsVLUIZibwLd7JL8e6uqWw+n0uEYLvET8X6Z2etyBbEAmQDndphwSPF84lBF9Q3e oIXSqU5ZM1ArGMe4NNpJ5g+qnc7Rek0Ddy407dqHSwxh84BuoXYUpAkIzchFqvAcp6lS 11biOJZGd2KOTV+DDeFsHT1R/8QBSrLN92OLdncsgZOXtDSEj48Ubbz6UruQkkWciIOh JP6SqoAXAoGUkPLXTwl5qo2+JUTN3/vVS/BUxJTjUPX57ZYcrb9l4xz8fIMaLIP4NGxz qbBg== X-Gm-Message-State: AO0yUKWvpxN42SCZHhAVunLkQuk/PKMTk8jvvyiW2mkmE5K3AegSKgyc J+pOAoD3327lX3SQ54Y0zGNi3A== X-Received: by 2002:ac2:44a6:0:b0:4dd:9b6b:6b5b with SMTP id c6-20020ac244a6000000b004dd9b6b6b5bmr6239022lfm.16.1679306116142; Mon, 20 Mar 2023 02:55:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:15 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:09 +0100 Subject: [PATCH 2/9] gpio: siox: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-2-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?1760882067199387772?= X-GMAIL-MSGID: =?utf-8?q?1760882067199387772?= Convert the driver to immutable irq-chip with a bit of intuition. In this case I had to figure out a way to get to the struct gpio_chip that would work even when the irq_chip is not part of the driver state container. I did this by just doing what most other GPIO drivers do and pass the state struct as data to devm_gpiochip_add_data() and rewrite accordingly. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-siox.c | 75 ++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c index f8c5e9fc4bac..051bc99bdfb2 100644 --- a/drivers/gpio/gpio-siox.c +++ b/drivers/gpio/gpio-siox.c @@ -10,7 +10,6 @@ struct gpio_siox_ddata { struct gpio_chip gchip; - struct irq_chip ichip; struct mutex lock; u8 setdata[1]; u8 getdata[3]; @@ -97,9 +96,8 @@ static int gpio_siox_get_data(struct siox_device *sdevice, const u8 buf[]) static void gpio_siox_irq_ack(struct irq_data *d) { - struct irq_chip *ic = irq_data_get_irq_chip(d); - struct gpio_siox_ddata *ddata = - container_of(ic, struct gpio_siox_ddata, ichip); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); raw_spin_lock(&ddata->irqlock); ddata->irq_status &= ~(1 << d->hwirq); @@ -108,21 +106,21 @@ static void gpio_siox_irq_ack(struct irq_data *d) static void gpio_siox_irq_mask(struct irq_data *d) { - struct irq_chip *ic = irq_data_get_irq_chip(d); - struct gpio_siox_ddata *ddata = - container_of(ic, struct gpio_siox_ddata, ichip); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); raw_spin_lock(&ddata->irqlock); ddata->irq_enable &= ~(1 << d->hwirq); raw_spin_unlock(&ddata->irqlock); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } static void gpio_siox_irq_unmask(struct irq_data *d) { - struct irq_chip *ic = irq_data_get_irq_chip(d); - struct gpio_siox_ddata *ddata = - container_of(ic, struct gpio_siox_ddata, ichip); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); raw_spin_lock(&ddata->irqlock); ddata->irq_enable |= 1 << d->hwirq; raw_spin_unlock(&ddata->irqlock); @@ -130,9 +128,8 @@ static void gpio_siox_irq_unmask(struct irq_data *d) static int gpio_siox_irq_set_type(struct irq_data *d, u32 type) { - struct irq_chip *ic = irq_data_get_irq_chip(d); - struct gpio_siox_ddata *ddata = - container_of(ic, struct gpio_siox_ddata, ichip); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); raw_spin_lock(&ddata->irqlock); ddata->irq_type[d->hwirq] = type; @@ -143,8 +140,7 @@ static int gpio_siox_irq_set_type(struct irq_data *d, u32 type) static int gpio_siox_get(struct gpio_chip *chip, unsigned int offset) { - struct gpio_siox_ddata *ddata = - container_of(chip, struct gpio_siox_ddata, gchip); + struct gpio_siox_ddata *ddata = gpiochip_get_data(chip); int ret; mutex_lock(&ddata->lock); @@ -167,8 +163,7 @@ static int gpio_siox_get(struct gpio_chip *chip, unsigned int offset) static void gpio_siox_set(struct gpio_chip *chip, unsigned int offset, int value) { - struct gpio_siox_ddata *ddata = - container_of(chip, struct gpio_siox_ddata, gchip); + struct gpio_siox_ddata *ddata = gpiochip_get_data(chip); u8 mask = 1 << (19 - offset); mutex_lock(&ddata->lock); @@ -208,11 +203,22 @@ static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset) return GPIO_LINE_DIRECTION_OUT; } +static const struct irq_chip gpio_siox_irq_chip = { + .name = "siox-gpio", + .irq_ack = gpio_siox_irq_ack, + .irq_mask = gpio_siox_irq_mask, + .irq_unmask = gpio_siox_irq_unmask, + .irq_set_type = gpio_siox_irq_set_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int gpio_siox_probe(struct siox_device *sdevice) { struct gpio_siox_ddata *ddata; struct gpio_irq_chip *girq; struct device *dev = &sdevice->dev; + struct gpio_chip *gc; int ret; ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); @@ -224,30 +230,25 @@ static int gpio_siox_probe(struct siox_device *sdevice) mutex_init(&ddata->lock); raw_spin_lock_init(&ddata->irqlock); - ddata->gchip.base = -1; - ddata->gchip.can_sleep = 1; - ddata->gchip.parent = dev; - ddata->gchip.owner = THIS_MODULE; - ddata->gchip.get = gpio_siox_get; - ddata->gchip.set = gpio_siox_set; - ddata->gchip.direction_input = gpio_siox_direction_input; - ddata->gchip.direction_output = gpio_siox_direction_output; - ddata->gchip.get_direction = gpio_siox_get_direction; - ddata->gchip.ngpio = 20; - - ddata->ichip.name = "siox-gpio"; - ddata->ichip.irq_ack = gpio_siox_irq_ack; - ddata->ichip.irq_mask = gpio_siox_irq_mask; - ddata->ichip.irq_unmask = gpio_siox_irq_unmask; - ddata->ichip.irq_set_type = gpio_siox_irq_set_type; - - girq = &ddata->gchip.irq; - girq->chip = &ddata->ichip; + gc = &ddata->gchip; + gc->base = -1; + gc->can_sleep = 1; + gc->parent = dev; + gc->owner = THIS_MODULE; + gc->get = gpio_siox_get; + gc->set = gpio_siox_set; + gc->direction_input = gpio_siox_direction_input; + gc->direction_output = gpio_siox_direction_output; + gc->get_direction = gpio_siox_get_direction; + gc->ngpio = 20; + + girq = &gc->irq; + gpio_irq_chip_set_chip(girq, &gpio_siox_irq_chip); girq->default_type = IRQ_TYPE_NONE; girq->handler = handle_level_irq; girq->threaded = true; - ret = devm_gpiochip_add_data(dev, &ddata->gchip, NULL); + ret = devm_gpiochip_add_data(dev, gc, ddata); if (ret) dev_err(dev, "Failed to register gpio chip (%d)\n", ret); From patchwork Mon Mar 20 09:55: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: 72055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1121494wrt; Mon, 20 Mar 2023 03:00:42 -0700 (PDT) X-Google-Smtp-Source: AK7set+E1K5KGXy9e8yM8QVcJFtn7xFGtNNEhK/C5ZdAgYmIvcXzpte8Op1t8Jsgdbque3Dehh0q X-Received: by 2002:a05:6a20:489:b0:d3:84ca:11b with SMTP id 9-20020a056a20048900b000d384ca011bmr14410335pzc.40.1679306441957; Mon, 20 Mar 2023 03:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679306441; cv=none; d=google.com; s=arc-20160816; b=nYxlF9NZp+fhqDAVwh6MyFwAe3jC5qJHxaCw9rSJVzXXfF862Y4orKHxUrJK4FpEAc DvU/CHX6h1h+/JAgrRGEDnFq13MCblDVnC0qi3WREiM1xwQ0Eu0eHzBuEsCTOwyOfrqF j9ENsawgROS4UZ19y6sfMiDx7a/x4jPn+7LQqEst/pYkiccnYjf5sbWKZUHI0y8x6rWr fIr8UgWK1mltX5FFqx5DVOW9oBD9xVIXOwVIrp6RC0WJdpEQO3Lqe/dNMfUop2S0DOWc 88QC0NpOnXMiHOLogfsBA4kQWGAcFqtqXsTiUQa5BekSf2gcTMYDFJ9lcuvPSdMjjfBX +RYg== 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=iBy8uglh8gI3CtA/oUcnRDs25I4dMI2aaLdEiGdH3E4=; b=Iz+I/XyMKCp4x/vWBWFi55ojjOtpn8Kx7q2IrkcqyevBKYfmr6MeOL0dA1YNob6qGf RiAfshyFY7lFt76uKp9QZq5kUS0fzsCCz5Ucz/aI8nQjITf83/2rj/vNKhXrOgwVLgqu qNIkYORNA7frtUJU8jlFlPKdYNZHsxMK9no77azZQBLgInTZ9Rxfz16nvsUdan+iskCL sxmADhSAAedej2NQfrYMyYpPndlYhiEBHxdZhGsz/i85/yy0P12AbMgyEkG3j4vqjjce hehnta5Qj9HKCZnhP0sS0+TBG9tXqVhlxDoQQ52iwP3TDd8SvoadFtEZBBMjjntcRGRV l6Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJSWksEl; 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 r190-20020a632bc7000000b0050bdfe2d47esi9939317pgr.51.2023.03.20.03.00.29; Mon, 20 Mar 2023 03:00:41 -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=VJSWksEl; 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 S230083AbjCTJzf (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjCTJzX (ORCPT ); Mon, 20 Mar 2023 05:55:23 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2103902E for ; Mon, 20 Mar 2023 02:55:18 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id x17so14132761lfu.5 for ; Mon, 20 Mar 2023 02:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306117; 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=iBy8uglh8gI3CtA/oUcnRDs25I4dMI2aaLdEiGdH3E4=; b=VJSWksEl6WxkHvKzPymzEi6mf3ZUeAsMB9WkGKvRi4yYReG0Nz/6sBKaHTNxqci5JY nqhyqfT+O4UI8OcnALy74NJgtnZkDTgmzaryyCzE18tQHFKDZaX/vCyj9bmzq4MQwEqm 7JspHuKpDSc9if5ybl5cxPLcd/u09a8lpVxbPNjMNhC1EVybYUH2BndXo7a2u+IJ12Tg Q1W984RSdg1rOcpmKqad1UkvNu2z1qqFc0ZJCIlsvJj3EI3CeUk2I4EBv1NfTJt/teZh kfeqyDjdd2/ny+QZeNEIVEdYu9QSsg+sQxIsHwHcN+SGVLdMwzvc1TikYc5i4lF/FyMo KnPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306117; 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=iBy8uglh8gI3CtA/oUcnRDs25I4dMI2aaLdEiGdH3E4=; b=NTQPh6YyNDWMfSl+/t9UgiErwrA/rfk3D0CHnHblbg/4npFMmwibqUIATaJOj3Ybas D7Ml3GZ3Oew82h60SCksc388t/1UO/fRwmMYb8Htnm5bpSKHaI8YabCMN6SXlTEjx4k+ iEDkm7TtRD14yfMQU6T7TH4sTBDSRmcP8/eIZddeFNLoJhOdiyeexpUqyKSAAuOrfSPi k2JIbIR7uT9e32zcvde6FddLcERpRV9z1rnUMqFuc8up5S/DbtHZQxMhkS2Bm+e0ojfN 1s6GcfMrfnt9O960xglEX+QxHsZNhrG/ETahJbbfbbchlbcWONOW/0+uYC1d/fXGWt3F zYfA== X-Gm-Message-State: AO0yUKVl3KJyCG7CuL67vsP80Ptsn7hHH6JhpVDZeZI/0RHXJVCG70jy A0T87rM3i7bWLoTCrgAT5I8HoQ== X-Received: by 2002:a19:ee14:0:b0:4e9:ccff:daa6 with SMTP id g20-20020a19ee14000000b004e9ccffdaa6mr939758lfb.30.1679306117176; Mon, 20 Mar 2023 02:55:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:16 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:10 +0100 Subject: [PATCH 3/9] gpio: stmpe: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-3-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?1760880431544723979?= X-GMAIL-MSGID: =?utf-8?q?1760880431544723979?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-stmpe.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index 0fa4f0a93378..27cc4da53565 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -234,6 +234,7 @@ static void stmpe_gpio_irq_mask(struct irq_data *d) int mask = BIT(offset % 8); stmpe_gpio->regs[REG_IE][regoffset] &= ~mask; + gpiochip_disable_irq(gc, offset); } static void stmpe_gpio_irq_unmask(struct irq_data *d) @@ -244,6 +245,7 @@ static void stmpe_gpio_irq_unmask(struct irq_data *d) int regoffset = offset / 8; int mask = BIT(offset % 8); + gpiochip_enable_irq(gc, offset); stmpe_gpio->regs[REG_IE][regoffset] |= mask; } @@ -357,13 +359,15 @@ static void stmpe_dbg_show(struct seq_file *s, struct gpio_chip *gc) } } -static struct irq_chip stmpe_gpio_irq_chip = { +static const struct irq_chip stmpe_gpio_irq_chip = { .name = "stmpe-gpio", .irq_bus_lock = stmpe_gpio_irq_lock, .irq_bus_sync_unlock = stmpe_gpio_irq_sync_unlock, .irq_mask = stmpe_gpio_irq_mask, .irq_unmask = stmpe_gpio_irq_unmask, .irq_set_type = stmpe_gpio_irq_set_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; #define MAX_GPIOS 24 @@ -511,7 +515,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) } girq = &stmpe_gpio->chip.irq; - girq->chip = &stmpe_gpio_irq_chip; + gpio_irq_chip_set_chip(girq, &stmpe_gpio_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; From patchwork Mon Mar 20 09:55: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: 72070 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1131052wrt; Mon, 20 Mar 2023 03:22:12 -0700 (PDT) X-Google-Smtp-Source: AK7set8CxqTg9Ik1V8y4rmMckOhtq2OCp0KLxr/bESOX4cYcnJnvIWmpP7RhHqToE7mnXRQ5oxyv X-Received: by 2002:a17:902:e495:b0:194:cc66:66f7 with SMTP id i21-20020a170902e49500b00194cc6666f7mr12991960ple.19.1679307732049; Mon, 20 Mar 2023 03:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679307732; cv=none; d=google.com; s=arc-20160816; b=GzcdAUw6wkETK81wTDjfpb2Ry3S/HQTyiEqbJd2CDNR/q5XfqQLGL/nlIngSKOpt6r vJIZlMufC3QbngcJF5jSNhzjl32aj9Z0qxooQzi3P03lquJUSL2pjKvRf1zl46uOulJN +MebXNxwZSr19nt+4mdZktw0j2FQiOEEql1FsbN/ifEXy2jAS3rN9ke/BglHWdNGKsWs 7crHOwohFaCCvfSYg4w9/3mSzTthPnRSpsprU/7kEUpaLDRSUEeIJrCmV6T0ul31aLiv wQF4suUmcY5MKv0/mJXlhM8SWIfvVmr7iKzFaHg6GBrF2dmgmeFWZxboF6s7SE57t7ho ev7w== 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=eNbwpBrcxQyOJmFGB8QKYSUw0GcL4gHVq06YlQk9V4w=; b=0GmmFVo6mANPGirqQqi3qulpXFLmD4ruaMA5OvJL2ibBJzmXO1EaVL+b2OVdJZXUC9 nF01lo0DbnrDP3qES+vshjjlyYKo/8Io+yAHGFuSHKFj3IdnXZavldjnL+T78JKKW+e0 qzbLdL40lf37EBIu0Kl6DPvMtRazZeAnpDPJsBiQ1Bu/kc7OXG4w7IpwOAAKWtZVeFyH LSXLXW8QQuAoLkvwM+ee4kqdIYGj714rBZylWmiWk2rnitfWrdJ2YzS8jhM+j24S/0VI QkiciyrOCXdv1r/BOSQUuQSw+130L1eGl/l4Lj+gygOpQnVaUpHkUmcUMzjj/GEL2jhE 4AEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=odNzulw4; 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 d11-20020a170902b70b00b0019acd30dc69si9484190pls.115.2023.03.20.03.21.56; Mon, 20 Mar 2023 03:22:11 -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=odNzulw4; 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 S229572AbjCTJzp (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbjCTJzZ (ORCPT ); Mon, 20 Mar 2023 05:55:25 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E371F5DD for ; Mon, 20 Mar 2023 02:55:19 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id x36so11429501ljq.7 for ; Mon, 20 Mar 2023 02:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306118; 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=eNbwpBrcxQyOJmFGB8QKYSUw0GcL4gHVq06YlQk9V4w=; b=odNzulw4pjVtLmYnmgubXKQe/ANfNF2OKvSlxkJ9K6L1U4dnK0JiNIUSeR8Kp8p1M6 JRt4CtRCRZqu3tKU7aYmGCRu4ikbscZP1XUsDiD2DC1vTGR/pwWx15QJCQxkGos/DNlX +rMyAEbBulqnjMe6QLGGUbfv4QbiI9knU7AqXZQbWno2KRYKcSJ3/c31+XDMnyDGo/j/ yxw2399oTI3QBwlqBJ/NLaC3h573x+XRYqBB4yof6B9oQ81hw0Vdtaca6L1zWBN2WXlz mbg9tBYRuFoBhn5MPkc6bAKoKRZ4ok7gPED6tHe0YEtpo2xIWVn4k82NHW3uLUy3f5IJ 2/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306118; 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=eNbwpBrcxQyOJmFGB8QKYSUw0GcL4gHVq06YlQk9V4w=; b=VmE0JLEBb90GXI8cMSnUBWJFeKTmQAzxOCtepppYDQAK7SRmM03h2lZm/WWiUQyy2Y rou08ymwSRDBQPEG4L/Q7lxwCES4RcszqIVI9VaLg6dKCMy1pQPtaoEPUOad0R9qoyz/ sdyKI9GEDWCoIpYjMn2UdAMVJwAWGY+futMdR7I2LvWKbbA+bevW8nOmsAx7EQIpJCuu 7+O+/XdBGgvloZtA3T0dxO4xdEszokn6aCOAJQGTrs48GEXFveF/LYTcpHbpIMdxzqba U3OEvp3DY8hfXlecCin6VtF4JKIZfmtSroMpJ+EDGsdpBVBR3TFtt3e96Bs+OxaWtIxg extg== X-Gm-Message-State: AO0yUKXITAHBSHU4b9Nt25Be7BP0XrHhxHgDPhI9Swehnz4OH0RuZo3+ rISinnbxTpFBSO/DMGSs2TmdlQ== X-Received: by 2002:a2e:7006:0:b0:298:ade0:40bc with SMTP id l6-20020a2e7006000000b00298ade040bcmr5128524ljc.10.1679306118261; Mon, 20 Mar 2023 02:55:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:17 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:11 +0100 Subject: [PATCH 4/9] gpio: thunderx: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-4-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?1760881784471223544?= X-GMAIL-MSGID: =?utf-8?q?1760881784471223544?= Convert the driver to immutable irq-chip with a bit of intuition. Whereas in most cases we put the gpiochip_[enable|disable]_irq() calls in the .irq_mask() and .irq_unmask() callbacks, here we need to put them in the .irq_enable() and .irq_disable() callbacks, as this driver uses both .irq_mask() and .irq_mask_ack(). Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-thunderx.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index cc62c6e64103..8521c6aacace 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -354,16 +354,22 @@ static int thunderx_gpio_irq_set_type(struct irq_data *d, return IRQ_SET_MASK_OK; } -static void thunderx_gpio_irq_enable(struct irq_data *data) +static void thunderx_gpio_irq_enable(struct irq_data *d) { - irq_chip_enable_parent(data); - thunderx_gpio_irq_unmask(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); + irq_chip_enable_parent(d); + thunderx_gpio_irq_unmask(d); } -static void thunderx_gpio_irq_disable(struct irq_data *data) +static void thunderx_gpio_irq_disable(struct irq_data *d) { - thunderx_gpio_irq_mask(data); - irq_chip_disable_parent(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + thunderx_gpio_irq_mask(d); + irq_chip_disable_parent(d); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } /* @@ -372,7 +378,7 @@ static void thunderx_gpio_irq_disable(struct irq_data *data) * semantics and other acknowledgment tasks associated with the GPIO * mechanism. */ -static struct irq_chip thunderx_gpio_irq_chip = { +static const struct irq_chip thunderx_gpio_irq_chip = { .name = "GPIO", .irq_enable = thunderx_gpio_irq_enable, .irq_disable = thunderx_gpio_irq_disable, @@ -383,8 +389,8 @@ static struct irq_chip thunderx_gpio_irq_chip = { .irq_eoi = irq_chip_eoi_parent, .irq_set_affinity = irq_chip_set_affinity_parent, .irq_set_type = thunderx_gpio_irq_set_type, - - .flags = IRQCHIP_SET_TYPE_MASKED + .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static int thunderx_gpio_child_to_parent_hwirq(struct gpio_chip *gc, @@ -526,7 +532,7 @@ static int thunderx_gpio_probe(struct pci_dev *pdev, chip->set_multiple = thunderx_gpio_set_multiple; chip->set_config = thunderx_gpio_set_config; girq = &chip->irq; - girq->chip = &thunderx_gpio_irq_chip; + gpio_irq_chip_set_chip(girq, &thunderx_gpio_irq_chip); girq->fwnode = of_node_to_fwnode(dev->of_node); girq->parent_domain = irq_get_irq_data(txgpio->msix_entries[0].vector)->domain; From patchwork Mon Mar 20 09:55:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 72073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1132056wrt; Mon, 20 Mar 2023 03:24:48 -0700 (PDT) X-Google-Smtp-Source: AK7set8jG4zyHuPgkiX4dXRpYQlK4CaxNrCaEgHY3m04SDhTIEsjq/IR5BBfcnrmQqJ+GJm+Z4Jb X-Received: by 2002:aa7:9706:0:b0:627:eece:5ca5 with SMTP id a6-20020aa79706000000b00627eece5ca5mr5687682pfg.18.1679307888345; Mon, 20 Mar 2023 03:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679307888; cv=none; d=google.com; s=arc-20160816; b=c/ai2IMnbgYxDq7JiX7Tnnjz+awYPGnD7u+ICIpidl+cPJdiXG0gC23gne3KVY1Gkb 9YOaW4whgQZoUtbT3P1gYkyI1bb6cK9alvc9GlTGUFpUua51mQof7zqB9wAOk0CP21tb cRvcPbcJRCGwmkLcMyFB+4BYOknZpgEayWgX+WvQ8uVKSwKHdm90PX7UpYcsmtcOjY5T cbV/GI+BQwidh/7yaL6vaMz87h+lVi+2mGpzH2Mzrb1me84t2bEFkfcw4T4Sg7k3o7ae fw9mNTmRY6CRpRxkKVtK3vGdF/oJtNn/HfXzpB2B26HgjpemA1DkS3BgD8xl/DvSoMki AFDA== 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=EOglr4b8wCIZjowHrmCHalgLUTFsF3VGPj317uHaVFA=; b=yCcTbWDfES1Hk2NCBMPcqcwFQQ3903XbIAY1CzVQAwwQDCfYIdSuDqnrbVNjl0D+jL 5W5VBUPbrZTL7CcYTg6/T3FMRkpkBPvZ1YiHUd6Vy8LuJ5L67TI3y0BqqJwgxqTDjfnn glmglmF4dN8m7YzBe84ftvgUrOJ+6wj+u7U6hp85eTMDSghQa/YNFOEBalfmcODkI9h8 bniuBls8A4bP7UCpQJV/TJTCMpbkdHmpGeZxGb6cby3S5+pOaeXqjWxaXWD1rRLRnoOI qBB4SGhw6H444cg2M/5h11tlGgiSfRPA15Ta/FO4zhHJun/efQJUcTMlqu4qibx495Il y4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kJ56kO3M; 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 p33-20020a056a000a2100b00625d5128684si6438875pfh.26.2023.03.20.03.24.33; Mon, 20 Mar 2023 03:24:48 -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=kJ56kO3M; 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 S230047AbjCTJzt (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjCTJzY (ORCPT ); Mon, 20 Mar 2023 05:55:24 -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 00C358A4C for ; Mon, 20 Mar 2023 02:55:19 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id g17so14142501lfv.4 for ; Mon, 20 Mar 2023 02:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306119; 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=EOglr4b8wCIZjowHrmCHalgLUTFsF3VGPj317uHaVFA=; b=kJ56kO3MduhiDK5ybC0WL3qaOzThm6WPK8eMyB1OamVZiJfOcQk0xmXE/zSisFY0dB MppJxQ2gGiT09ZH487ElXsDAGrtQ/ogdwA2zLb0Xrf5q0OObLU48m9uZiBd5rmAoLz19 c87J3IwGn68t/c4poAw7ckPaJz82738fW0ktSIKaoEfp0jn+T05UpNTxbunOynb+fYHS 3pOHgEPRPuSq+G9TlA0LQSX0mKmEBwa7IIaeFArqxLcZtYTIWuNLH25t/aVdXOosDUVK DJlQYGwxDg16lZOq/vLKok6RDvSzlCo4SCMZSJUDvn/fvHwz+bQnbahCPa4VITowm5zF hSfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306119; 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=EOglr4b8wCIZjowHrmCHalgLUTFsF3VGPj317uHaVFA=; b=HfNI4w/FOp5hlhrNZ862NXPsHveSDA84TAlUAYG7WuU+U4C//feHqrPXaweBPFNRaU +KcIVOm/FoLf99REhMk9YGyULzYTHi+Jtgvq74eIWEMIt0AzPcgVy1RG+E9VwdhJQ+Tk iqGEoEzN2i/8vXfpoJIxjUdp8fMoet6H9kx676/nUCSXoY8oGLB7zVyBQMcCpjwZi+Bq tuHaRvgO8cqmOt/Z1MIL3n1o25Cu4KLRbYJOmySkqSMPRj3paAFLjNUrdu4sVxIIUjdL 3MGHMRrJ0Yz79Ct5Wxj9vrizm4HDaNpGAcDqtBr56GdgF/TWS2i6eRvAUiwwo59COx+C 700g== X-Gm-Message-State: AO0yUKXiSgJdSwip2xgJqFeMiemtJeS0IZBaS9DVhNWh1ZIY3AQn8wZ0 JOYaiEoObKXWh6sB6w13gYHtpg== X-Received: by 2002:ac2:46d4:0:b0:4e9:4d61:e750 with SMTP id p20-20020ac246d4000000b004e94d61e750mr4663273lfo.32.1679306119303; Mon, 20 Mar 2023 02:55:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:18 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:12 +0100 Subject: [PATCH 5/9] gpio: tqmx86: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-5-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?1760881948198367256?= X-GMAIL-MSGID: =?utf-8?q?1760881948198367256?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tqmx86.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c index e739dcea61b2..6f8bd1155db7 100644 --- a/drivers/gpio/gpio-tqmx86.c +++ b/drivers/gpio/gpio-tqmx86.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define TQMX86_NGPIO 8 @@ -34,7 +35,6 @@ struct tqmx86_gpio_data { struct gpio_chip chip; - struct irq_chip irq_chip; void __iomem *io_base; int irq; raw_spinlock_t spinlock; @@ -122,6 +122,7 @@ static void tqmx86_gpio_irq_mask(struct irq_data *data) gpiic &= ~mask; tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC); raw_spin_unlock_irqrestore(&gpio->spinlock, flags); + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data)); } static void tqmx86_gpio_irq_unmask(struct irq_data *data) @@ -134,6 +135,7 @@ static void tqmx86_gpio_irq_unmask(struct irq_data *data) mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS); + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data)); raw_spin_lock_irqsave(&gpio->spinlock, flags); gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC); gpiic &= ~mask; @@ -226,6 +228,22 @@ static void tqmx86_init_irq_valid_mask(struct gpio_chip *chip, clear_bit(3, valid_mask); } +static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + seq_printf(p, gc->label); +} + +static const struct irq_chip tqmx86_gpio_irq_chip = { + .irq_mask = tqmx86_gpio_irq_mask, + .irq_unmask = tqmx86_gpio_irq_unmask, + .irq_set_type = tqmx86_gpio_irq_set_type, + .irq_print_chip = tqmx86_gpio_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int tqmx86_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -277,14 +295,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); if (irq > 0) { - struct irq_chip *irq_chip = &gpio->irq_chip; u8 irq_status; - irq_chip->name = chip->label; - irq_chip->irq_mask = tqmx86_gpio_irq_mask; - irq_chip->irq_unmask = tqmx86_gpio_irq_unmask; - irq_chip->irq_set_type = tqmx86_gpio_irq_set_type; - /* Mask all interrupts */ tqmx86_gpio_write(gpio, 0, TQMX86_GPIIC); @@ -293,7 +305,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS); girq = &chip->irq; - girq->chip = irq_chip; + gpio_irq_chip_set_chip(girq, &tqmx86_gpio_irq_chip); girq->parent_handler = tqmx86_gpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(&pdev->dev, 1, From patchwork Mon Mar 20 09:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 72059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1123061wrt; Mon, 20 Mar 2023 03:03:17 -0700 (PDT) X-Google-Smtp-Source: AK7set8/3O5ncyioRt8oyoqwTKrTaKuUbMqdq2WbtuD6Sjba8vs2bb4OkX4YLBjEqOs5mf5Nd31O X-Received: by 2002:a17:90b:3006:b0:23b:3b3a:54c2 with SMTP id hg6-20020a17090b300600b0023b3b3a54c2mr16596892pjb.48.1679306597129; Mon, 20 Mar 2023 03:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679306597; cv=none; d=google.com; s=arc-20160816; b=Xi/ri7NNmJwF5+NMflVtp8cDRTyldxpSYSqc83Eh3IMB5WXaSBQsCdY/gVVDv6n/dB jg1V6vubbt+qWW9MBFPq+gOPegnD4Y22V06NGU1y9JYlTHl0vky665seZGLxbrs9fxhv rcTG0OPJNh0b4oZSDOzjx7UnWAr/9Sa+5bWxLpXqMohLBsq75wg0nWKC2s+tTj+alP+z 23RGQibukWk0gxoKBFdTspJpxwn0Ro0KfuiScsQj+0ks8NWCPcmPzS6jsKVTJpwROllW KjrkIV0Cm7EIdo2JC46yu9vHmcNqMXR+k4m3GqS3ji/oV3bIdbLCbPlCl5pKyBxy7GH9 71HQ== 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=v+DXSMEQSq/E/GeQCvRmH9xVPSCzJghFx8xjxHqDlf8=; b=IXsmHia8btye1m0U3I0gCgfRd3Hp1sharuoX7+fWAt2BRFf6dMkCjxrb87EWFVKUxs aS+MeoG8bylk78Z0IBaYV4yzlYbQ/GwtGXC67FhJhmy7YdKcRYtHN7KEn1HjPPsKF0dB Dr3szlUl2YbbV57fnhn9FZtghlKNa4upkK3th5ilOlJHizgGpyFkcXUsPmHhTYg7xno1 HUqLvX71CIR1/zwVV8V04wkdclyrSBCOqo4At0mCATjOch+uFVHulAGtLyaMWqvDwYLh 12E1MzWiBeoTImh2lp2LpnRz/pOwdYlZFMF109JWxFFLnTfr5qTwc5po+uzd55TPrtdU Mchw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="f3XMr/0a"; 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 np17-20020a17090b4c5100b0023cfdc0a574si11375681pjb.129.2023.03.20.03.03.04; Mon, 20 Mar 2023 03:03: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="f3XMr/0a"; 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 S229599AbjCTJ4B (ORCPT + 99 others); Mon, 20 Mar 2023 05:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229878AbjCTJz2 (ORCPT ); Mon, 20 Mar 2023 05:55:28 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18058A75 for ; Mon, 20 Mar 2023 02:55:22 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id j11so14086278lfg.13 for ; Mon, 20 Mar 2023 02:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306120; 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=v+DXSMEQSq/E/GeQCvRmH9xVPSCzJghFx8xjxHqDlf8=; b=f3XMr/0a7E5112yn8B67+isIfWczaPX0COKFhxZkn86tE4AL1XxGx42+A1VpWkDmSt d+Y6jr+rwJt9Xe4wxYLwVW1QCMB1w6qWZAwj86Ei0FpY4cnzwtt+SaQVPqyz0SfGDAPH Qw4ueTfAzpFMmhhknevnUDjTFUksagTsBZJPqi3E3A0mRx6JxGwhCtlY0WWl33zsXdRN Z+x577EcFusK//cUApR8yZAamFCOLzS9uJs+haWkC+N2Ac07I2Pmcw9y8tno8eAq+VV3 GXEQ/z2jBCxku12gxUKuuiS7wZMtbpc7urzScbumij6iW/ulL7l+d4/szT4r7lbaZfV3 mtgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306120; 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=v+DXSMEQSq/E/GeQCvRmH9xVPSCzJghFx8xjxHqDlf8=; b=wfroOLUwiEVPBCDbzXJSps/v0ecCZfhlfzE32nR1AQ0jl2zKlJrghk9r3iSLxGEVet x70CoxBysxR7rQ2Q6zIEFPkLclnsK57fQPIWOyp+GtCjco/7VqQUwEBdwx3Cprecd0on 9BQp2rSVjyNeBIYyxp/rtYt6W6VayUVi1cIfcE8jZe5bhFnriTq45jakeuaiYyne0ar2 M8R/Hz1KH1B76EH2P+5LjfYrj7KiUXCvfVaU1UkTCB7lAZLRbERCzxXuMTqyquodFDFU m655Nu2M58+96gKbxdutvWwnwUKmBjpnIdTW6vlqmaQIRHKyk9Bl63wd4mNPWAybL33r Q1jQ== X-Gm-Message-State: AO0yUKWzK0Q4Fq+r1lPzz9pnoIgpkatpfkExfunLzl3BsKF2rzbClwab a3O2G4XU7o2Y3yHdoJkMMnFuAA== X-Received: by 2002:a05:6512:404:b0:4db:2977:508e with SMTP id u4-20020a056512040400b004db2977508emr6682560lfk.18.1679306120372; Mon, 20 Mar 2023 02:55:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:19 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:13 +0100 Subject: [PATCH 6/9] gpio: visconti: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-6-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=unavailable 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?1760880594373293032?= X-GMAIL-MSGID: =?utf-8?q?1760880594373293032?= Convert the driver to immutable irq-chip with a bit of intuition. The driver is for a hierarchical chip so some extra care needs to be taken to introduce two new callbacks. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-visconti.c | 50 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-visconti.c b/drivers/gpio/gpio-visconti.c index 5e108ba9956a..82639e81303e 100644 --- a/drivers/gpio/gpio-visconti.c +++ b/drivers/gpio/gpio-visconti.c @@ -15,6 +15,7 @@ #include #include #include +#include #include /* register offset */ @@ -31,7 +32,7 @@ struct visconti_gpio { void __iomem *base; spinlock_t lock; /* protect gpio register */ struct gpio_chip gpio_chip; - struct irq_chip irq_chip; + struct device *dev; }; static int visconti_gpio_irq_set_type(struct irq_data *d, unsigned int type) @@ -119,11 +120,45 @@ static int visconti_gpio_populate_parent_fwspec(struct gpio_chip *chip, return 0; } +static void visconti_gpio_mask_irq(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + irq_chip_mask_parent(d); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); +} + +static void visconti_gpio_unmask_irq(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); + irq_chip_unmask_parent(d); +} + +static void visconti_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct visconti_gpio *priv = gpiochip_get_data(gc); + + seq_printf(p, dev_name(priv->dev)); +} + +static const struct irq_chip visconti_gpio_irq_chip = { + .irq_mask = visconti_gpio_mask_irq, + .irq_unmask = visconti_gpio_unmask_irq, + .irq_eoi = irq_chip_eoi_parent, + .irq_set_type = visconti_gpio_irq_set_type, + .irq_print_chip = visconti_gpio_irq_print_chip, + .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND | + IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int visconti_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct visconti_gpio *priv; - struct irq_chip *irq_chip; struct gpio_irq_chip *girq; struct irq_domain *parent; struct device_node *irq_parent; @@ -134,6 +169,7 @@ static int visconti_gpio_probe(struct platform_device *pdev) return -ENOMEM; spin_lock_init(&priv->lock); + priv->dev = dev; priv->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->base)) @@ -164,16 +200,8 @@ static int visconti_gpio_probe(struct platform_device *pdev) return ret; } - irq_chip = &priv->irq_chip; - irq_chip->name = dev_name(dev); - irq_chip->irq_mask = irq_chip_mask_parent; - irq_chip->irq_unmask = irq_chip_unmask_parent; - irq_chip->irq_eoi = irq_chip_eoi_parent; - irq_chip->irq_set_type = visconti_gpio_irq_set_type; - irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; - girq = &priv->gpio_chip.irq; - girq->chip = irq_chip; + gpio_irq_chip_set_chip(girq, &visconti_gpio_irq_chip); girq->fwnode = of_node_to_fwnode(dev->of_node); girq->parent_domain = parent; girq->child_to_parent_hwirq = visconti_gpio_child_to_parent_hwirq; From patchwork Mon Mar 20 09:55:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 72056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1122494wrt; Mon, 20 Mar 2023 03:02:16 -0700 (PDT) X-Google-Smtp-Source: AK7set+CiBv4/6yqC8rHR9yjqqMsHkYW9iOVt9Y4usZs0ADics+Ewu18ev1f+pm182wZBvg3+adh X-Received: by 2002:a17:90b:1c83:b0:234:dc4:2006 with SMTP id oo3-20020a17090b1c8300b002340dc42006mr18412922pjb.4.1679306536317; Mon, 20 Mar 2023 03:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679306536; cv=none; d=google.com; s=arc-20160816; b=KAczCXcrTBfqOr2rGGdAoO0iGiYOacMwjU6c6HjsLTB6Ai2DFEdQLekerczkg1Tv3N Zf9/yvnqSqNgJDJZkR3oFakFqqXAReN+bzWddfwXqutp2FOCDXbTezTiDRDT1Z7JXJ6Z bIKJnehwdj0bsgz8dt9kB/26Rq0mIFh6ah4KsMrZmeIo3EAuZ4EW4MiiKrI3gtIn0MkA B+uPmOXGssY5UqIhx0BpclLggCn/3aqiQZADS5CgTnxLG4fFPUXMZ8qs2Ymqylc8HkHX 2u0sQ2GsNZro5D3otfpIJeSw0py6QVXvCApS6ahyb/yBjqutxcXJ6BWSChUpGv//UdbU 7gWA== 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=IQ8pDJ544LSAcFuKnZ1WqdUejeWGxtlm1VYmzzGBmgw=; b=Fn0KMrtJ+U0MWKb/nQsKveUkOR50W1Z+z1ByJFTXl6mu9PndUWpmMYorWbYynP3+kD EttclZ1uBua0OODZCiXP3U4CFC6VnR7nFNh9ocsyhoM8G+tCEwQtwesatzoxQFGmJltY bUrg3QOOm9/adXRyuAjAniu1NKYOichQwag7ubTCSDB3OTQZEPAED0nwg1Xb8O/IULnW 2+b3Rm2iz8CfHdcKu6SleOGxzk4P5LtKTA/M3eD65F35U3spJQQe228nCS3724f4B16n EOEmeR0qXAUD8RZL23zmjHtPwvYNr8tT+RjIhTj0GlByoUIQA6giREPKWhFlTYaqNGm0 HDng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lyJ+w0kp; 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 d10-20020a170902aa8a00b00194dd9cb062si9751749plr.396.2023.03.20.03.02.03; Mon, 20 Mar 2023 03:02:16 -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=lyJ+w0kp; 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 S230024AbjCTJzz (ORCPT + 99 others); Mon, 20 Mar 2023 05:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbjCTJz2 (ORCPT ); Mon, 20 Mar 2023 05:55:28 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1CF49FD for ; Mon, 20 Mar 2023 02:55:22 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id f18so14138393lfa.3 for ; Mon, 20 Mar 2023 02:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306121; 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=IQ8pDJ544LSAcFuKnZ1WqdUejeWGxtlm1VYmzzGBmgw=; b=lyJ+w0kp8l+cELb9UDJarzOUReNGbayK9wKZjJTyeWN91AK8i7Ojx1/+8902eHM++O 9kF6KgWPr4bGDOvASkQQQ9H3Zmhv4qhTLYtfiLOOSJb+BuYd0RzL6B6g5MCVkqry2pkY TPZ9pMkcsEiWJyhR4BpfK8oE+pVkByFq5vPia5YqQMtmxXWrDekt/7CFGcEI0DfOzoJ4 G3VTorPbaI1mBds+GzA7oerrUJKn7s/A0Oro1yOATwLbZ5MeDgM0Go+6GkqQgitIoYjg wEf1P1C9RBs5vanaRf2Fi7fyRDhAL0LJH2JrY3zV6i5A55/249WVxszwS96+eAqG0Y6F MyAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306121; 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=IQ8pDJ544LSAcFuKnZ1WqdUejeWGxtlm1VYmzzGBmgw=; b=1uK2vwWtyOYRNJ6hbz6UIQb1krGHne0BZSnTaPmAhM5Bx74WaIAWMc1P/rcWQI0+Mh VWlKZvYdBiITtGg8oWe5oPjpGxx0LPNTu3PQj7AAfwTL0hvepxh0eHaOGdMZhcbVNknh GMFtHxscm7Hwcy4wg5z+IBKih2Whw9HiI8b4MbFdIQcGd3B3cnHdsiG+aa/a/LRH9Wyr uVbI7LM9Fc7FTxav9H5snE0lGkR+v4gqZnlNi2uw9O/2WwrHDChwgQMNk16tnCqNxAHT M5MdpKBgwdfqrXUMRNSvAsxFLDy4o92dNK/HrAwXTF3ov/x0ZRxLLukNA2eTvjN1ZEEi 7hPA== X-Gm-Message-State: AO0yUKXO/kQYsNNLTGALWjYTNglzkQUwS6/fmcg2setwVAovJEv25iAz eTzfHcilLexdro8JyTPWfhkW0A== X-Received: by 2002:ac2:4142:0:b0:4dd:a445:e69d with SMTP id c2-20020ac24142000000b004dda445e69dmr5657173lfi.26.1679306121600; Mon, 20 Mar 2023 02:55:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:21 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:14 +0100 Subject: [PATCH 7/9] gpio: xgs-iproc: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-7-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=unavailable 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?1760880530437758506?= X-GMAIL-MSGID: =?utf-8?q?1760880530437758506?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xgs-iproc.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c index fd88500399c6..2d23b27d55af 100644 --- a/drivers/gpio/gpio-xgs-iproc.c +++ b/drivers/gpio/gpio-xgs-iproc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #define IPROC_CCA_INT_F_GPIOINT BIT(0) @@ -27,7 +28,6 @@ #define IPROC_GPIO_CCA_INT_EDGE 0x24 struct iproc_gpio_chip { - struct irq_chip irqchip; struct gpio_chip gc; spinlock_t lock; struct device *dev; @@ -69,6 +69,7 @@ static void iproc_gpio_irq_unmask(struct irq_data *d) u32 irq = d->irq; u32 int_mask, irq_type, event_mask; + gpiochip_enable_irq(gc, pin); spin_lock_irqsave(&chip->lock, flags); irq_type = irq_get_trigger_type(irq); event_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); @@ -110,6 +111,7 @@ static void iproc_gpio_irq_mask(struct irq_data *d) chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); } spin_unlock_irqrestore(&chip->lock, flags); + gpiochip_disable_irq(gc, pin); } static int iproc_gpio_irq_set_type(struct irq_data *d, u32 type) @@ -191,6 +193,24 @@ static irqreturn_t iproc_gpio_irq_handler(int irq, void *data) return int_bits ? IRQ_HANDLED : IRQ_NONE; } +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 *chip = to_iproc_gpio(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_print_chip = iproc_gpio_irq_print_chip, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int iproc_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -230,16 +250,8 @@ static int iproc_gpio_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq > 0) { struct gpio_irq_chip *girq; - struct irq_chip *irqc; u32 val; - 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; - chip->intr = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(chip->intr)) return PTR_ERR(chip->intr); @@ -261,7 +273,7 @@ static int iproc_gpio_probe(struct platform_device *pdev) } girq = &chip->gc.irq; - girq->chip = irqc; + gpio_irq_chip_set_chip(girq, &iproc_gpio_irq_chip); /* This will let us handle the parent IRQ in the driver */ girq->parent_handler = NULL; girq->num_parents = 0; From patchwork Mon Mar 20 09:55:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 72079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1133622wrt; Mon, 20 Mar 2023 03:29:14 -0700 (PDT) X-Google-Smtp-Source: AK7set+CvaAWCUNlmpPeFR8j52uh1lvbcsr/dfeg7N2edGGYe7w3dn1RUL8F5hJjTA4abrzRs/lk X-Received: by 2002:aa7:9e5b:0:b0:626:6a3:6b81 with SMTP id z27-20020aa79e5b000000b0062606a36b81mr13098789pfq.15.1679308153957; Mon, 20 Mar 2023 03:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679308153; cv=none; d=google.com; s=arc-20160816; b=R3XRcaMMVc9CR5XZzxYKLZvBiUU9Iv9jCNsXrQYeLaHb7BR6WirxnuvvqLr9Te5LGn azU8vy5xw3H+Omo2KwmQOF00a9xtXptz8tmNBOTLKZMJCEV/8g6qEe6JKW6+UzpWBmf5 C/Hkv1gdtYCwLiBuQVlxyRCY87i2DAwczVxxZrF5q0NwU9Npehx0dQHxnoSr7XxlDou+ 5JSGd+ldciQn2L9aNgZC0uiGIUt53zzxfXPUU6FIwO2tqXQ6Js6Ygdd3ZXu2UDN2ywIQ ODDYTEWJb2/FDoWkbo5QFbHrtt3Srff3hGOica3zqlAQOUkvdNQCOVixK6ltKIYSv9vz w2Rw== 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=ONs8hu4DakRq6Eq9QQk6sVabt3pk1jUGku2e96eNaoc=; b=oIaEXTnumpesPJKpRKEsSLAcUwBwQky024xyh1m9Bz5jex0B3qOwO5Ln0u4fE7a3ae o8e3wTwstMMajsqkep1cf41/z3lz6RuQaMQFabO/+1vDJch/YLL7b7PrIIsxv3+tcpkh OLUmfklOsglxTALHtBMqoJB8Y6D4+NSWvPa/4snGAnEJ1HWOjXnDXhj9UMBB7bptBLTw 5jTMq0bhuQmbUYUoJpmqY/Vr2mbBhpY2i/m2h6AnhorviiRaYoabmZKWvaRVEccGNgQP wszIqBMmfQxYBJLoPCspr8E8GtfNhmgsSXMnVl3IXl5q3X2GKlZWVvGRfk330+pnnXct t2ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aOazW7qy; 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 r4-20020a056a00216400b006275424eab1si7484645pff.139.2023.03.20.03.28.59; Mon, 20 Mar 2023 03:29:13 -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=aOazW7qy; 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 S229529AbjCTJ4P (ORCPT + 99 others); Mon, 20 Mar 2023 05:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbjCTJzc (ORCPT ); Mon, 20 Mar 2023 05:55:32 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61FA24208 for ; Mon, 20 Mar 2023 02:55:26 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id b10so12943404lfb.9 for ; Mon, 20 Mar 2023 02:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306122; 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=ONs8hu4DakRq6Eq9QQk6sVabt3pk1jUGku2e96eNaoc=; b=aOazW7qyLg8EFAxpfusMynHT4aR5dT28i5YmCDy2aNE49eIk4P+GQ36cGYKN769CRr 8MkfV47LsZ80x+/3fpq0B+lMRPiab+22V/Z6LIGq14vI7NkNTumNzLDvAegjlBKrKiED CHMcfcXyEZuYYPSJNKR3mketsbGFofKCVw2uSSXwVWr8U1utrhwdZ0QehLWUyi5Dadpd Jbj8c7/XlikkigGSWOIokZzMIs5a/eKH8LEosYiibLs+1z3BAW4j9/9Q+RHg13e3SDFJ /Gb8o/Df2SJUEbvYbCJnKo4RkxaNF1CXYnsJ2MLVe6QcXoHDeRRWRu4g6DOsK4q7iC+V LyaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306122; 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=ONs8hu4DakRq6Eq9QQk6sVabt3pk1jUGku2e96eNaoc=; b=zmSYCYIbk4scSFjwJNjZrlGeGoAEPeyO2O+vGzfY/nMkZ+Ho8JGlrrn9MK1y5O8/M9 MIGnZ4GstAY8I20pCJ3tM23MJYV9SCkXfq+NQn6gGTikFhdoED7SeRVnvgrXndJY24Ds 6GdjZPBUzgioahLVXpPD2muz58t5mFU3k4sjkiiYCzfDrGtoag0T7e4q1vEFM7cybMY9 tFWTcJ7tqwklrNeXAazXPUy55NDgS4fCJI+7VgqeuC19U2pQtpeEJ8QjIaIsaZlxzin5 ZGaY30fvkqrLx5OZEnx8zOEJe1XH+kKzp3G4JdXzLmbJjQF0490JqoWpC11yXaokJ9vU UCeQ== X-Gm-Message-State: AO0yUKV8lsaOIjhyg8entP2ukXQ4tgY73pVjoQ31XPu4nR/3TdkLRnqj +Y45TVAALtWPOYW5P8rKIYX/iQ== X-Received: by 2002:a19:f00d:0:b0:4e9:d53:a5ef with SMTP id p13-20020a19f00d000000b004e90d53a5efmr4588282lfc.1.1679306122703; Mon, 20 Mar 2023 02:55:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:22 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:15 +0100 Subject: [PATCH 8/9] gpio: xilinx: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-8-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=unavailable 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?1760882227189239181?= X-GMAIL-MSGID: =?utf-8?q?1760882227189239181?= Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xilinx.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index e248809965ca..1fa66f2a667f 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -68,7 +68,6 @@ struct xgpio_instance { DECLARE_BITMAP(dir, 64); spinlock_t gpio_lock; /* For serializing operations */ int irq; - struct irq_chip irqchip; DECLARE_BITMAP(enable, 64); DECLARE_BITMAP(rising_edge, 64); DECLARE_BITMAP(falling_edge, 64); @@ -416,6 +415,8 @@ static void xgpio_irq_mask(struct irq_data *irq_data) xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp); } spin_unlock_irqrestore(&chip->gpio_lock, flags); + + gpiochip_disable_irq(&chip->gc, irq_offset); } /** @@ -431,6 +432,8 @@ static void xgpio_irq_unmask(struct irq_data *irq_data) u32 old_enable = xgpio_get_value32(chip->enable, bit); u32 mask = BIT(bit / 32), val; + gpiochip_enable_irq(&chip->gc, irq_offset); + spin_lock_irqsave(&chip->gpio_lock, flags); __set_bit(bit, chip->enable); @@ -544,6 +547,16 @@ static void xgpio_irqhandler(struct irq_desc *desc) chained_irq_exit(irqchip, desc); } +static const struct irq_chip xgpio_irq_chip = { + .name = "gpio-xilinx", + .irq_ack = xgpio_irq_ack, + .irq_mask = xgpio_irq_mask, + .irq_unmask = xgpio_irq_unmask, + .irq_set_type = xgpio_set_irq_type, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + /** * xgpio_probe - Probe method for the GPIO device. * @pdev: pointer to the platform device @@ -653,12 +666,6 @@ static int xgpio_probe(struct platform_device *pdev) if (chip->irq <= 0) goto skip_irq; - chip->irqchip.name = "gpio-xilinx"; - chip->irqchip.irq_ack = xgpio_irq_ack; - chip->irqchip.irq_mask = xgpio_irq_mask; - chip->irqchip.irq_unmask = xgpio_irq_unmask; - chip->irqchip.irq_set_type = xgpio_set_irq_type; - /* Disable per-channel interrupts */ xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, 0); /* Clear any existing per-channel interrupts */ @@ -668,7 +675,7 @@ static int xgpio_probe(struct platform_device *pdev) xgpio_writereg(chip->regs + XGPIO_GIER_OFFSET, XGPIO_GIER_IE); girq = &chip->gc.irq; - girq->chip = &chip->irqchip; + gpio_irq_chip_set_chip(girq, &xgpio_irq_chip); girq->parent_handler = xgpio_irqhandler; girq->num_parents = 1; girq->parents = devm_kcalloc(&pdev->dev, 1, From patchwork Mon Mar 20 09:55:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 72060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1123235wrt; Mon, 20 Mar 2023 03:03:39 -0700 (PDT) X-Google-Smtp-Source: AK7set+iB4qEvGHacCu/F0Po+Fu5kRFo3MLsUoQTqe0JMP5Pfxa5NPrTrKjTFqIjH8yOMDdsjieO X-Received: by 2002:a17:902:ef91:b0:1a1:b8ff:5552 with SMTP id iz17-20020a170902ef9100b001a1b8ff5552mr7180011plb.6.1679306619572; Mon, 20 Mar 2023 03:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679306619; cv=none; d=google.com; s=arc-20160816; b=DCqHSyu2HfPKBAbpC57HfxbVdE/wcI6FQ4+O6KgNtolHD6XFcDJcp6g/8aiFec9lZR RJJoZzlko8oOsMbphT1oz1ykBXbxLiFf4zuaFjqxKCrno20DkywYy14A8oYfTeSJshrj NGzmf4XAi6UJa19R+nxp6sabh97yFPu4l157GOxRLcn3qRnD38PXFwx66MeFQlJcaE70 ZvVFuIl2hNmuZMjcu7XDDEAoMZDjRxojKdBXK9hy8UI89cASaTH+KTySaeun6weL56dN ujautNu22GIL2JnmjzDkgn0jOaD3pmml+MwK2ainfnKWT9zLtjbt3iMrNSXnWDvJkWn4 oP7g== 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=cSpuqjy/eXDpqnKiK4OUOR7RpMUVN5QXd0K9J1nI3tU=; b=08z63Q8DLZjjwNIGbF5oJIWVvC8NKIrXH31DCQv62KM7+Ps+aSL8w+N22h7CozCuh8 lPOshZXVI+5ZAnkl+Ao5TIxvXKBRrfwJap4ARRiXa8reGcPFYwf3cCI0MhwboPr639ym U9ly/VRcGUpaFdaO/4pHDP1uIPmafSeEt0TnTbV9SHFNh7m5NwB2k2+MiVyg1Xn7UKNv PFrxOu38YuhizxxiT7ZxmJ/mGUvnj35rQbZto39edWDMK1AWAjsFN2NuzDsPMVkmUSYS zpn9Hmzr01mxcWY5xggaERVUikou5outXqzYmBs/tn7ffOjb3XiQxQUWcrx6XSkEqhBj a2NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ph9IxB/K"; 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 s129-20020a632c87000000b0050ac80fc7b1si10470685pgs.658.2023.03.20.03.03.22; Mon, 20 Mar 2023 03:03:39 -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="Ph9IxB/K"; 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 S229970AbjCTJ4I (ORCPT + 99 others); Mon, 20 Mar 2023 05:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjCTJz3 (ORCPT ); Mon, 20 Mar 2023 05:55:29 -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 96842E1B3 for ; Mon, 20 Mar 2023 02:55:24 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id g17so14142716lfv.4 for ; Mon, 20 Mar 2023 02:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679306123; 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=cSpuqjy/eXDpqnKiK4OUOR7RpMUVN5QXd0K9J1nI3tU=; b=Ph9IxB/K1MagKuPpYcNTHdd1a0iCrw+L76Vhq2MD2jW8DA+dF0oUzJH2YUzr2HqIjB yLqqO7Ju5f+zqKibHuUfbPuUwD6+dseaWQ4FBN9f1G3CyOhRPUnm3UaLAQyI4lR/Qv9H +5mTs+wlfZvAXRjf0dovMN01lsNZd+l86pcj2o7gaunZ+uNHm0+viVKVdxSiLn9mVSEv mG1vifHHT4awWvocEkbiYrMIcgJUa6eu0av+kMiltzYOWC1VjQdjk5qTR3aBZ56I7g3u 3UHfCMgukj6UI4cTDyj27WstwX5M3XMSCyX9suaMYfSNLZthYMDI+QKbCEw6E5deGByT nBDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679306123; 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=cSpuqjy/eXDpqnKiK4OUOR7RpMUVN5QXd0K9J1nI3tU=; b=1KJEl5Q/1mJGIYmaiq9F3IwLFSGrl6zsoDz2z0b/2LnrfQNoPqH7JSHXgG8Et8n5xZ q8QW5IdHThgMq9tt9xJKgfkBjFlfJgKspu8sBbPYG6tA11+eSDKLR6tmF7rREjfT02Uw BbPcG7wbcgOcOJyvx+ICVKnY1k8HoDl5Ki3wWs9Fto3b9rvfkkQjZNG2qodFO0hMcOGr MNRHoF29hYHWKywtEXLXUBIc4/6vaMTO/Z6TtKIvmPb5YcDowEYBrMvfaiH9TPhk6j1n +yh/tkNVpooie9sb4cpobZyHjjN3xVgRHOxdBkHT7WNfWgwqohCBS46Fj4ZnC9jk4GPM UVAg== X-Gm-Message-State: AO0yUKXuc4a5nnLjMBbQfqWeJ3xVkqmEGuH/t2x1f3AWvHOFQ3/BluVf x6aOILsWZu4FVbeaVO3vI18OXg== X-Received: by 2002:ac2:52b5:0:b0:4b6:fddc:1fcd with SMTP id r21-20020ac252b5000000b004b6fddc1fcdmr3649099lfm.23.1679306123693; Mon, 20 Mar 2023 02:55:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 02:55:23 -0700 (PDT) From: Linus Walleij Date: Mon, 20 Mar 2023 10:55:16 +0100 Subject: [PATCH 9/9] gpio: xlp: Convert to immutable irq_chip MIME-Version: 1.0 Message-Id: <20230316-immutable-chips-2-v1-9-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?1760880618169748019?= X-GMAIL-MSGID: =?utf-8?q?1760880618169748019?= Convert the driver to immutable irq-chip with a bit of intuition. In this case the driver uses .mask_ack() and .unmask() and since I have a vague idea about the semantics of .mask_ack() I added .irq_enable() to the existing .irq_disable() and called into the gpiolib core from those callbacks instead of mask/unmask. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xlp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c index 0199f545335f..b4b52213bcd9 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c @@ -90,6 +90,13 @@ static void xlp_gpio_set_reg(void __iomem *addr, unsigned gpio, int state) writel(value, addr + regset); } +static void xlp_gpio_irq_enable(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); +} + static void xlp_gpio_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); @@ -100,6 +107,7 @@ static void xlp_gpio_irq_disable(struct irq_data *d) xlp_gpio_set_reg(priv->gpio_intr_en, d->hwirq, 0x0); __clear_bit(d->hwirq, priv->gpio_enabled_mask); spin_unlock_irqrestore(&priv->lock, flags); + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); } static void xlp_gpio_irq_mask_ack(struct irq_data *d) @@ -163,10 +171,12 @@ static int xlp_gpio_set_irq_type(struct irq_data *d, unsigned int type) static struct irq_chip xlp_gpio_irq_chip = { .name = "XLP-GPIO", .irq_mask_ack = xlp_gpio_irq_mask_ack, + .irq_enable = xlp_gpio_irq_enable, .irq_disable = xlp_gpio_irq_disable, .irq_set_type = xlp_gpio_set_irq_type, .irq_unmask = xlp_gpio_irq_unmask, - .flags = IRQCHIP_ONESHOT_SAFE, + .flags = IRQCHIP_ONESHOT_SAFE | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static void xlp_gpio_generic_handler(struct irq_desc *desc) @@ -272,7 +282,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) spin_lock_init(&priv->lock); girq = &gc->irq; - girq->chip = &xlp_gpio_irq_chip; + gpio_irq_chip_set_chip(girq, &xlp_gpio_irq_chip); girq->parent_handler = xlp_gpio_generic_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(&pdev->dev, 1,