Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5809526ybv; Tue, 18 Feb 2020 04:26:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzd3tLfOXltLsIRlMpHZtGb0rkFE7DzccNXLID5WDq0WiybfTW11r/F9hYrHr8ecDUy44kl X-Received: by 2002:a9d:74c4:: with SMTP id a4mr16123964otl.119.1582028773400; Tue, 18 Feb 2020 04:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582028773; cv=none; d=google.com; s=arc-20160816; b=MPQ47WGGekIDN1FoBOBy/PQZidoS1yEB+8tbVNC4Co4aHizuwYbZ5EmYyGKsMxxnIX wdKcK61glxJuLxGplH4zj9XH9riRmN9HNsBU78sO15Rty6pydOCAIGIB977BPQ13R4/A 3T8ZI+uVP3Ylsiz+ht4vrD5oIuJrnRsyQfTyAIBu79gmODE2Vx3Yxq3saK2SyaanKJmu 5M7X9jUtsPVAmK7YPYOEiXaupBhZ1WBZQHewCBFhB1Pf2/jmn4YzDbvidpLDi3Ae/b+a oXqrzZEJT8AQ/Yx/hzobhsz8G4FLgpoGYDTRO+6Cya4IfXgHTyHJ1Wzs34++hluE9WCF KYrA== 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=U0Ceh+FlGTTOUOhhQurokc/kt9qJIdqklePtj0sY9b8=; b=FeLXTRUbCSEQ3e6Ng3mQqz/FYaR7trAXSIdJ2L3kU6dkVkDgdJJ3gFSwhoSQm52gdP 4yg5LpyKp8XLrIg1nJapmefmC5ANKkmbuIDiteI5eWSxBf2kItqbHN+NeYNli4UzZLD2 Q+8lpjZXFrowbxe4JB+mKkhcHqbdUJlAtSJ76F1+1uXmFEZhA2tmg/IgqaG6E2ub+qc6 aNAWYpKgZujt/iiwMphYNTxrxp4gB2Ib2VtXxpADF6G/KZLASutEs4rprUDCGHi36uXk Ufpj1JF1lnl4Y7W+3jTgeFz4mpFsw/MwytWArbbOM6CkMWM2bo/Kocq0CEfT5hapBpRs S2/g== 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 x19si1700153otk.89.2020.02.18.04.26.01; Tue, 18 Feb 2020 04:26:13 -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 S1726612AbgBRMZv (ORCPT + 99 others); Tue, 18 Feb 2020 07:25:51 -0500 Received: from mga07.intel.com ([134.134.136.100]:36582 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbgBRMZu (ORCPT ); Tue, 18 Feb 2020 07:25:50 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Feb 2020 04:25:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,456,1574150400"; d="scan'208";a="348688175" Received: from kuha.fi.intel.com ([10.237.72.53]) by fmsmga001.fm.intel.com with SMTP; 18 Feb 2020 04:25:46 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 18 Feb 2020 14:25:45 +0200 Date: Tue, 18 Feb 2020 14:25:45 +0200 From: Heikki Krogerus To: Peter Chen Cc: Felipe Balbi , Chunfeng Yun , Bin Liu , Benson Leung , Prashant Malani , Mika Westerberg , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: Re: [PATCH 5/9] usb: roles: Provide the switch drivers handle to the switch in the API Message-ID: <20200218122545.GF28776@kuha.fi.intel.com> References: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> <20200213132428.53374-6-heikki.krogerus@linux.intel.com> <20200213133239.GN1498@kuha.fi.intel.com> <20200218072341.GA30350@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200218072341.GA30350@b29397-desktop> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Feb 18, 2020 at 07:23:41AM +0000, Peter Chen wrote: > > > @@ -1118,6 +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) > > > } > > > > > > if (ci_role_switch.fwnode) { > > > + ci_role_switch.driver_data = ci; > > > ci->role_switch = usb_role_switch_register(dev, > > > &ci_role_switch); > > Why the struct usb_role_switch_desc needs drvdata, the struct > usb_role_switch has already one? I'm assuming that you are asking why not just register the switch, and then call usb_role_switch_set_drvdata(), right? That may create a race condition where the switch is accessed before the driver data is available. That can happen for example if the switch is exposed to the user space. To play it safe, supplying the driver data as part of the descriptor. That way we can be sure that the driver data is always available the moment the switch is registered. thanks, -- heikki