From patchwork Wed Jul 19 16:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13319195 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 6DAAFC001E0 for ; Wed, 19 Jul 2023 16:35:00 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bMKELCgzsi/kpKIXHaTKV3VRb9HQaD/Kks24jFf5QWM=; b=h3YPzKuqXicTgK QrgNecvtDwOsMFQ/l/sJ6UtKiLbRg2mkrBPFSXPPNt/qmykkGzTmuIeRy6BWr8uVpG/FziN1hdM7y 9Tq8jCrUEW54EPDFaaOyHtolcDbVTMo1qj4A+A+LAWkEwkOoNEljjDcuhe88OAi4WTJysP1lSadM0 vMypFGjTd2q0PQDX/9u3WKEinFADzDcgTrMFcDa3F5lEkwzFuMFjvtxUwzyjZZR6AlSJa9TRpvizP XBSL03XQfkfOrQntOMSRRWBXycos4J5TDsqcvUwnHLx857BzuETv0ofsuTwDb8q8xr/tkLkMSTh+r zuNs8aZPnbPTOBYGpC7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8e-0089YS-0a; Wed, 19 Jul 2023 16:34:56 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8a-0089VJ-03 for linux-riscv@lists.infradead.org; Wed, 19 Jul 2023 16:34:54 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b852785a65so7322245ad.0 for ; Wed, 19 Jul 2023 09:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1689784490; x=1690389290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q3Vmf1NOG+ODjCHOgvNL111a44nf8BOJMta6b8HQDok=; b=KM4n0tGjZndeHQmSDMlsp7ofZX/LnEb4qirUfsAM54X9Oy82L0EZEHRalHPNnDygG6 nNx8cSdB5UYvQ/u+WH4OGpsBvnwtGTv2kudZfZ7ShkkiQauK8i3dA2eaFQwDICEyTDiA FOTbe5VBBGE6ukx1/g8oMY1+FT6DFqHeDxFS1sLciRyq295/ddfMs1GkCUjXxbtD8B6/ 4mIi3jh018Joh4zJWwGo7ikDeLCV0a2pg+1+judZ1neV+8/tFxzqjyWxWN5qPIE6WWdD Ys2+SxdHHuZLUcEIQr3Tehb8+F4be5mG7as7vi4F8o97xpSw8PRqEqxRlBxQJdZokZsb X9Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689784490; x=1690389290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q3Vmf1NOG+ODjCHOgvNL111a44nf8BOJMta6b8HQDok=; b=hxXcVGnAnYDAatwFgoIKb9+E66MaalJcHLXxKBau9u2HaG69m5eL0blqR9fJ/uqj1r GW+zAs9fC9eSBJWkT5BmOkVUsRsBYq9pxgFh4/1AfuOZ2xNDCujP1iqyytMCfM3baMIJ bVa3KUZW5wAvee3CcFk2bvZK7Og0cWdVJtyv75A335Jh3DYBUyXwC7lBRNjM8iAOzEZ1 kbpFAQPsl+X19rEg8VS1xukwQ6wt140hWcrtVNGuu6h1+fqNSIpaDfztGtaF6tagW6z0 DRmWdFc1ZUn9v5wlLwlCeZQ9f1llWSresHuEzUGOCC1CiM/3HXkPlOUHgiV4wL+pCo4D +h2g== X-Gm-Message-State: ABy/qLbJU0CnHtAwh5kH+5/7oE2BCdgIfGfPW8IQpJgTaD9rcWV74bwe +jgXyHlUqyhlOkZszKBshePC5g== X-Google-Smtp-Source: APBJJlE7hFmGHGL/6El2RN8C/gzU454avPKtZQT3f8vkHvUEcVT/8J+Y90iWWwoCNkPuUZMQ0MWfDQ== X-Received: by 2002:a17:903:2288:b0:1b6:9954:2030 with SMTP id b8-20020a170903228800b001b699542030mr3456086plh.8.1689784489937; Wed, 19 Jul 2023 09:34:49 -0700 (PDT) Received: from sw06.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id x6-20020a1709027c0600b001b0358848b0sm4199276pll.161.2023.07.19.09.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 09:34:49 -0700 (PDT) From: Samuel Holland To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: Emil Renner Berthing , Rob Herring , Frank Rowand , Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 1/4] gpio: sifive: Directly use the device's fwnode Date: Wed, 19 Jul 2023 09:34:42 -0700 Message-Id: <20230719163446.1398961-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230719163446.1398961-1-samuel.holland@sifive.com> References: <20230719163446.1398961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_093452_105799_603A5A3D X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org There is no need to convert dev->of_node back to a fwnode_handle. Signed-off-by: Samuel Holland --- Changes in v2: - New patch for v2 drivers/gpio/gpio-sifive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c index 745e5f67254e..ab32c952c61b 100644 --- a/drivers/gpio/gpio-sifive.c +++ b/drivers/gpio/gpio-sifive.c @@ -254,7 +254,7 @@ static int sifive_gpio_probe(struct platform_device *pdev) chip->gc.owner = THIS_MODULE; girq = &chip->gc.irq; gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip); - girq->fwnode = of_node_to_fwnode(node); + girq->fwnode = dev->fwnode; girq->parent_domain = parent; girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq; girq->handler = handle_bad_irq; From patchwork Wed Jul 19 16:34:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13319196 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 E43D9C04A6A for ; Wed, 19 Jul 2023 16:35:03 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yK0x+ABYYGFHOIRupfNQasMQv5Xz59gfyux/kWy3t/8=; b=Z0y/2TlAOt3ylq IzLm3UODRLrdDqwkV7ryVsH/Z6wGuj2VgRisFO3gUDi/zyjx8Rey2c3nguo2ZRjsrBurVeS/o51z+ 53ZgBSXUKa5qNMGuDpE1F8JkXu1XJbPEb9LnJknt59GVsL2ABCZJe7ZOgz2+ccztqijLXJsIWp1Rj iNgCqpYPYixOYmpne+TDXklFbI4aPFS1fiVWnnZySYWCGdZdSkRgcP5qPy9NAvfrLnUrLEby7pNeU AqwrhZBf/193qsuTYm21ca9PynB/F9TzcqQA99RRzNgGf0+UWQRu7wpsgmbS8z/TnOl6ORHZOzBcC zHkq5Ls/Amizr7fsenBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8i-0089ZY-0Q; Wed, 19 Jul 2023 16:35:00 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8c-0089Vo-2s for linux-riscv@lists.infradead.org; Wed, 19 Jul 2023 16:34:56 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b852785a65so7322525ad.0 for ; Wed, 19 Jul 2023 09:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1689784491; x=1690389291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WY7X996NeRiPR/Rn6FoiwTLGW7DQeNpFoBjkmVc9GgI=; b=Or+/RZwQvNw8bCsOMpm2hSeXLxwp0YuvAcpxKF/K2j6mFJlt3xZGR9ukX+ORaAabKc S/BtVbCvnXG7wClDGpbGAMoCX/el65aEgzRnBn5+XjPwirv+/sC6G+nt5vaK46C5cJ5Q ut6Z72dE3exsn0wXnTpjlmU3IG8rj8ONqqZoL8UZAZ87q1sQR9ZrY3TIcTYSO5eCMkN0 K2GBSS6WcrAdlz0eN/pd/f6gjwGcO56TIdZ8xhNSkqMOd3fcEa1E8jsNB3SSSPRXacMs RVqOmrJEu4o7Dpfa3m8IquxXcYW+JF2mpl9Bh8EWRGF9EJMZ5WhDBUiufGw+kw8cGlnV I0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689784491; x=1690389291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WY7X996NeRiPR/Rn6FoiwTLGW7DQeNpFoBjkmVc9GgI=; b=JgW+VTtIyiC9go3Cr+fbydTbax1ILkbffJsQbeEDgvoInk++EtEdlsfd/psaAuVgCq suKHVhKtHaLrQZBOsOKBGrM4yzWnPxChft9R8ZJhR9SomQBVg/cffwCVu1t178SIpc9b ZJNvh4wD+TyX/N16gxwvoT5DpKXNGhJIZNN7SXP97pfibpATDG0YtfKA8mfFE/Sxopmw BeMT9WrR2y9Mt5WTOGN5STRLtcdkTAj/kIVMU9q2X3gFda2ymv5xV+mUZ7P6JFUkwLjq oZaP1ci+saUsXrA9HoYk3Pf3+eaiC8CyHtUCPw+pZW9M43P2l6BNdWbyekXZqdc/CFhZ tuTg== X-Gm-Message-State: ABy/qLb9ehjo3qa3BUbKROBcds2tl5wr91CtI0Z2I2tJQlZjJ53IHMVs hZ7kQq3BJI2AJxMe297Ogo43JQ== X-Google-Smtp-Source: APBJJlEdZ4LQSFXZ1B6gqxnku1+mdn1+YmhZhDbIEaXe7GUhYDR8hCg+4i71OKmpuzxzwsW+MP9rUw== X-Received: by 2002:a17:902:bb84:b0:1b8:8728:d776 with SMTP id m4-20020a170902bb8400b001b88728d776mr2926304pls.0.1689784491343; Wed, 19 Jul 2023 09:34:51 -0700 (PDT) Received: from sw06.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id x6-20020a1709027c0600b001b0358848b0sm4199276pll.161.2023.07.19.09.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 09:34:51 -0700 (PDT) From: Samuel Holland To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: Emil Renner Berthing , Rob Herring , Frank Rowand , Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 2/4] gpio: sifive: Look up IRQs only once during probe Date: Wed, 19 Jul 2023 09:34:43 -0700 Message-Id: <20230719163446.1398961-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230719163446.1398961-1-samuel.holland@sifive.com> References: <20230719163446.1398961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_093455_097031_9198EE7C X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org of_irq_count(), or eqivalently platform_irq_count(), simply looks up successively-numbered IRQs until that fails. Since this driver needs to look up each IRQ anyway to get its virq number, use that existing loop to count the IRQs at the same time. Signed-off-by: Samuel Holland --- Changes in v2: - New patch for v2 drivers/gpio/gpio-sifive.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c index ab32c952c61b..6606c919d957 100644 --- a/drivers/gpio/gpio-sifive.c +++ b/drivers/gpio/gpio-sifive.c @@ -185,7 +185,7 @@ static int sifive_gpio_probe(struct platform_device *pdev) struct irq_domain *parent; struct gpio_irq_chip *girq; struct sifive_gpio *chip; - int ret, ngpio, i; + int ret, ngpio; chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) @@ -202,13 +202,6 @@ static int sifive_gpio_probe(struct platform_device *pdev) if (IS_ERR(chip->regs)) return PTR_ERR(chip->regs); - ngpio = of_irq_count(node); - if (ngpio > SIFIVE_GPIO_MAX) { - dev_err(dev, "Too many GPIO interrupts (max=%d)\n", - SIFIVE_GPIO_MAX); - return -ENXIO; - } - irq_parent = of_irq_find_parent(node); if (!irq_parent) { dev_err(dev, "no IRQ parent node\n"); @@ -221,11 +214,11 @@ static int sifive_gpio_probe(struct platform_device *pdev) return -ENODEV; } - for (i = 0; i < ngpio; i++) { - ret = platform_get_irq(pdev, i); + for (ngpio = 0; ngpio < SIFIVE_GPIO_MAX; ngpio++) { + ret = platform_get_irq_optional(pdev, ngpio); if (ret < 0) - return ret; - chip->irq_number[i] = ret; + break; + chip->irq_number[ngpio] = ret; } ret = bgpio_init(&chip->gc, dev, 4, From patchwork Wed Jul 19 16:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13319197 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 D4CD4C001DE for ; Wed, 19 Jul 2023 16:35:06 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qPrpQQLnf+npBuska+leNlssvQWZ/+OK7OX32kaWnhU=; b=PJLtAmqBjgu1Py 1h/xqsi6pINnrbwoXpkIl0WHyKonIRJIHlQ6jzOGeJElMKDpgz2tElJL6x5zoeGoEieoFwqtoBXDh nfv2qgWiFwS4u5HCLA/kSliLUSp4OlOI0I+a8H2c8BuERE7kQjwaaEzFThYUJ02jR8zIsya8rAMHP JI3rIi5jH6ZBZVc6bjbABLLnpOkj0Hh5EJgmakOsjo3g6TR/3LyREa01qFho7Pgz2+ZFlkmuVqNUk LedgNeDDaZ8Aal8m/Lm43r74jb16815U1R8S7FY5CHTdLEzagjDFdRF6bQcSN4QtBVpK5irwFz1ba KxnvJa2qEW30QjaVPOBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8k-0089bg-2u; Wed, 19 Jul 2023 16:35:03 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8i-0089XC-1u for linux-riscv@lists.infradead.org; Wed, 19 Jul 2023 16:35:02 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b9e93a538dso40656445ad.3 for ; Wed, 19 Jul 2023 09:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1689784493; x=1690389293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qKYrsbwFkQq7mxSa9jMwKApOtesu39YvxU4CShJxAhI=; b=ZvLnrY1568MZhaU/qXPqlRY4i0xnbvv+JpUWdEukxuSZl/js2HLyiHv64/36av5u3L kUf3LGIWVHKuEZeht318sYiL3rd50EHbqXS0SXHIx8tUVeo1gBBrSfKjl0evGs6RA3Ph g15fyNoVbYvClluNk5HufnB5tU27SwjMx5sRXAV13WPnOgbqZokaYWmyXm001+hU3wzZ pjyGKQGGSPgDbmCq74EU+FgzpiZ9qp8PbTz5jkNX35QqD0fTRTcLxPkTgUTIUr7UjxPB WIr+kn52YPa2S/ZaOznqmSXXYvLlDmov1AW9dqDgYj+1cv1QQdhKmZolsnN5t/wTas0R BFCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689784493; x=1690389293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qKYrsbwFkQq7mxSa9jMwKApOtesu39YvxU4CShJxAhI=; b=ALArLMwt3UOe5q6E64SEuFfiAj2zJNBRS0d5PLSmTlZE42vbJNhnMqX013lzX0CnZS qvXqUSCgwfb8uF4oY3Slz3QvnesHd7LtCoYiWJTEU9WqgtT02moMb5t7CboMN0e4EAnY cgT7mwKygIsckaGZksydnev6GNLNdI/1Cvl2QIqeXrQ9JrrRgiWESY3b+NSzcF4ElLAp HMaksiXjj6q1kEuXDabvlIQK2dVYaR8ZhYcUnUBBTolFSMlokQgxdvLmdfwWdaPlSGOh 4s6UI52fH0gsjQrZjDl/67qq1nPy9cDVbTTF1g6YCk1egaYsLyTA53Ly2oOiFVUxs1bs wLQA== X-Gm-Message-State: ABy/qLboyX67MlKUdEzPhkmVEQII1VAmcKnSN0jnPKewFxZX8aWVXKO1 BMnqCwDLyQoCC5O0uiCc+DoTRw== X-Google-Smtp-Source: APBJJlFipcbSu/NojN35HkrEsviKbFWtcYcx3WLvCCXo8NC5ZDt1xR4dBGQY2EMiUvSm/R5cz/pIvg== X-Received: by 2002:a17:903:48c:b0:1b8:7483:d47a with SMTP id jj12-20020a170903048c00b001b87483d47amr15035853plb.37.1689784492938; Wed, 19 Jul 2023 09:34:52 -0700 (PDT) Received: from sw06.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id x6-20020a1709027c0600b001b0358848b0sm4199276pll.161.2023.07.19.09.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 09:34:52 -0700 (PDT) From: Samuel Holland To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: Emil Renner Berthing , Rob Herring , Frank Rowand , Samuel Holland , Palmer Dabbelt , Paul Walmsley , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 3/4] gpio: sifive: Get the parent IRQ's domain from its irq_data Date: Wed, 19 Jul 2023 09:34:44 -0700 Message-Id: <20230719163446.1398961-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230719163446.1398961-1-samuel.holland@sifive.com> References: <20230719163446.1398961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_093500_697607_A36BF99B X-CRM114-Status: GOOD ( 16.51 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Do not parse the devicetree again when the data is already available from the IRQ subsystem. This follows the example of the ThunderX and X-Gene GPIO drivers. The ngpio check is needed to avoid a possible out-of-bounds read. Signed-off-by: Samuel Holland --- Changes in v2: - New patch for v2 drivers/gpio/gpio-sifive.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c index 6606c919d957..46a42109d6f5 100644 --- a/drivers/gpio/gpio-sifive.c +++ b/drivers/gpio/gpio-sifive.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -180,9 +179,6 @@ static const struct regmap_config sifive_gpio_regmap_config = { static int sifive_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *node = pdev->dev.of_node; - struct device_node *irq_parent; - struct irq_domain *parent; struct gpio_irq_chip *girq; struct sifive_gpio *chip; int ret, ngpio; @@ -202,24 +198,16 @@ static int sifive_gpio_probe(struct platform_device *pdev) if (IS_ERR(chip->regs)) return PTR_ERR(chip->regs); - irq_parent = of_irq_find_parent(node); - if (!irq_parent) { - dev_err(dev, "no IRQ parent node\n"); - return -ENODEV; - } - parent = irq_find_host(irq_parent); - of_node_put(irq_parent); - if (!parent) { - dev_err(dev, "no IRQ parent domain\n"); - return -ENODEV; - } - for (ngpio = 0; ngpio < SIFIVE_GPIO_MAX; ngpio++) { ret = platform_get_irq_optional(pdev, ngpio); if (ret < 0) break; chip->irq_number[ngpio] = ret; } + if (!ngpio) { + dev_err(dev, "no IRQ found\n"); + return -ENODEV; + } ret = bgpio_init(&chip->gc, dev, 4, chip->base + SIFIVE_GPIO_INPUT_VAL, @@ -248,7 +236,7 @@ static int sifive_gpio_probe(struct platform_device *pdev) girq = &chip->gc.irq; gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip); girq->fwnode = dev->fwnode; - girq->parent_domain = parent; + girq->parent_domain = irq_get_irq_data(chip->irq_number[0])->domain; girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq; girq->handler = handle_bad_irq; girq->default_type = IRQ_TYPE_NONE; From patchwork Wed Jul 19 16:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13319198 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 6DD62C0015E for ; Wed, 19 Jul 2023 16:35:10 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wJVVgfWU932b95k+RSn9RToBc2xUo71DUeM2n2V+Qfg=; b=xIQvzscR0IBwP7 5y58fM/4thchCVqr3SOiNBQ8V16Cz9J8VneygwfPvnYSmhrA7zY7jBrzw0b0b80prQIyAjW200elH nZQy2oRO1WSXdG/mmcQ/p+igf9KSxw1Te5zHqZplqkkNniuKGvS/XrFtjFkGPqVJFtlsAjspCzILt aqbJINIV3JVPmwFmmRJJUY/PJ1txCDqtGVyAbyVCdOMmKfpVZwXw+VMNj07KR2Lsz1cr2p4g+18hn AURr8pGaA1ny12NAA27ofZbZO0HZaMbXVD1voOlslNoybKf2TDX2vOSG6hMHO5aZ9RwPBWFzZd3GQ yNgFAf7Z/KLCV5OBc9aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8o-0089dj-17; Wed, 19 Jul 2023 16:35:06 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMA8j-0089Xc-1I for linux-riscv@lists.infradead.org; Wed, 19 Jul 2023 16:35:02 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b8bbcfd89aso42576975ad.1 for ; Wed, 19 Jul 2023 09:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1689784494; x=1690389294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zKB5qFFhQfmSiP15ZwnXAvSg+5ghnoWFBwWWZp0+n88=; b=Fzuo/o3DY4Sh5Qgsn7fB60HWZEm8qGCWfWwgkORpj1Uwy42N1moshxGGiv1RhmQuTp VFcCfw/xlYoOkI+FAmpTbSI+DdJ3jReOTIqODtR6XdLpfN4N3VIlGaXC05aJ++w/kGpe RFfW+Knv7wWpKU6Uf+gGYkSmiI6jzgU5UOUZtFnFqL4zJwQu2KHE44WrbnPWBRsHJayd lLlQCVrl3BPnXJfJPEwUsEMXpma82wUKYiTejzT4M+7yDWyvaf7lKyBAGA2kKf1CVG7H szfCCXrfRq8DHlKaOXiAAkaAi7Wl+TDX8tVsZkev8j2LX4Eg3R9xUjcQ+V9dfZ9Vc3gT j1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689784494; x=1690389294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zKB5qFFhQfmSiP15ZwnXAvSg+5ghnoWFBwWWZp0+n88=; b=Q6oZ/uFsQq+qlg1z1Zd/Mhu28LNAdmQWrHK8yOyPSyMCNdfkMhYrfJ2oRnbIMkqx3g iuX9mauXb31e11jdZElICDRQs7Xm2uXLybJaE2dqxVZAhp7F2xnDu9xGXvf5LTFmG4JT KqQlqTS4z2I4aLKcQBm+nejtuGpLOM/85mrIr66vAqmvWmemjJA9zYUqQ822ovDQ0KDy 6ZdF+K4F1M8p1MZAYbYkA/a/SMHGTJw6z8al9aFpXmtFlSdA7WBZB1UbRnT1IIUMD94B yNFPc/aBW7+lv0l/bmpqHC/1Qcgfb+u9DxvzdHl+4g3pNo/sC+p5G5a7lEj+ZsAMgLcp VLSA== X-Gm-Message-State: ABy/qLb2R6tbG80PVcwDv3OubVTWrmtvgGS5HYlaKsQdWxOz+Nq3crGD vtD+YvMi9Ghe29bu2+4gPbZuUQ== X-Google-Smtp-Source: APBJJlEr2JhRNQslVvd4bf3YmcEKWm1LZVkXGrEjXE4E1ojG1uF3du72OmlgajKo9Nox25sMHDZYHA== X-Received: by 2002:a17:902:7589:b0:1ba:1704:89d3 with SMTP id j9-20020a170902758900b001ba170489d3mr14046930pll.54.1689784494582; Wed, 19 Jul 2023 09:34:54 -0700 (PDT) Received: from sw06.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id x6-20020a1709027c0600b001b0358848b0sm4199276pll.161.2023.07.19.09.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 09:34:54 -0700 (PDT) From: Samuel Holland To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: Emil Renner Berthing , Rob Herring , Frank Rowand , Samuel Holland , Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v2 4/4] gpio: sifive: Allow building the driver as a module Date: Wed, 19 Jul 2023 09:34:45 -0700 Message-Id: <20230719163446.1398961-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230719163446.1398961-1-samuel.holland@sifive.com> References: <20230719163446.1398961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_093501_558540_51A87608 X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This can reduce the kernel image size in multiplatform configurations. Acked-by: Palmer Dabbelt Signed-off-by: Samuel Holland Reviewed-by: Andy Shevchenko --- Changes in v2: - Add MODULE_AUTHOR and MODULE_DESCRIPTION drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-sifive.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index e382dfebad7c..1a8e8a8c85d6 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -564,7 +564,7 @@ config GPIO_SAMA5D2_PIOBU maintain their value during backup/self-refresh. config GPIO_SIFIVE - bool "SiFive GPIO support" + tristate "SiFive GPIO support" depends on OF_GPIO select IRQ_DOMAIN_HIERARCHY select GPIO_GENERIC diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c index 46a42109d6f5..eacd67982de0 100644 --- a/drivers/gpio/gpio-sifive.c +++ b/drivers/gpio/gpio-sifive.c @@ -258,4 +258,8 @@ static struct platform_driver sifive_gpio_driver = { .of_match_table = sifive_gpio_match, }, }; -builtin_platform_driver(sifive_gpio_driver) +module_platform_driver(sifive_gpio_driver) + +MODULE_AUTHOR("Yash Shah "); +MODULE_DESCRIPTION("SiFive GPIO driver"); +MODULE_LICENSE("GPL");