From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26ABDC4361B for ; Tue, 8 Dec 2020 09:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E54B023A52 for ; Tue, 8 Dec 2020 09:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728846AbgLHJjZ (ORCPT ); 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