Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3040834pxu; Tue, 8 Dec 2020 01:43:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnHHyIn73ZhGhQqHAj3+mB2eHlEKAEG2aUlKp8MrQzYjgr7D7T9ENy0qqb4NYGP+tqfrXP X-Received: by 2002:a50:d2c8:: with SMTP id q8mr22804950edg.375.1607420597973; Tue, 08 Dec 2020 01:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607420597; cv=none; d=google.com; s=arc-20160816; b=jKQcoYDfpavWjixAt+yAhh0POstn9ws5oZ9CoOaj28GuuAVyUmlwr3JDvzT3j3tdr3 OLOvPShgAqu+mirs6GGWItViytUGddrlhRqqHiuUYX+G4AWmYpxmn8Ts8YswRA1nyqK4 REWPX5ocnXiPBrgmyUoLM/LRoAVjfFOcKTThCXOIlPbCFkXD+UfTN0sJ69Kn7E2NYcpf o62VtrQWzzTi5/V+IEEp0xvMuud33ySRxKSUU3rUcbVKMeYB+dpxobo1+ySJ64qcUw5P HZo9pjYBFwERyf8QgUiPzFRnHAJ5M/oqVSG35l1lWCckIVY0sWbA+IA1c4Q/iPte9e8L QNOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=MS64sCAVOTz+V5qMDJ4wAZzQsaiBP1adgisaal/+y9U=; b=ZyUtO0gApeP8uByPGGsW7euVRka8xP9o+NgTiKX2CmOAaczMS8vb+HErNSc6KXYr3/ btYkFQpXsnM1c5RXs0hnErfZtDi+B6O5NgsBPLrUrdWh8kKveFqTDNNi8+eCAUeWp3LC b8IJDnySMgHk3kPiNb9P2UFrrHM6xzgmbGC6a2uQQzYSnehy3x7LC82TLNDhpJklmBRX buzpGOS//rFHbY6PQYGMaDQELZ9u5vfWEA/v1I7qn15Gu6KqffJ8TZ6RDaYuVIMw+V9P EEroy5JdnsPHTkjCoQ5g/1bsk9iuOLuK9wNX+LmrKJSYLSNobcdmQXJhj3C1gYNsVbcZ jxdw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq4si8217312ejc.14.2020.12.08.01.42.54; Tue, 08 Dec 2020 01:43:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728829AbgLHJjZ (ORCPT + 99 others); Tue, 8 Dec 2020 04:39:25 -0500 Received: from mga01.intel.com ([192.55.52.88]:3517 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727831AbgLHJjY (ORCPT ); Tue, 8 Dec 2020 04:39:24 -0500 IronPort-SDR: RJGCzVcAxNlQricLjz/DfdP+9ItWBjQ4wrobbJRprvRGrx6Laaip7Yanyb3ViB2JHe6VI87AF7 xvzf09HF7KOw== X-IronPort-AV: E=McAfee;i="6000,8403,9828"; a="192145328" X-IronPort-AV: E=Sophos;i="5.78,402,1599548400"; d="scan'208";a="192145328" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2020 01:37:37 -0800 IronPort-SDR: ZLLqWybu4KNlwT0nEra2KW9AAi9SfnFfqpqzXJdn+3aobKyzkNBm4nS7myaqwoGh6IiPV0zit4 L+35aKnD+L+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,402,1599548400"; d="scan'208";a="437320455" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 08 Dec 2020 01:37:35 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 08 Dec 2020 11:37:34 +0200 Date: Tue, 8 Dec 2020 11:37:34 +0200 From: Heikki Krogerus To: Prashant Malani Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, bleung@chromium.org, Jonathan Corbet , "open list:DOCUMENTATION" , open list Subject: Re: [PATCH] usb: typec: Add bus type for plug alt modes Message-ID: <20201208093734.GD680328@kuha.fi.intel.com> References: <20201203030846.51669-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201203030846.51669-1-pmalani@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 07:08:47PM -0800, Prashant Malani wrote: > Add the Type C bus for plug alternate modes which are being > registered via the Type C connector class. This ensures that udev events > get generated when plug alternate modes are registered (and not just for > partner/port alternate modes), even though the Type C bus doesn't link > plug alternate mode devices to alternate mode drivers. I still don't understand how is the uevent related to the bus? If you check the device_add() function, on line 2917, kobject_uevent() is called unconditionally. The device does not need a bus for that event to be generated. Also, I don't understand how are the cable plug alt modes now prevented from being bind to the alt mode drivers? > Update the Type C bus documentation to mention that there > are alternate mode devices for plugs as well. > > Signed-off-by: Prashant Malani > Cc: Heikki Krogerus > --- > Documentation/driver-api/usb/typec_bus.rst | 6 +++--- > drivers/usb/typec/class.c | 8 ++++++-- > 2 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/Documentation/driver-api/usb/typec_bus.rst b/Documentation/driver-api/usb/typec_bus.rst > index 21c890ae17e5..7874d2f37d9f 100644 > --- a/Documentation/driver-api/usb/typec_bus.rst > +++ b/Documentation/driver-api/usb/typec_bus.rst > @@ -15,9 +15,9 @@ modes by using the SVID and the mode number. > > :ref:`USB Type-C Connector Class ` provides a device for every alternate > mode a port supports, and separate device for every alternate mode the partner > -supports. The drivers for the alternate modes are bound to the partner alternate > -mode devices, and the port alternate mode devices must be handled by the port > -drivers. > +or cable plug supports. The drivers for the alternate modes are bound to the > +partner alternate mode devices, and the port alternate mode devices must be > +handled by the port drivers. > > When a new partner alternate mode device is registered, it is linked to the > alternate mode device of the port that the partner is attached to, that has > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 35eec707cb51..74061a699f16 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -478,8 +478,12 @@ typec_register_altmode(struct device *parent, > if (!is_port) > typec_altmode_set_partner(alt); > > - /* The partners are bind to drivers */ > - if (is_typec_partner(parent)) > + /* > + * The partners are bind to drivers. > + * Also set the bus field for plug alt modes so that the udev event occurs on device > + * registration. > + */ > + if (is_typec_partner(parent) || is_typec_plug(parent)) > alt->adev.dev.bus = &typec_bus; > > ret = device_register(&alt->adev.dev); > -- > 2.29.2.454.gaff20da3a2-goog thanks, -- heikki