From patchwork Sun Apr 8 21:27:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10328621 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 344F06053B for ; Sun, 8 Apr 2018 21:28:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237FA287A6 for ; Sun, 8 Apr 2018 21:28:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1662928807; Sun, 8 Apr 2018 21:28:37 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 973A8287A6 for ; Sun, 8 Apr 2018 21:28:36 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LsDxI8HJXczr1ItlFM0FsnzvzL49B9pXK0H91qllfAc=; b=gvFtUt06VolQoVa1UU5mlxvNon 0nSX4wYAVtJ+P/5W9ixH4TKoyejw912xpMf4xFDBHbC7Sy1tkO8Fzh5b29xuaOYN6ugg8AA3Mk/C6 zvWA3ULd8n0LVO/dbWQEeUj2H2eHTJbakjevUOmv7LtS4AXobaqNutSXGZGm8wnx1kOIB2NiSFvd3 nGNIuu2gBQwuHLn7/pnAPYu1DzF8PlKOAEz6c6R/TFrbURl+yujZ2dPx6Ax8WcT9pvQqpXc+HHksb AXUAguSQAXq7DnuvBoZ0Xn8F6IEZXJTZSlshw2E1YoBOMgEf+/hdtElEgVlgqXICOBV8kDSUHWjrY MxJcM8Eg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5HrV-0006Ht-OA; Sun, 08 Apr 2018 21:28:33 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5HrA-0005yr-8h; Sun, 08 Apr 2018 21:28:14 +0000 Received: by mail-wr0-x241.google.com with SMTP id d19so2906549wre.1; Sun, 08 Apr 2018 14:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZuEbBcOqud9+K0+H1xHXobWt6HY2p39yMwmD2yUjg1Q=; b=Ad4OZf/+t0l+DTWxEaRWcD4qHD6VqVXiaAJlrEclJx3NmCgrFhIsI5yovLa/OOhIKc ZHE1iDiVi51ilDNj+AG6InG7P6coMTSei+AgJi+VmXVNhHs2jNdBqphZDrChOKLCfW/B PzP9hr22TpnFNhTNuTh2mOnw16lr5tpa08C4SqntZc8Vt43s1eDfoMKtpe3sGIKKW747 zL96B66w7Qp650zRZ4/2utY2elTlf8E1ZJG7YlyYB9dsHDLZagZJZMAW/MOmaVjjFGeO XFH/+nx3GaYkOIi+8MuGedW3P+6lmc79BhmrfynKBjOSnQ8Vmzn8YCRD/cJnpdu091p2 Sjiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZuEbBcOqud9+K0+H1xHXobWt6HY2p39yMwmD2yUjg1Q=; b=KnHZgwOE6WJDVUvvD2kYNynTADovJh3GNmDnPI4UeAlyVc0oEkpn/RW3lLyyT0buO4 +zhJapCMbVrXh3XVnl6pr/QG/7Bdrak1gr2TAoyJoNKdMTL9rPk7Oc9O6ttuoXWqel7N Oy4ikBJhbwN5w3U+85VVNbCmHrCBprGjctkhdVzNAbIy4H2+rsqGBXFIdlaD3o0yYI9P mGw1Y18NytZlVDr+0ASgB/Q+l068Rli6uFRV0jivlN9dFnYtludRrhXKoq0M0uUlqn6e IFUvT6b85i2k7aYrnjtvS41n2BXqxW1lNrTmenzhKx78f81le/qpvXdrvlSy44DtsRGO evFg== X-Gm-Message-State: AElRT7GTSi6+Z15aHzvWh8ECX/Wm+z0sIPrjKoxYMoJtgd4D4n2P4tPU 0Ofu6DxZVKCQy9Tb1fPWg0o= X-Google-Smtp-Source: AIpwx4/Ak7C31Xx9/JT+CLLIEyFhlpc54nGeMzzOzhPICBSNuDFKgiusFXY2qgMthXUMRX7vdZLJAQ== X-Received: by 10.223.130.102 with SMTP id 93mr21919502wrb.97.1523222881758; Sun, 08 Apr 2018 14:28:01 -0700 (PDT) Received: from blackbox.darklights.net (p5B056562.dip0.t-ipconnect.de. [91.5.101.98]) by smtp.googlemail.com with ESMTPSA id j21sm18476370wrb.49.2018.04.08.14.28.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 14:28:01 -0700 (PDT) From: Martin Blumenstingl To: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH usb v5 4/6] usb: core: phy: make it a no-op if CONFIG_GENERIC_PHY is disabled Date: Sun, 8 Apr 2018 23:27:41 +0200 Message-Id: <20180408212743.22934-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180408212743.22934-1-martin.blumenstingl@googlemail.com> References: <20180408212743.22934-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180408_142812_348472_23E8D9A3 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: d-gerlach@ti.com, eric@anholt.net, j-keerthy@ti.com, stern@rowland.harvard.edu, chunfeng.yun@mediatek.com, yamada.masahiro@socionext.com, linux-mediatek@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, matthias.bgg@gmail.com, linux-amlogic@lists.infradead.org, kishon@ti.com, Martin Blumenstingl , rogerq@ti.com MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the generic PHY support is disabled the stub of devm_of_phy_get_by_index returns ENOSYS. This corner case isn't handled properly by usb_phy_roothub_add_phy and at least breaks USB support on Raspberry Pi (bcm2835_defconfig): dwc2 20980000.usb: dwc2_hcd_init() FAILED, returning -38 dwc2: probe of 20980000.usb failed with error -38 Let usb_phy_roothub_alloc() return in case CONFIG_GENERIC_PHY is disabled to fix this issue (compilers might even be smart enough to optimize away most of the code within usb_phy_roothub_alloc and usb_phy_roothub_add_phy if CONFIG_GENERIC_PHY is disabled). All existing usb_phy_roothub_* functions are already NULL-safe, so no special handling is required there. Fixes: 07dbff0ddbd8 ("usb: core: add a wrapper for the USB PHYs on the HCD") Reported-by: Stefan Wahren Signed-off-by: Martin Blumenstingl --- drivers/usb/core/phy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index a39d9bb26a4f..9879767452a2 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -50,6 +50,9 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev) struct usb_phy_roothub *phy_roothub; int i, num_phys, err; + if (!IS_ENABLED(CONFIG_GENERIC_PHY)) + return NULL; + num_phys = of_count_phandle_with_args(dev->of_node, "phys", "#phy-cells"); if (num_phys <= 0)