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: 341981 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp919931jai; Fri, 11 Dec 2020 13:19:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjE7CUn+euLE6geteBfqvbbfL9pckD1BAbfasDFUHLZVUFDXwS10zuwHTUAUlMsOPu6ZPZ X-Received: by 2002:a17:906:fa12:: with SMTP id lo18mr13013648ejb.354.1607721584617; Fri, 11 Dec 2020 13:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607721584; cv=none; d=google.com; s=arc-20160816; b=t+yE7RlHOL/O3Qpr75QWkrjB2G7qCRbXO+Hi2DaSF0+Kqckqzg1weJYQM0ihaNgxCE pLrvdABnutzGwtSNYMhodnZfr/wqdQ3YxZ8o2rncRguGP7yOpHEAfb2kcMJL3NxGcxjc jaRNgFWkbbORxVEVl0W0+2EEkOhnUmcxwvmAPKUOIbPyjBpxXs/bd5XtdSaMbRKFRwe+ bVdo8QE381E8xt8YdaPqDMkotC399Ndnrs0vHGD5a+KdPP87oWmFTdh133p7e9I1YgwP B44VZ3BcRtNCuccW3S8GeYZOSZrmtd2+/t+qUp2FB0ZxQWOazh4pKwq1vwB4/5TfK+MU WE1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f4jyCtqfsT6bFiaWz4C37nQaMqaYNh8RgdovwPFEFag=; b=fzm+x8WnBcf6QPrweG3w8zCUeRdh6V7WX6JyyZ+EcESaf5LSU4mlXdpQjpXPwd7vZx ArRpiorG19YpOOgPxg+hSL2tpDUPiyy/ILovxz7H3ZC59Bii+TLMZj6qcuNP7+CsAqDx krqDa/uCAVQxC1XEOaTyKyTmFHP3NWLHs8nHpqUFv6/sNNNZiaxqjoSfmHnM8dUvyXJW M3wUHKpDI3gjDeHi1zmqQ8zQaL+zOVWWmfxVqiTgRTx4eeQRfVyVDZIzR8hgijhE8Y/A lzWkc3hu2vrXn5QkFvyD+E2uW1Pr3UH5RbTe4UvfcQpjESik1q82brCpa+pz6yzlxJ8F vh7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3C22yj6; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn38si5186169ejc.438.2020.12.11.13.19.44; Fri, 11 Dec 2020 13:19:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L3C22yj6; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395505AbgLKVTN (ORCPT + 4 others); 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-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 --- 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(-) -- 2.29.2 Reviewed-by: Andy Shevchenko 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: 341982 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp920320jai; Fri, 11 Dec 2020 13:20:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwb0Sisz9D/2F6h7JHBVhkGZVIlXfrKU7Jv9lgpsHv4XjSZKArbVFdPEcAgznoi1Y9M+Jp0 X-Received: by 2002:a17:906:1f44:: with SMTP id d4mr12158969ejk.368.1607721617756; Fri, 11 Dec 2020 13:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607721617; cv=none; d=google.com; s=arc-20160816; b=Hj0vAcovISSSXL+qXn3MJxUE8Z4njXgAbuDXdw8drmF7jE/omioMQta3ozpFGCzrPI l3YH2NPNQZ56fHz7kwzszkwagctGlVIqgjclpq/CZggRBev3F4g4uBkaH2EWi0OgGnZd r23NqH9uTw1ah1NVqijaoqLENLu6Ue7xVGY9aXVeFkHDopsVBYBKnDXXf+MntqAjQyUe +4O2Ngv8ktQatdW1v/cvByIiSQ8L6NVTrPui1ikr0Uwo/EYapeBVNkAoL2+QpkZc5UV4 XhBBerAl9Bc/pgA00PbSybesb3xdpDtQzR+KW4MdV+QbEp4JQMhC2EI3+RagQjbvUFP4 jA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=orV6Jiq3kXB0bcDgP4wZM6ASqt9ALseXlLi8MU8P7Ns=; b=aa7CDOWUsyiNiNIuP8HbiJ2mLSKEQEASjrZqXW//VhdpZlPbD3nASXyzD+l2/As2fz l8oYjU5DSH7DadwwePz4AVK2tKG3xCHapsLuxDL2HGGjkNohhFaWPFotGIs8kThpMxup Qj01c6rio818f42sDOCiX15poG6Jzdo5Fqi0BsW6PeJnxoKDx0dkQnutjuMFl21AOha9 IBtWHKHNR+o40cwgcE9G/9cOnQiW45BfMguiDWeQ6kA93uw2cTf+7LESzmKPzYD8woVv 1CSm57I3t+Wbmp69Xn0TOQhcwbtNsJBnlo+MpT7EXN4Db0fY4ZPNLB9GHuP6inyBJ7VN Jd+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y/Sb4BbQ"; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn38si5186169ejc.438.2020.12.11.13.20.17; Fri, 11 Dec 2020 13:20:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y/Sb4BbQ"; spf=pass (google.com: domain of linux-usb-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405882AbgLKVTw (ORCPT + 4 others); 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-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(-) -- 2.29.2 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;