From patchwork Sun Jul 30 17:46:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 9870643 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 7CA056032A for ; Sun, 30 Jul 2017 17:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CA8A28593 for ; Sun, 30 Jul 2017 17:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61148285A0; Sun, 30 Jul 2017 17:47:18 +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=unavailable 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 E649B28593 for ; Sun, 30 Jul 2017 17:47:17 +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=zSKKTYCA3l2ixKwxf78ZjRP2l61bVgrF14SNftRattI=; b=a6c3ch1DWF4OjM Kh5zqfwHliCMCH7IaWsxfwgsTUviImFaVxHSRkZkLDtCzqQmg5SU8hJnbOMVBj5TZhSe7s1QJL9bV tSpHdqw6Dc5pZryP02KNO5gUV8ukya4+KsXJpnqf7f3F/R80dzYyq8ZocUt2c09KpMBbwHD27R2uX 1hiB2VvUNOkSs6TAIcZeRt8Zm8FuDZXs6FOHNuyl6/NFSjCFsPEKnVih+BueN3vGHL7PAEF9Nn0YC rMa7Xc6o8bgghPBW92LKKVbgm/aMQecdxe8jr4GP36OP+K/IN78Kl5y5JB/f9ovAcBl052kNzyZ6f JPTEoJvmjSCbiBCbOthg==; 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 1dbsJA-0006eD-19; Sun, 30 Jul 2017 17:47:16 +0000 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dbsIs-0006P2-BI for linux-rockchip@lists.infradead.org; Sun, 30 Jul 2017 17:47:00 +0000 Received: by mail-lf0-x22f.google.com with SMTP id t128so76308994lff.2 for ; Sun, 30 Jul 2017 10:46:35 -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=SOXh7yIMXsbv9fsM0Xi+kp92Yt9TZmrf9TsIBri/7p4=; b=shNxxyE/kuuZlpiTaevh6Mro5JOTee91seD4+ttjIVSXU28V3eu5x1tnYc0Vg1icXz 5d0zTJE44MpIfXzV5zDE5lM/5zb1umLfYzKXSH3AjKCxxxemAlLte2oVAnZ6/ZRZ2qvf +G++u4fcowa2E/uSTTD0JUJTp2OE+wH/hPUmChKzSzgGQeLbhZ9izQ/avvJRuKsrB16J XT5jWsJGLIFjokeSdPWhHAuwRMsebUQYcvYVtmBLRueZvGOjXgFvjNJZv4LA3peGV/h6 yyy7UmxdQpiv7GPwip3658paUo77BgLTHx09jtZ25kRuIVJ3ZU1rEEy2kgrGx3GqNV5z bqDw== 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=SOXh7yIMXsbv9fsM0Xi+kp92Yt9TZmrf9TsIBri/7p4=; b=NiYX0BRXmwH0bQ138F5tnw7N1RkbVtyrmtT80LJfChdJHgGczKg9f2H6/Ug92Vq9nN ZAQWzwcHLueO4zkECPrpIIaJfzQdTTQ/k6ElHzAK8+WVyIqNeFvzyJjd9K/5wKg6MPq5 Ly199X89GMBYJWlmV5wQShljKeDMaA+44sE8X3Sxu7vOjZAppy/fPdh5fTd8hbcOgME9 dvigEQsUg/YOlKx7P53gjHUsOKFOxYEhuEVu9UCQsNqiYCZpm9SYru9ptHk3DPh4/H+X CZiPq/uFIGfjpXXw2VjBlPjTOxj6lSPPwuFiqO85JbrMKdiIJg/8ybdQaEPXS7fbHVnF X5qQ== X-Gm-Message-State: AIVw111G1ZyQb4n8oW3rY04E26YpP94mXu0Pa3NP+nZ5h0MWh7Xm9xDI +LGM5yaGWruyExIr X-Received: by 10.46.33.168 with SMTP id h40mr5322438lji.30.1501436794150; Sun, 30 Jul 2017 10:46:34 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.85.243]) by smtp.gmail.com with ESMTPSA id d203sm5029103lfg.59.2017.07.30.10.46.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jul 2017 10:46:33 -0700 (PDT) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Sun, 30 Jul 2017 20:46:30 +0300 Message-Id: <20170730174630.481994041@cogentembedded.com> User-Agent: quilt/0.64 Date: Sun, 30 Jul 2017 20:46:23 +0300 To: Kishon Vijay Abraham I , Heiko Stuebner , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH] phy: rockchip-inno-usb2: fix of_irq_get_byname() error checks MIME-Version: 1.0 Content-Disposition: inline; filename=phy-rockchip-inno-usb2-fix-of_irq_get_byname-error-checks.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170730_104658_796157_16BF2879 X-CRM114-Status: GOOD ( 10.36 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergei Shtylyov Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP of_irq_get_byname() may return 0 as well as negative error number on failure, while the driver only checks for the negative values. The driver would then call devm_request_threaded_irq() for IRQ0 and thus never get the valid interrupts. Check for IRQ <= 0 instead and return -ENXIO iff it's 0 from rockchip_usb2phy_{host|otg}_port_init(), and thus fail the driver's probe. Fixes: 0e08d2a727e6 ("phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy") Fixes: 98898f3bc83c ("phy: rockchip-inno-usb2: support otg-port for rk3399") Signed-off-by: Sergei Shtylyov --- The patch is against the 'fixes' branch of Kishon's 'linux-phy.git' repo. drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux-phy/drivers/phy/rockchip/phy-rockchip-inno-usb2.c =================================================================== --- linux-phy.orig/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ linux-phy/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -925,9 +925,9 @@ static int rockchip_usb2phy_host_port_in INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work); rport->ls_irq = of_irq_get_byname(child_np, "linestate"); - if (rport->ls_irq < 0) { + if (rport->ls_irq <= 0) { dev_err(rphy->dev, "no linestate irq provided\n"); - return rport->ls_irq; + return rport->ls_irq ?: -ENXIO; } ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL, @@ -988,9 +988,9 @@ static int rockchip_usb2phy_otg_port_ini of_property_read_bool(child_np, "rockchip,utmi-avalid"); rport->bvalid_irq = of_irq_get_byname(child_np, "otg-bvalid"); - if (rport->bvalid_irq < 0) { + if (rport->bvalid_irq <= 0) { dev_err(rphy->dev, "no vbus valid irq provided\n"); - ret = rport->bvalid_irq; + ret = rport->bvalid_irq ?: -ENXIO; goto out; }