From patchwork Fri Dec 11 21:19:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 11969561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84770C433FE for ; Fri, 11 Dec 2020 22:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4309A23A33 for ; Fri, 11 Dec 2020 22:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395505AbgLKVTN (ORCPT ); Fri, 11 Dec 2020 16:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405690AbgLKVSy (ORCPT ); Fri, 11 Dec 2020 16:18:54 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E409C061794 for ; Fri, 11 Dec 2020 13:18:13 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id y19so15187445lfa.13 for ; Fri, 11 Dec 2020 13:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f4jyCtqfsT6bFiaWz4C37nQaMqaYNh8RgdovwPFEFag=; b=L3C22yj6e7mZ1ae57EoqyLDdn2C7A5WvAmk6sNlRZpg6sSQUZHSCL8MDBYRH6RamIL 9keusa18auHJbx1LOkaR/b2OUBPql7KMG/JZoaRdLcwZtOzSnvAZc1mAMaF736/50DcK C/3iRmO1bgVi5fvLa8QvITGzz+u7Mw1bIcTyx35XZgivj2DtZM7t2NLOi9brMjl/Prk8 3vzl2qVg2x1voOpXo157jfVsnC0BhUZEV4T5sRqJCu1T49fx1r5WImUlTjShqpYJuL+V in9ZR9GOy/E0fQfIf5E1y446bJ6PffMqN9Ln65O0/zkDYghex69Ee5CzJeiQQ29cdax4 6lTQ== 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:mime-version:content-transfer-encoding; bh=f4jyCtqfsT6bFiaWz4C37nQaMqaYNh8RgdovwPFEFag=; b=olmI/k+PvxNVMOj+LxW3HfcY5cZZskaROcAoEluPRtBW2C/XHN8C/GiQa6Hi3qlL8O 9wvsu9bgqteQgL4IuB/kh8XoKIO2rSKLA4hjG9SJjdGBA2ZhV0K1om1ppiO4wBAFOpms xeYV8bKfcCpbzHnF5E3UOUIpP02x58LWN8pu0gA5eLxPu6bsBXyHUXDwMi/yRENOq92W SCa61LBHdXDKKQXZmqFTGkTWo3i0aOrxZb5FuXDS8WdKmt2aRicxumit7pNewCED/+ja 0QXqz+6S+fPrS466KR6mAXGNwqpXqRfCbSkKRTh/CGfu3GC1LDf4VsYqVEzwOphOI/bi WzuA== X-Gm-Message-State: AOAM531BSgSbypVHOk4A8lUVg+is40XzNRPM/KQ91XHJuFDE5pal3E3O rPTonOw3zDj0SliUYpzSpWmw8iSyPlYeJpMbrV4= X-Google-Smtp-Source: ABdhPJyRxtky3At4bdPpe8TSi8A5QyQyiqt6v8+Uu//6gJ5iv2ZUBFFXIOtHkhC7C8FtiMgLMeG/Mg== X-Received: by 2002:a19:8c13:: with SMTP id o19mr5397732lfd.573.1607721491314; Fri, 11 Dec 2020 13:18:11 -0800 (PST) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id z26sm808501lja.125.2020.12.11.13.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 13:18:10 -0800 (PST) From: Sam Protsenko To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , John Stultz , Andy Shevchenko Subject: [PATCH v3 1/2] usb: dwc3: drd: Avoid error when extcon is missing Date: Fri, 11 Dec 2020 23:19:15 +0200 Message-Id: <20201211211916.6259-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211211916.6259-1-semen.protsenko@linaro.org> References: <20201211211916.6259-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If "port" node is missing in PHY controller node, dwc3_get_extcon() isn't able to find extcon device. This is perfectly fine in case when "usb-role-switch" or OTG is used, but next misleading error message is printed in that case, from of_graph_get_remote_node(): OF: graph: no port node found in /phy@1234abcd Avoid printing that message by checking if port node exists in PHY node before calling of_graph_get_remote_node(). Signed-off-by: Sam Protsenko Cc: Andy Shevchenko Reviewed-by: Andy Shevchenko --- Changes in v3: - Split patch into two patches: logic diff and style diff drivers/usb/dwc3/drd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 3e1c1aacf002..312a4d060e80 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -463,7 +463,10 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) } np_phy = of_parse_phandle(dev->of_node, "phys", 0); - np_conn = of_graph_get_remote_node(np_phy, -1, -1); + if (of_graph_is_present(np_phy)) + np_conn = of_graph_get_remote_node(np_phy, -1, -1); + else + np_conn = NULL; if (np_conn) edev = extcon_find_edev_by_node(np_conn); From patchwork Fri Dec 11 21:19:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 11969579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61193C433FE for ; Fri, 11 Dec 2020 22:30:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3042123A33 for ; Fri, 11 Dec 2020 22:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405882AbgLKVTw (ORCPT ); Fri, 11 Dec 2020 16:19:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395504AbgLKVTN (ORCPT ); Fri, 11 Dec 2020 16:19:13 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6394C0617A6 for ; Fri, 11 Dec 2020 13:18:14 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id y19so15187531lfa.13 for ; Fri, 11 Dec 2020 13:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=orV6Jiq3kXB0bcDgP4wZM6ASqt9ALseXlLi8MU8P7Ns=; b=Y/Sb4BbQENjqsYlg1fDVvuON5YE+C4L3JZGFp1VhKJkJjAeDP0tezXoP49VoxIsmLZ DrlCyH1yE+w1cfnsNG0PpnmwkIrPegtOCAy7zlnQ9D+17sdPJ/x1Ed1LQy0UncQV6LXO 3ZtWXbXDho2IQG+gr9MkG8PGe+oH2rOEOExWl0bgRd6yA1g4jm1VYJJt3/3mHMSLdLNw in+HIWdSQx4MxjXqBclslBFEW0kGjLFkqoBHjY76G6kdZOZOtJQNa6i26eA3gT/bWxrm rvP65YF8jRpa4y1i92b6F4Q9O7ISNwN8zLScKxppeyWPU6xmAoCOwIy60OjtqqcQ0HgY L2Sw== 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:mime-version:content-transfer-encoding; bh=orV6Jiq3kXB0bcDgP4wZM6ASqt9ALseXlLi8MU8P7Ns=; b=EzBmBVCNGTNCloBiZOvzIJVJ0lM14uPQzp+XtkiQ35Cl04lMniTWNFeNaCw7t6wUot mfiCdyq8xFedQdyjgmqrONkxE0bEo16ixGXicgkHFEt9P8Yacdi+sT7KSfPzDiDQOARb /1Kir5QcFsLx1hzrEXV/QR4DOB4j8FEl1OnHuflUQOS+hl0kjFHFQ7n0R2LIEvoYN077 jwQG05LMU8OeyEyGdXn9WWX7y0mHExIDr3DnQBH7jFER8MxBMzYnvIqWHi2UcBYsOhls uSV7EO5/T0fiNEz0oCuLPaoDEIEoC/DHhCw1gIZSur8CojIHgb3LduFfVuDcfaARfywB F1lQ== X-Gm-Message-State: AOAM532kIJhMTdl4t5O+BAvmxHk3LcNr89FhJLS6ucwQ5U0SBcwiel9l RD/PhqILADmD8WTkxi4ltKk24NWpyvlhPxA+v3Y= X-Google-Smtp-Source: ABdhPJyttESJdu/GkalVmYRVZcpwh1cHRonw6XxjwGa1UnPEd8DFWTgp2osz7o/izFoAktU+CHAKjw== X-Received: by 2002:a19:f60b:: with SMTP id x11mr5758697lfe.156.1607721492841; Fri, 11 Dec 2020 13:18:12 -0800 (PST) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id g190sm833904lfd.72.2020.12.11.13.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 13:18:12 -0800 (PST) From: Sam Protsenko To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , John Stultz , Andy Shevchenko Subject: [PATCH v3 2/2] usb: dwc3: drd: Improve dwc3_get_extcon() style Date: Fri, 11 Dec 2020 23:19:16 +0200 Message-Id: <20201211211916.6259-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211211916.6259-1-semen.protsenko@linaro.org> References: <20201211211916.6259-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Commit c73b41955ee4 ("usb: dwc3: drd: Avoid error when extcon is missing") changed the code flow in dwc3_get_extcon() function, leading to unnecessary if-branch. This patch does housekeeping by reworking the code for obtaining extcon device from the "port" node. While at it, add the comment from mentioned code block, explaining how checking the port availability helps to avoid the misleading error. Signed-off-by: Sam Protsenko Cc: Andy Shevchenko --- Changes in v3: - Split patch into two patches: logic diff and style diff drivers/usb/dwc3/drd.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 312a4d060e80..eaf389d3f3c5 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -441,8 +441,8 @@ static int dwc3_drd_notifier(struct notifier_block *nb, static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) { struct device *dev = dwc->dev; - struct device_node *np_phy, *np_conn; - struct extcon_dev *edev; + struct device_node *np_phy; + struct extcon_dev *edev = NULL; const char *name; if (device_property_read_bool(dev, "extcon")) @@ -462,18 +462,22 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } + /* + * Try to get extcon device from USB PHY controller's "port" node. + * Check if it has the "port" node first, to avoid printing the error + * message from underlying code, as it's a valid case: extcon device + * (and "port" node) may be missing in case of "usb-role-switch" or OTG + * mode. + */ np_phy = of_parse_phandle(dev->of_node, "phys", 0); - if (of_graph_is_present(np_phy)) - np_conn = of_graph_get_remote_node(np_phy, -1, -1); - else - np_conn = NULL; + if (of_graph_is_present(np_phy)) { + struct device_node *np_conn; - if (np_conn) - edev = extcon_find_edev_by_node(np_conn); - else - edev = NULL; - - of_node_put(np_conn); + np_conn = of_graph_get_remote_node(np_phy, -1, -1); + if (np_conn) + edev = extcon_find_edev_by_node(np_conn); + of_node_put(np_conn); + } of_node_put(np_phy); return edev;