Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1591664pxu; Sat, 12 Dec 2020 19:14:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+cp/HIx+AbDXGHFkz/cSDIA3xkj3Qw7oXEfh1qGZOQYsOxoXnQ1pr+W41g2tlvGTfscOQ X-Received: by 2002:a50:d6dc:: with SMTP id l28mr18684612edj.286.1607829280187; Sat, 12 Dec 2020 19:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607829280; cv=none; d=google.com; s=arc-20160816; b=qp9hi6Uu5bA2gX7H0XkYHbfBH1xg+aDnAyan2jL2H/jOP46UL/pE/mjB4CFqzu+nT3 UpA7sMm2VJN6gtmmrHeTrQj/nTlvWVMzH4mFIwrybC8XEqrNLb0zkTNjYoLQOke73mXV Kn4axaiMyrVWz6aWJUhreyF1JNIZTZ/CE/AGyKTsowgmog7mlCbqNCK7//QzVb8tP2Bo AR9HnHTmorsZU27khlc5zUPP5QsTKo+gkRcQxhBceebAe/4bw43CJMNzmO3vno0J40zy /URAqAchAhCnewqRJq1mtT4p0loIwIquK5fpOQgi1d2n/Rd8J1UOFchztKH7VF/xbqCp Wngw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=txHS+fz8k2KCZchJH18l2B/VJee2wpafojXlxjFkEbg=; b=ttVTdX1uxQY+lGbxs1cYvowo3MIlPaCt38Jyx41R6WDPFrRmPJaE8F8GivXfhGQOQ6 XWbcM4kHiHYb2ja+CBIbDueZfE653Ehoy+EK0U5uYTJ1TYZ9JXwA6QIX2YqB9IXPBlhi IxUNamkSxa5BlLY8QYMf39kMT3yt60wB5PB+0rc5wQGRY67AoP51C3YQjnUvcjmCTe4M vQMFxT44U9F+JYn7Owk71DA7LJIr52paQN6IdyUK45F37kF4r0aTCPT1MmKmnnLTUmGg CeXCrqzq4VSsgSrUz0AXB2rLm+fAz82JBxWIB2kyooyq0KYNZiOQrgPEEMh9KM+FYUbO U7wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="otkvC/jw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 e22si8510320eds.52.2020.12.12.19.14.17; Sat, 12 Dec 2020 19:14:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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="otkvC/jw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2394179AbgLKVPk (ORCPT + 99 others); Fri, 11 Dec 2020 16:15:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390615AbgLKVPQ (ORCPT ); Fri, 11 Dec 2020 16:15:16 -0500 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594E6C0613D3 for ; Fri, 11 Dec 2020 13:14:34 -0800 (PST) Received: by mail-vs1-xe41.google.com with SMTP id p7so5561846vsf.8 for ; Fri, 11 Dec 2020 13:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=txHS+fz8k2KCZchJH18l2B/VJee2wpafojXlxjFkEbg=; b=otkvC/jwZ6/TwBEwk8oFLDidR9riZ9p5DgsQkEY3PN512N5dW2pSmXvH/2N7I2vxfE 8hrJlwATglONGcw7U9+YNlWby6XrsVNAUrJcoMNeSqks0ep3SVuf5QAGkZpxc0NvAqGs TA2xVTwilegZknQ/fogGir5d+Fz25s0R5fcYSSXNTOXA93R/Upxy/TZiKmITWpLx0ez0 14ME01ASVtVMrUz/sDeqBSodRBDowO1Lyp1wi6TifzWPEHt7tbvJvLUlxRebS2+e+5ww V+yP0s3Wq6w96sl1UgCMEXrUB2p5HUr0MCPKdavJGFM40pOfqHpvGl4jd+vXry+VCkAz FXnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=txHS+fz8k2KCZchJH18l2B/VJee2wpafojXlxjFkEbg=; b=dIr87CL9CpiJ6PvQQT8omwG4WFgGCk8qi+ueEbfjPS+7qy/YcO0C6DfECczaEmn2b0 eWI4R6I4aWfJVh5BJYHy/8y/1Wn+C4z8AeVB8WGFldjpXu95YNFFx8kR1zs+OxJCzO7I yFkyzBH2k7o9KJxh79R4TBa4ee/VT5VxAvcuWqMA6ldFJId9DU4HgmSMdUI+lD0CKmVm 4bA2qQKILQfygCHVUjZnpp4LUBMI/pi/uuNXlkfaU+NyVRRO7uSSQ8yymKVzTJERISM1 grXDJrAeWBXf4pLp3Cqxg1w3Dd6CO9K/LlmAAJ6FTIMPzhqVWbva8yUYdbFnqoDZmxJE PuwA== X-Gm-Message-State: AOAM53112oXyjWR36QIEvz/Nc97diukwn6NxOiPx0AIFzMELfYCnU6AM g/VSVo7l0ghlT9VFn86zLcyQuxfkar0D+/tl5l2e16fu6LrLJHfu X-Received: by 2002:a67:32d4:: with SMTP id y203mr14611389vsy.30.1607721272917; Fri, 11 Dec 2020 13:14:32 -0800 (PST) MIME-Version: 1.0 References: <20201211142421.15389-1-semen.protsenko@linaro.org> <20201211144936.GT4077@smile.fi.intel.com> In-Reply-To: <20201211144936.GT4077@smile.fi.intel.com> From: Sam Protsenko Date: Fri, 11 Dec 2020 23:14:21 +0200 Message-ID: Subject: Re: [PATCH] usb: dwc3: drd: Avoid error when extcon is missing To: Andy Shevchenko Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman , John Stultz Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Dec 2020 at 16:48, Andy Shevchenko wrote: > > On Fri, Dec 11, 2020 at 04:24:21PM +0200, Sam Protsenko wrote: > > 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(). > > So, this has to be v2... > Anyway, see below. > > ... > > > 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,15 +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); > > - np_conn = of_graph_get_remote_node(np_phy, -1, -1); > > + 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; > > > Why not do it slightly different, i.e. > > - 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; > > ? > Thanks for the review, Andy! I'll address this in v3. > -- > With Best Regards, > Andy Shevchenko > >