Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp788752ybe; Thu, 19 Sep 2019 03:57:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTGWR1kjZodJv1VIkdo5jKWQ5wMkJlhz51GkRwvFUIrQiOxUh4HYW8IOVNIQGUZ904lcgs X-Received: by 2002:a50:f04e:: with SMTP id u14mr15393217edl.247.1568890625176; Thu, 19 Sep 2019 03:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568890625; cv=none; d=google.com; s=arc-20160816; b=wx7F1YOn7IeTTX16XvhnYP/HC0252d7M+7KGzgclILpWVngVa51+gVwy3BeCpssPFk mw9hp8dWWdU2axmVkuHVUZxPinotcfWzKX2BH98kkemqY2XJWkPVl52RDKc+1MAAB0Yo rsMD1IewEPQUfelxX6xZghgXuZnjjWcdlUxljV5ozlZZbaCPLRVXyierGM06AW5kqek3 +K4B9/TJgD4cPPuItnqia1iJiE86JnjlMkmnhEuAoRt6xdLlhKMzZY651ixz/RWOEMS1 ZHzXAU7/Pa7AurbjKSB0yp0t4n8f+sz59q4AIC5CR9XwwRivuNiu4bvG8RWaVW5fzQ2u 8OBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=jx4raJYNbxyNxb1JvnmJHKjvaUjSefRXgg0gEUX/neU=; b=B7JB5AKkmQojvYctA8A0zksAFR6/YGQZ6k5W0SI3eK+F8hP1Qr/VFUGd6wxsmeZB5l XKaNCMKBnLXWeKfoPHMeEYOMImzp0Yr2p9Ej7nDaQC7+GYWkW4CAUJagndz8f/rrHWWD OXGNl8Gg4KLoy8X/jFv/LWic2YZlH5F1rdXVvC9pLlwIB6ex4EQ/M8UMCMrPaSY7CwcE LlTHf3NMQR7PW0u4FPWuexzLsVmI4DQ3b9N82YcE7uEX3FRzDMBSY5tjfahc/1M5VpSX lx+Qh5imnaPfdKDZdTAjG4vJevvSPM97z3GSDlwFWQzOnjz9bm2xiMxNxGBvvLF6VyvG b5Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q28si4746485eda.322.2019.09.19.03.56.41; Thu, 19 Sep 2019 03:57:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388858AbfISJkj (ORCPT + 99 others); Thu, 19 Sep 2019 05:40:39 -0400 Received: from inva020.nxp.com ([92.121.34.13]:56704 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388084AbfISJki (ORCPT ); Thu, 19 Sep 2019 05:40:38 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 74DB11A00E7; Thu, 19 Sep 2019 11:40:36 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id AB9CB1A02DD; Thu, 19 Sep 2019 11:40:33 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E5F60402D0; Thu, 19 Sep 2019 17:40:29 +0800 (SGT) From: Anson Huang To: linus.walleij@linaro.org, bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH V2] gpio: mxc: Only getting second IRQ when there is more than one IRQ Date: Thu, 19 Sep 2019 17:39:17 +0800 Message-Id: <1568885957-2968-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some of i.MX SoCs like i.MX8QXP, there is ONLY one IRQ for each GPIO bank, so it is better to check the IRQ count before getting second IRQ to avoid below error message during probe: [ 1.070908] gpio-mxc 5d080000.gpio: IRQ index 1 not found [ 1.077420] gpio-mxc 5d090000.gpio: IRQ index 1 not found [ 1.083766] gpio-mxc 5d0a0000.gpio: IRQ index 1 not found [ 1.090122] gpio-mxc 5d0b0000.gpio: IRQ index 1 not found [ 1.096470] gpio-mxc 5d0c0000.gpio: IRQ index 1 not found [ 1.102804] gpio-mxc 5d0d0000.gpio: IRQ index 1 not found [ 1.109144] gpio-mxc 5d0e0000.gpio: IRQ index 1 not found [ 1.115475] gpio-mxc 5d0f0000.gpio: IRQ index 1 not found Signed-off-by: Anson Huang --- Changes since V1: - use local variable irq_count instead or err to avoid confusion. --- drivers/gpio/gpio-mxc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 7907a87..c77d474 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -411,6 +411,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct mxc_gpio_port *port; + int irq_count; int irq_base; int err; @@ -426,9 +427,15 @@ static int mxc_gpio_probe(struct platform_device *pdev) if (IS_ERR(port->base)) return PTR_ERR(port->base); - port->irq_high = platform_get_irq(pdev, 1); - if (port->irq_high < 0) - port->irq_high = 0; + irq_count = platform_irq_count(pdev); + if (irq_count < 0) + return irq_count; + + if (irq_count > 1) { + port->irq_high = platform_get_irq(pdev, 1); + if (port->irq_high < 0) + port->irq_high = 0; + } port->irq = platform_get_irq(pdev, 0); if (port->irq < 0) -- 2.7.4