From patchwork Wed Apr 18 19:39:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10348833 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 338F360244 for ; Wed, 18 Apr 2018 19:40:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23CE228831 for ; Wed, 18 Apr 2018 19:40:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17CC628837; Wed, 18 Apr 2018 19:40:22 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9482528831 for ; Wed, 18 Apr 2018 19:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752700AbeDRTkT (ORCPT ); Wed, 18 Apr 2018 15:40:19 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33705 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbeDRTkR (ORCPT ); Wed, 18 Apr 2018 15:40:17 -0400 Received: by mail-wr0-f193.google.com with SMTP id z73-v6so7874224wrb.0 for ; Wed, 18 Apr 2018 12:40:16 -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=XoMeu8//3qpkxOScuN9rY7hLa0OaaHCIgz8ppnKbolGeo2qLse0aO6Xp4fedUpmVhM I2k+sg750NAH+UouYqwWUZevlDhgaSoZMeX3ubV1+KYJFHtzYIdeIyh1MIe9BL4svTMX /TNAqaCTggbNFXRwUg55v9k982gQXDn+ojk+wiFxIe4v+QLDTdn4DOBJYuiLDWK+St5E eP4d3MT4UFWTw358/QG2LEzyInE4cd762JmUq2RqhRVNgSfxUY0g308aufv5pAEmXgBW BQoY7ZpLoGFcW/zMl7o5GROucEPCdWk6SP0wmo6FUuloNCNfeHM/Zg35Elpo7y5Bf+iG NOBw== 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=HyMV6Ax27cDiTYZ1aPIGV8iGk+BeL+heWY1SBNVPpBJ+ZqeKv2W0Wbn0Ey61kY1Aet FzACd8qOIgNrqBacjlpGH9dwbAP3nB1w1dGHoCvmafvOGrrsUK0Ojgpr7ckBll9CqJgw +kt+5bu7AxXUM4x+PMUOh5aPfgcmWeW0lLA93ALMCSbeYkJDEOjJ3v0dH0QfhGJlZp9d +LaxIDHng6wvZEdAmZefBtRvcekaEIM94Tgb5a5xJMmldV8MGha1yzqgoRITGcXU6non ExeGh9fYzUhznq15M20UlgNVjqdsmKDZ2n/FwDDbYEAAyMzRV/Kk3R3Dc1YXnZnim4/F sQSQ== X-Gm-Message-State: ALQs6tCcnU7eh90n1wMAHDkezUC0y0ZiTNxCKqTm+8dUm5k4aevopNF7 WNR5ANFrIE+za85N0JxazXgeGCz7 X-Google-Smtp-Source: AIpwx48GIuUUXzbrA/E2G53ugSlrSMplSlgYfe0ZUsdDRyIbjt9JeuaU1SJ0pc8GfASg54+moF35IA== X-Received: by 2002:adf:c682:: with SMTP id j2-v6mr2490178wrg.135.1524080415577; Wed, 18 Apr 2018 12:40:15 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD743A504F9143C002217B8ED.dip0.t-ipconnect.de. [2003:dc:d743:a504:f914:3c00:2217:b8ed]) by smtp.googlemail.com with ESMTPSA id 60-v6sm1871990wrj.62.2018.04.18.12.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 12:40:14 -0700 (PDT) From: Martin Blumenstingl To: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org Cc: matthias.bgg@gmail.com, stern@rowland.harvard.edu, rogerq@ti.com, linux-mediatek@lists.infradead.org, linux-amlogic@lists.infradead.org, j-keerthy@ti.com, d-gerlach@ti.com, kishon@ti.com, chunfeng.yun@mediatek.com, linux-rpi-kernel@lists.infradead.org, eric@anholt.net, yamada.masahiro@socionext.com, Martin Blumenstingl Subject: [PATCH usb v6 4/6] usb: core: phy: make it a no-op if CONFIG_GENERIC_PHY is disabled Date: Wed, 18 Apr 2018 21:39:49 +0200 Message-Id: <20180418193951.17922-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180418193951.17922-1-martin.blumenstingl@googlemail.com> References: <20180418193951.17922-1-martin.blumenstingl@googlemail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.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)