From patchwork Sun Jul 30 19:38:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 9870657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F87160353 for ; Sun, 30 Jul 2017 19:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5543128503 for ; Sun, 30 Jul 2017 19:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47A0D28545; Sun, 30 Jul 2017 19:40:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ABFB228503 for ; Sun, 30 Jul 2017 19:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Subject:To:Date:Message-Id :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Q51QK7aJbkth7j7KQbmq18bV1x5aVWqcexLM+1zPyXU=; b=NQBBqmCpnGtjfQ jEp/dehAdD80L80sQAWn0WABhJbVpX4cwHQb0uwUsAoiX3N9dF5e3feBQCB94BjMQEAwGrk5msX2a MN7OhXdbS27OFx3GIMgWvHUfhDtFZgMz4Iz4Re6RIj4IjrK6NmE70vTqzEpv33NFNdqGWOuk+vr1i 8nefFQ5PVQnAvj9TJeks2FapDLUyi+0GbwhNKDHWT+kq+UCvhX7o+vFjFN3EA8vvU1IGBzoXrSJwK 65hDipPDKkoyO5iMERrVdRSVk0krh6veNr/7r/Vhida/DmejDFptbG8QYn+k80SQENUoqNiQapK3H ghO97mb3ietcyWeP4FMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dbu3i-00067v-JQ; Sun, 30 Jul 2017 19:39:26 +0000 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dbu3e-00066Y-U2 for linux-arm-kernel@lists.infradead.org; Sun, 30 Jul 2017 19:39:24 +0000 Received: by mail-lf0-x22a.google.com with SMTP id o85so47212281lff.3 for ; Sun, 30 Jul 2017 12:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=0sOA4MHry0SSgKaezwTIhxVeofFOFRceFfS+7lGnrQs=; b=0hbj2ATygmED0YrkQgpLF9yEV3QPFo8EpcKDWqXfXqd9IQJzWHtI6pNnkqlyffmLjp NlVO2EbgSkZEleW4Pfpj78AOMRiy85fp23R2iwPwh7595UmXzd3zW6gAs9FH5GEOC3cZ DYfk+YNwsskkX6kjs3XymQdVTWBNBi2IDBPE7BdkavcV3dGdxRvUASBnw+yokX0GkyJq JBnWCVK4kfFP6BdZ9jGOyGJXleoQOG02OZu3eYLMLURBDE63zPuLZ64FmsjrwQMAK5Qv YZPV6DT+oEplJJpX+1PdrLzGUr1zOjGZHik/EY81iYHhQX+wh0wYj35Auj9Cqw/4iUsi ILFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=0sOA4MHry0SSgKaezwTIhxVeofFOFRceFfS+7lGnrQs=; b=MTaq1aG87vdR5SLva6UScRriCieKJHcYCKey9iDGFpGAZNM+/Lkyx6hkjRGGsSDKX6 kPsDuJSWY179HXW3w1gWIhLcXsR+2sRZJNc082EPqEirq/ENcB5/CES/PjZSuZstW/fc aknIVMx95OBbfof2yibWAi8TAyV3ZTrEKnX3KOsF6wprrE9Z44td9FYDntfsNY2q2tEO uVQQYbIJANgy5z24yJV3IU+If2POZTc7k9XleKwrspa8i+P14xPCfRGvN8Q+ZqXpGC5/ nkcNB/kLLraxBNKVYni0+Xdqgb+eiKFyrEqrcUNwLjfQtQjijb5T06NHaZUxTDyGZPJu CUWQ== X-Gm-Message-State: AIVw110IB8mL0tYr4ivKdpP45L4WtLeipJmTInSUychYbZ7IstvlcT4j E3fQxTtWo3wYCWTo X-Received: by 10.46.83.71 with SMTP id t7mr3861532ljd.118.1501443539695; Sun, 30 Jul 2017 12:38:59 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.85.243]) by smtp.gmail.com with ESMTPSA id s133sm3336420lfs.4.2017.07.30.12.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jul 2017 12:38:58 -0700 (PDT) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Sun, 30 Jul 2017 22:38:55 +0300 Message-Id: <20170730193855.099325987@cogentembedded.com> User-Agent: quilt/0.64 Date: Sun, 30 Jul 2017 22:38:48 +0300 To: Linus Walleij , Barry Song , linux-gpio@vger.kernel.org Subject: [PATCH] pinctrl: sirf: atlas7: fix of_irq_get() error check MIME-Version: 1.0 Content-Disposition: inline; filename=pinctrl-sirf-atlas7-fix-of_irq_get-error-check.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170730_123923_332662_ADB8738D X-CRM114-Status: GOOD ( 11.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP of_irq_get() may return any negative error number as well as 0 on failure, while the driver only checks for -EPROBE_DEFER, blithely continuing with the call to gpiochip_set_chained_irqchip() -- that function expects the parent IRQ as *unsigned int*, so would probably do nothing when a large IRQ number resulting from a conversion of a negative error number is passed to it, however passing 0 would probably work but the driver won't receive valid GPIO bank interrupts. Check for 'ret <= 0' instead and return -ENXIO from the driver's probe iff of_irq_get() returned 0. Fixes: f9367793293d ("pinctrl: sirf: add sirf atlas7 pinctrl and gpio support") Signed-off-by: Sergei Shtylyov --- The patch is against the 'fixes' branch of Linus W.'s 'linux-pinctrl.git' repo. drivers/pinctrl/sirf/pinctrl-atlas7.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: linux-pinctrl/drivers/pinctrl/sirf/pinctrl-atlas7.c =================================================================== --- linux-pinctrl.orig/drivers/pinctrl/sirf/pinctrl-atlas7.c +++ linux-pinctrl/drivers/pinctrl/sirf/pinctrl-atlas7.c @@ -6081,9 +6081,11 @@ static int atlas7_gpio_probe(struct plat /* Get interrupt number from DTS */ ret = of_irq_get(np, idx); - if (ret == -EPROBE_DEFER) { + if (ret <= 0) { dev_err(&pdev->dev, "Unable to find IRQ number. ret=%d\n", ret); + if (!ret) + ret = -ENXIO; goto failed; } bank->irq = ret;