Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2005766ybf; Sun, 1 Mar 2020 23:43:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzwWdbQ5GdkSCmJq65Ez17MFIw+tC6RwqikSwY83z3oRnRl6HMW5EV19ASZCcpzHVQB4EUA X-Received: by 2002:aca:3f43:: with SMTP id m64mr10213190oia.165.1583135017354; Sun, 01 Mar 2020 23:43:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583135017; cv=none; d=google.com; s=arc-20160816; b=HAJVU4uxu7cg7LNFRoBlg0+TaIMvUofQnOUpasYZwje4UpGjJZ6FidXYg+YNhxZm/C xGJ8JKTAkbVKRpko4lwZysz8thMVijAnCyHYCRSOHAcMDZCdHeeFLQfsJw6YB5zR/+3w t0NcYRX3D3tsFe7XaQa0wv65VjDgw9Y28GJ3q2AeXuskA16SplMGWud9c3ZTREyb0x2e ePFMqQQ/GfjsVJ5L8zYGW0fmDDWt0da+xOzK+OioeeaEBV4QBwnGfKsZqUZ6RMncTXls zVLh1GaRs1z0H3GDghdlZPbYfhuO7uwoT1SzAEfUzhvolNcdHpdV3Kg7udPwUMolw4Lg kh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=rt++fopoLY2yvju40Ez88WsdddEv4jSP7ntvGVpn9ic=; b=g2hN7TXRzfkeD9ttYoG8tShyC8lk2QfiFa7O4aw/bIeJ9XOio8pbWm/R13HS78y4Wf W7iJDYtsTk3Q8F6QldM1S92MZI18aqFel/HAp5lSHgsbo8+FSelX/s2Cv0bW2tVccf6q EgnlGxXB2esa6l/SnEjzILcbO2OYJ59DrzUC9eQaymM+HIe2NlWz+nYW408OsBmgGUxd +MNlHPB3zD1D0fyMtk2jPXZKKXdbuzOTiJMzZIjsAWy5+zdkmxphB1/rgVmfM0Ptd+n8 ZpcU4kQEBhHOe9BY80Eg9N30Cc8S8bluFy7F/Zv8TuQ94dJ8a5eW45woNlqqyOFltwHN 3+Yg== 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 45si5898660otg.7.2020.03.01.23.43.25; Sun, 01 Mar 2020 23:43:37 -0800 (PST) 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 S1726956AbgCBHnI (ORCPT + 99 others); Mon, 2 Mar 2020 02:43:08 -0500 Received: from mga06.intel.com ([134.134.136.31]:42953 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgCBHnI (ORCPT ); Mon, 2 Mar 2020 02:43:08 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2020 23:43:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,506,1574150400"; d="scan'208";a="351483847" Received: from kuha.fi.intel.com ([10.237.72.53]) by fmsmga001.fm.intel.com with SMTP; 01 Mar 2020 23:43:03 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 02 Mar 2020 09:43:03 +0200 Date: Mon, 2 Mar 2020 09:43:03 +0200 From: Heikki Krogerus To: Peter Chen Cc: Greg Kroah-Hartman , Benson Leung , Prashant Malani , Mika Westerberg , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , Felipe Balbi , Chunfeng Yun , Bin Liu Subject: Re: [PATCH v2 5/9] usb: roles: Provide the switch drivers handle to the switch in the API Message-ID: <20200302074303.GB27904@kuha.fi.intel.com> References: <20200224121406.2419-1-heikki.krogerus@linux.intel.com> <20200224121406.2419-6-heikki.krogerus@linux.intel.com> <20200224131442.GA5365@b29397-desktop> <20200302062302.GE3834@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200302062302.GE3834@b29397-desktop> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 02, 2020 at 06:22:59AM +0000, Peter Chen wrote: > On 20-02-24 13:14:40, Peter Chen wrote: > > > */ > > > -static int cdns3_role_set(struct device *dev, enum usb_role role) > > > +static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role) > > > { > > > - struct cdns3 *cdns = dev_get_drvdata(dev); > > > + struct cdns3 *cdns = usb_role_switch_get_drvdata(sw); > > > int ret = 0; > > > > > > pm_runtime_get_sync(cdns->dev); > > > @@ -423,12 +423,6 @@ static int cdns3_role_set(struct device *dev, enum usb_role role) > > > return ret; > > > } > > > > > > -static const struct usb_role_switch_desc cdns3_switch_desc = { > > > - .set = cdns3_role_set, > > > - .get = cdns3_role_get, > > > - .allow_userspace_control = true, > > > -}; > > > - > > > /** > > > * cdns3_probe - probe for cdns3 core device > > > * @pdev: Pointer to cdns3 core platform device > > > @@ -437,6 +431,7 @@ static const struct usb_role_switch_desc cdns3_switch_desc = { > > > */ > > > static int cdns3_probe(struct platform_device *pdev) > > > { > > > + struct usb_role_switch_desc sw_desc = { }; > > > struct device *dev = &pdev->dev; > > > struct resource *res; > > > struct cdns3 *cdns; > > > @@ -529,7 +524,12 @@ static int cdns3_probe(struct platform_device *pdev) > > > if (ret) > > > goto err3; > > > > > > - cdns->role_sw = usb_role_switch_register(dev, &cdns3_switch_desc); > > > + sw_desc.set = cdns3_role_set, > > > + sw_desc.get = cdns3_role_get, > > > + sw_desc.allow_userspace_control = true, > > Heikki, when I try to apply above, and compile, I find above issue, > the end of code should be ";", but not ",". OK. I'll fix that. I could have sworn that I tested that, but clearly I have not done it. > > > + sw_desc.driver_data = cdns; > > > + > > > + cdns->role_sw = usb_role_switch_register(dev, &sw_desc); > > > if (IS_ERR(cdns->role_sw)) { > > > ret = PTR_ERR(cdns->role_sw); > > > dev_warn(dev, "Unable to register Role Switch\n"); > > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > > > index 52139c2a9924..ae0bdc036464 100644 > > > --- a/drivers/usb/chipidea/core.c > > > +++ b/drivers/usb/chipidea/core.c > > > @@ -600,9 +600,9 @@ static int ci_cable_notifier(struct notifier_block *nb, unsigned long event, > > > return NOTIFY_DONE; > > > } > > > > > > -static enum usb_role ci_usb_role_switch_get(struct device *dev) > > > +static enum usb_role ci_usb_role_switch_get(struct usb_role_switch *sw) > > > { > > > - struct ci_hdrc *ci = dev_get_drvdata(dev); > > > + struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw); > > > enum usb_role role; > > > unsigned long flags; > > > > > > @@ -613,9 +613,10 @@ static enum usb_role ci_usb_role_switch_get(struct device *dev) > > > return role; > > > } > > > > > > -static int ci_usb_role_switch_set(struct device *dev, enum usb_role role) > > > +static int ci_usb_role_switch_set(struct usb_role_switch *sw, > > > + enum usb_role role) > > > { > > > - struct ci_hdrc *ci = dev_get_drvdata(dev); > > > + struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw); > > > struct ci_hdrc_cable *cable = NULL; > > > enum usb_role current_role = ci_role_to_usb_role(ci); > > > enum ci_role ci_role = usb_role_to_ci_role(role); > > > @@ -1118,6 +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) > > > } > > > > > > if (ci_role_switch.fwnode) { > > > + ci_role_switch.driver_data = ci; > > And chipidea code, better change it like cdns3's, otherwise, the > switch desc for all controllers have the same driver_data. OK. thanks, -- heikki