Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3652428ybi; Mon, 27 May 2019 03:46:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHDY4lzmaRERrk2ZlGoPbhgJNbBfpGQeK0LOUeubOzgji1gwdlJ4J4AktjWsPM3eSfrjGK X-Received: by 2002:a17:90a:e393:: with SMTP id b19mr30504221pjz.119.1558953999468; Mon, 27 May 2019 03:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558953999; cv=none; d=google.com; s=arc-20160816; b=WU3Td9vED2lVDMAEZ/D/mXLM8JALapJop5KU+HJvlcfZE3AO6sJIgaaZK+6YPtuv9e FrJ8aCu1SEO3vgH1M+2NpB5jPMwoixvsnNTZhoqQ2L3eg0hBq706+ntTxKAuGzFbDJ8Q GSUpRArSf1Qs76TGCOtMetrqVEqoGVS1f06iO9Wf9fMGvtWRPWqyMh04vxRibwGJcwwg FeSxf6bc7zTMmvDrnKmVhi4fg7GSKhKLRPTS85lpddwACtz//YGLlqPucWPswxcKoSJi hq3gNaD1UtdWp+jcBATsth3H+siRJVNwUojhK6Z8XigEqVUQDV4IIVzyTDf5Myxnnpyb 1OMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HqaQD463nzDcGzOI2W4Ygl9QQ0qwL02uIpDyHJIz5OU=; b=wS/r3WdKf9E+2Kn+Kkm32JaisAcD6TlFs8lKdUzH1nl+KwMuKvNGOOoasZn+1Y35eK JtNTKAqmT9KLFWYjsEac96BQ1SX/v7tNaxTU++Zt7vJP4tlbTMRDbUx4FbMBtaVuFYgW Ovgq3c2As6MmsvGUAMCHI0krGFleQ+S8FUFOrgDg5lj2TT78xKMk7baQsrcWqyhkMGoJ sE3Aj3/LgMva35d+gVZIhOW+6sI/Xx10GoDZRLszc4hC7pboW50RsOW0S48BvW00dxQX 1oegR+MwIJeET/99ECSq8vtcCCIMngv1tZKtt7TLef6yU/MVHoFbXePIuJO/IlHHF6P3 mYiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a62si17731678pgc.129.2019.05.27.03.46.24; Mon, 27 May 2019 03:46:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbfE0KpN (ORCPT + 99 others); Mon, 27 May 2019 06:45:13 -0400 Received: from mga18.intel.com ([134.134.136.126]:30969 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbfE0KpN (ORCPT ); Mon, 27 May 2019 06:45:13 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2019 03:45:12 -0700 X-ExtLoop1: 1 Received: from kuha.fi.intel.com ([10.237.72.189]) by fmsmga001.fm.intel.com with SMTP; 27 May 2019 03:45:07 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 27 May 2019 13:45:06 +0300 Date: Mon, 27 May 2019 13:45:06 +0300 From: Heikki Krogerus To: Chunfeng Yun Cc: Biju Das , Rob Herring , Greg Kroah-Hartman , Mark Rutland , Matthias Brugger , Adam Thomson , Li Jun , Badhri Jagan Sridharan , Hans de Goede , Andy Shevchenko , Min Guo , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mediatek@lists.infradead.org" , Linus Walleij Subject: Re: [PATCH v5 4/6] usb: roles: add API to get usb_role_switch by node Message-ID: <20190527104506.GA7167@kuha.fi.intel.com> References: <20190520083601.GE1887@kuha.fi.intel.com> <20190521095839.GI1887@kuha.fi.intel.com> <1558517436.10179.388.camel@mhfsdcap03> <20190522142640.GN1887@kuha.fi.intel.com> <1558606570.10179.403.camel@mhfsdcap03> <20190524114036.GO1887@kuha.fi.intel.com> <1558926443.10179.438.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1558926443.10179.438.camel@mhfsdcap03> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > > IMO that case should be handled in USB role switch API initially, not > > in the device connection API. If there is another user for it one day, > > then we can move it to device connection API, but not before that. > Ok > > > > How about this on top of the two patches I sent: > I just test it, it works well. > I'll prepare a patch and put into this series. > > > > > diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c > > index aab795b54c7f..36ac9d181e09 100644 > > --- a/drivers/usb/roles/class.c > > +++ b/drivers/usb/roles/class.c > > @@ -114,6 +114,19 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, > > return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); > > } > > > > +static struct usb_role_switch * > > +usb_role_switch_is_parent(struct fwnode_handle *parent) > > +{ > > + struct device *dev; > > + > > + if (!parent || !fwnode_property_present(parent, "usb-role-switch")) > > + return NULL; > > + > > + dev = class_find_device(role_class, NULL, parent, switch_fwnode_match); > > + > > + return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); > > +} > > + > > /** > > * usb_role_switch_get - Find USB role switch linked with the caller > > * @dev: The caller device > > @@ -125,6 +138,10 @@ struct usb_role_switch *usb_role_switch_get(struct device *dev) > > { > > struct usb_role_switch *sw; > > > > + sw = usb_role_switch_is_parent(fwnode_get_parent(dev_fwnode(dev))); > > + if (sw) > > + return sw; > Do we also need to get parent module before return? Yes. thanks, -- heikki