Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8497933rwp; Wed, 19 Jul 2023 10:36:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXvZhc8FtSDkz4a6ShY4ZspeKWwtiW3yoIur+mCiVDIi8SbW53+xZlkSFiOdkRqa5+gwCj X-Received: by 2002:a05:6a20:7291:b0:125:3445:8af0 with SMTP id o17-20020a056a20729100b0012534458af0mr3768928pzk.7.1689788191786; Wed, 19 Jul 2023 10:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689788191; cv=none; d=google.com; s=arc-20160816; b=lmmY2qHXdLG87L/QyiYFqY5n3md4Cs3nZEu0803XfxOk0cF/KzpqhxdETZ9u5SUEBd St9vI8gQY5YxZrU+KEp2aoT6+JKnp+BO4jINZDYHIGBMNt0/WQ/CD7lYkxkzuq/pNl2o m3+dOw6NureYilkMqr5v4kULS3gvynM31aPKY0eiJi+i4YQM7PEAlJ3McfZDeSOn47oy JE35JvW0MU1Ahmx9aHS5RLuyy+0xNgTqwptIqMSvI3+mveq76aMw6QJ5DzyKIuD8zmtt M12ZR4OmdhGle0nxK9YyygCqyBbNmuEvFEgQIqrPQJAoK8xWuvZh/XvuN3RMPQaK7IpQ gnEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WY7X996NeRiPR/Rn6FoiwTLGW7DQeNpFoBjkmVc9GgI=; fh=7Iv+nmknwq0vzuxY/p9xeluMk1WnPOovtl66aotocHY=; b=G4dE4KQKjoLl28hGVmz4ZYDaxx3ZitUwoa7a5pCE6/yr03cV9nqP0HVB87AYPrFJVc KGO6eym9oGdJZvhDivg7IVGtf64NaQ228VpHhnxB/LRXpTAghCHHLypXbpeDs1lMTRKi QBULrCXjdveVKnN8B+wn8pwk5Krd9dqC2Fyac+SomPun2QTlml8Pl31G9m22X1gV5peq UAlqYgnNV6RnODH2As/HPPBKEYpx5Pzr4PysaYnKBlnC5dbEu7gqN9mL9OW+jPJONjK9 DMvl3NAjudQhxCOhqlkSs5K1nkQphagMNqZY9RnqHmzRxI5L40XzhNd5eQq/W9DySBoT 2Xkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Or+/RZwQ"; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s186-20020a6377c3000000b0055c85062a70si3908438pgc.307.2023.07.19.10.36.18; Wed, 19 Jul 2023 10:36:31 -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=@sifive.com header.s=google header.b="Or+/RZwQ"; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjGSQfA (ORCPT + 99 others); Wed, 19 Jul 2023 12:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjGSQew (ORCPT ); Wed, 19 Jul 2023 12:34:52 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C601BB for ; Wed, 19 Jul 2023 09:34:51 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1b8a8154f9cso7284265ad.1 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=UHr5KDW1ZlxPR8mErL7q2qCin4JSar1ZmveNYFK75xBNsJFaa0Tx/LXSPiyAmBKjb8 fOFNz0iBPqYMj6qDfb01gHAY8wswMWK93hgxnt0JzyUR1tEenvULMktkkjO3iabBpkLG nQO+7pGocWsu8Y41hH8yirt1W5cOWgTAmiMiA7ezuPBXiVr56ucMWx9tGeFxkPZdIRuj RAWrYJTj0Rcy5bPPQtXbPAt9iQziqTKekdN2xsn+gu/mgGJWSjM2iPtn2/NpNe6YgnA4 UamoLsM6UsPGSmnHCOZz7FE07/rL6Y5JBwcIm4ifwlK9sAMc5Yu0YObkHvzx/AVriHtd DIYA== X-Gm-Message-State: ABy/qLbWlXi1OqHvlK093kRBjX62s+ywAaOQLJTczKUg+3/pbdwZeZCW WzmSibxeBRTgeUVxh2raKRr6Kg== 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 Content-Transfer-Encoding: 8bit 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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, -- 2.40.1