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: 13181035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 645B3C761AF for ; Mon, 20 Mar 2023 11:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NcoJcFZMHWZ28vzwmW3lwK9xpbOmBS+JiuBC3/R2Ti4=; b=s5GQ1wp0jIg/N3 FkB+hCastMqPGzNkfvwSz6xxVZSAFhJQV7XlnF8PDyrGPCBbHbtHVWhGMpbYyImkn6dhl+ra4AbmF XiRGtYEzk8W6Cc7ohb+tBqnxWc/0Kg4mQsTVrE315FPaX0KwQFIREAI9w1GrdTPe62GLveyXmonqU tr2np7PU9WTga+OFFMZg8jk5f6skebpL6AaCqv4+WnasUHfge11szTma9q/AWIKVC4wDEwkzrTDg+ PYQb5mTUk3sm44Thg70Qmh1JCP1lU2/Yl6cPMwgprRKFbA6N/T7Ai8fCZxkKsIUW42Z1mMEEYXVd6 /ggH6a2/kv+W/j8b8F0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peDFW-008jkJ-1R; Mon, 20 Mar 2023 11:00:22 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peCEc-008Y5B-35 for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 09:55:24 +0000 Received: by mail-lf1-x134.google.com with SMTP id h25so2455995lfv.6 for ; Mon, 20 Mar 2023 02:55:20 -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=WaOtnozw1tJIpyMjAZz1w98hMwrZvHjGAbEshGMo21gxiaESeLx4OyvUMK2uCh5U7k ISEuYj1zZaCBJqdGIl6aQ9w9q6gVlVmnGMVc4lSlGpK0OdTiMrWJEcPUtlv7mw31pd4O LdZzBh+C+315Og8gML3lwHoQvwJLFkSh6GaO9cHK73U1Lh1vzZdCNcPtGqs1aUyz9XfQ FyjxAcvxJ/9s0k3DiIopEP4y3o/bonZb3vW6hONF6cYWAJZRXiaHfjktAbo5jwxpAQlp 55SnVZCeDpKKiA0vI/a+S9XNJeIVmozX7MqJQUlDXYJW7YXaZVbVKqA28pv0WXOOjrpe Vq3Q== X-Gm-Message-State: AO0yUKVDMMxB6+pxHiDCxb4sqUEggylj6b982Q/FGW1VcuVcm33HkTvJ DqOnW3GVdPhnjn2XIp1fkVbAoQ== X-Google-Smtp-Source: AK7set+nN7wJ+atkoSzdFP68LNe4ASCgnZA7hoX78zbZLZDK9kBtZZM0z69izqvAxxmLwp/AJRTN/A== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_025523_042409_FDEB9A55 X-CRM114-Status: GOOD ( 15.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/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,