From patchwork Mon Dec 14 11:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 11971957 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=unavailable 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 7E2DEC1B0D8 for ; Mon, 14 Dec 2020 11:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F1B422C7B for ; Mon, 14 Dec 2020 11:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbgLNLJG (ORCPT ); Mon, 14 Dec 2020 06:09:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407689AbgLNLHa (ORCPT ); Mon, 14 Dec 2020 06:07:30 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9EFC06179C for ; Mon, 14 Dec 2020 03:06:34 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id y19so29068420lfa.13 for ; Mon, 14 Dec 2020 03:06:34 -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=SFONqpKBx0+WGexIMJg0MppTIKw83Md/mUpNBwOPGvw=; b=EIEKyQp1tYGSTyeqRijNIjiczO2nSEeSBQk8Ma/kB23zAfJ2RyTgZFzV0gAEE8GDZ7 Kz6qOl0CJ2jcPMaeq0jgh8wyIvMYZkNn5br85W90ieiSHichYtkjs9dg3KnsxlE73HaR q8s99VSj/i4PKdx8Me6eqBLB5Hl6wX0rYJqdZWuHQGmuSlEOy/2nNVnglr/lLue8u6Z0 qElKdwbtKKpdYzhLehEbdircnTUPwN8cC2yGbvQrC5udBjxmtS9kkQrM3VnnEl5XIXFF F1q+n9koowuSNU1GmhDyEFYQeKwVwjR4nN5TCQKU5Mszqe71hLNHwBHt7D5j/PvbRYj2 byAg== 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=SFONqpKBx0+WGexIMJg0MppTIKw83Md/mUpNBwOPGvw=; b=PxYXyq3Esrr9sHdR8/jcqTUmBUM5dCpej7f+GXdOQ0e15bc1MU4IoVWyLrxl6m7v5/ KlGwIPIRe0vfXf3hacH1+T3YNPeeKPl3nwhXDjvUjrYfxnxwT3ZpvU73HRp+RZCavItx 6PaXv206+yBuB3CCVnoIcb47vyR2Nb2XZWVPbObDxc6TE5qePiV1ZnpMYj/TAx95H61D r+NraHu2W/XNzbkKGIdvOHaAi67uytbNTIhcW3bRv2NG5BwCYbKQhBaG08+1KI9PQ97B 2Bb46qp2cdruOx9WwW8zd9JdZVFv5Lcz8YKp26hLRH8Vqc+sE808RzKcfUrm44MmBi5C dlXg== X-Gm-Message-State: AOAM533Rx5DE86DmwGVXdH/yvOIIP7QPUj3dwaylnDss5t8SUB1hdYdS X7nkXjY0Y1t4f2ZgOKle3S4SD2Tx0HZg6bfx X-Google-Smtp-Source: ABdhPJwL99/BSTWjRTj1U5PSzQVTLj1X/NsvFtRTbp1VIM938jxZMvi4BvM4RzVvsYqDFSkzDCUcsQ== X-Received: by 2002:a2e:2417:: with SMTP id k23mr10009497ljk.373.1607943992681; Mon, 14 Dec 2020 03:06:32 -0800 (PST) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id q19sm2092217lfa.80.2020.12.14.03.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 03:06:32 -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 , Andy Shevchenko Subject: [PATCH v4 1/2] usb: dwc3: drd: Avoid error when extcon is missing Date: Mon, 14 Dec 2020 13:07:40 +0200 Message-Id: <20201214110741.8512-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214110741.8512-1-semen.protsenko@linaro.org> References: <20201214110741.8512-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 devices. 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 the port node exists in PHY node before calling of_graph_get_remote_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 Reviewed-by: Andy Shevchenko --- Changes in v4: - Moved the comment from patch 2/2 to 1/2 - Fixed typos in commit message and comment Changes in v3: - Split patch into two patches: logic diff and style diff drivers/usb/dwc3/drd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 3e1c1aacf002..da428cf2eb5b 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -462,8 +462,18 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } + /* + * Try to get an extcon device from the 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); - 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 Mon Dec 14 11:07:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 11971953 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=unavailable 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 60906C1B0E3 for ; Mon, 14 Dec 2020 11:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31CDD229C6 for ; Mon, 14 Dec 2020 11:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730191AbgLNLJE (ORCPT ); Mon, 14 Dec 2020 06:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbgLNLH5 (ORCPT ); Mon, 14 Dec 2020 06:07:57 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564A6C0617A7 for ; Mon, 14 Dec 2020 03:06:36 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id u18so29112832lfd.9 for ; Mon, 14 Dec 2020 03:06:36 -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=91Fi62YRIS4Qn6KO/9qSSfAEFCCwvmrnELKnrs1gSak=; b=RXm958TAHnbV81cWTdfZkaz4J2LXVnX/G/QULCB45ONmQNZXongcyH33ltdJe7f41l Q1kIQu7mBQoDBJWkAoWR18X3cQ2DLwsIGjGzLAhI9yrzq18I0mRP3L8Z5BIz3BJI25L5 pWt1ERh+q6OzxwH4JypYTbRwv9PKb0BDrKpVF42mfCO6L5vQBzf0JSn/tok7vNwfLj0S OW3kBImVFwHPLODQLrK2fI5vQp7uxLBv6HTGx2t/hCIuKh/d60C522wl0c4Wcg4FdtIa uYcBBrLA13hRFAVmfGzBkejieX+SHjB8nlIvIFKvb11fyEWURrplk7nPeOyehSIMcHnV nHfg== 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=91Fi62YRIS4Qn6KO/9qSSfAEFCCwvmrnELKnrs1gSak=; b=KPL7o7hEnFqZTV+OQb+5p3pLd9DscLlQIO44eDSJImWwe7KPrE37uCjshNQ8WWcIOJ rM8wCg03umbGyo2uPphnXKj2yqB0B4C9XmHlzA3UvDBJNNIyCipj0U65Xb2OI2W4/rpO V+3Tw/kQg1jHt82Wb+lFeghqm8xnV+dT5LMtRAempG0rXBsYPUA14cmyAGA6IZ7t0j37 ERhLuW0xwjmzAR6/6rjV39PMGeSr9p10F7zQK22XCbmOme5KqbdWddqj10AmZKJ61OlJ FiwXnu5e7BNiQm7c4nnYe5hOxV+25G+UvQ3VwpHYVAY9ZhYO0VJicLiOeo4n4oHbOuGm dmWw== X-Gm-Message-State: AOAM533QMe2iEEXEjLmitWpPtdzTLsenSdUgEKsEPnadOMHxIpqVWyvO 6gtg3ItPF5s8euJSE+wQ4nlxZb825sANdHs7 X-Google-Smtp-Source: ABdhPJzSzQh01E26X3BXk3jup3Yn066amJXzbnjsaisJb1HdHAeGSPBNzo+Fgl5Y/4Q67+7wpABz6A== X-Received: by 2002:a2e:9151:: with SMTP id q17mr10479296ljg.475.1607943994446; Mon, 14 Dec 2020 03:06:34 -0800 (PST) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id f26sm1199576ljg.137.2020.12.14.03.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 03:06:33 -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 , Andy Shevchenko Subject: [PATCH v4 2/2] usb: dwc3: drd: Improve dwc3_get_extcon() style Date: Mon, 14 Dec 2020 13:07:41 +0200 Message-Id: <20201214110741.8512-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214110741.8512-1-semen.protsenko@linaro.org> References: <20201214110741.8512-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The previous change ("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 an extcon device from the "port" node. Signed-off-by: Sam Protsenko Cc: Andy Shevchenko --- Changes in v4: - Moved the comment from patch 2/2 to 1/2 - Fixed typos in commit message Changes in v3: - Split patch into two patches: logic diff and style diff drivers/usb/dwc3/drd.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index da428cf2eb5b..e2b68bb770d1 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")) @@ -470,17 +470,14 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) * 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 (np_conn) - edev = extcon_find_edev_by_node(np_conn); - else - edev = NULL; + if (of_graph_is_present(np_phy)) { + struct device_node *np_conn; - 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;