Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp186187pxu; Wed, 2 Dec 2020 19:14:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRzkV6dEq8GKY5zxCfrNPF5meN2X2sWpFpcOxqQUcn4Xy0SOkvFADetXAAAoOfZAfFybes X-Received: by 2002:a17:906:7016:: with SMTP id n22mr734824ejj.402.1606965286675; Wed, 02 Dec 2020 19:14:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606965286; cv=none; d=google.com; s=arc-20160816; b=zZreEuXhvhXWA16mPdUEawqIHgl7ewZyNquMo3217EwzcTW/P+P4AmpMu+GyuizIQx vScrNAeWPoe5F+C9m4dvzR9MxUy4lhFKJk/p+V0W1ROsaJsNXuvS6BQsiXLtP2IobXJZ xI2osI1Jl7oSGPGKuEbW5vde7TptHGPIKXvI0O5JnNZ9/z/NrbWy9uE0lhrVArYW2PS7 F13c3zQv34q7iyCrPHYo53TqUQGXDE7aHYzxmuiZKy3BKNe+rHWw5a4js9ULFJyU9di4 iWn28hKpZqWk0KMW32sXWv6WsfaZupcL/PowCc8QL3ZOTlrwcE1xqdgAJh3dNeGKSbFC E4Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3HPjMiZ7r2vmNOesKbXHx10R/RkIYQVQPBYwT6NlQG0=; b=quEancNFGzsY7LLyv9n3KDZmsM2ABSTDMeSx4tENnWqTfLF3m1qm+5S4Y2Z8aLVaE7 8KggEIzkE6/qsNFKBJavu1Nb6n5lx+DzwAkn+G0BOOHL0vYQyaoMX0Wd+RlEQ3u2Wj8Y m+bjHpl4xzRWvmdCn7xtHIh7Ll8BNWUMGYr7/AZVFZ181JziV9XNUfv/YqHMgl+WI8vB K6qrd5LOZ3V3k5ht1Eohh/mHZ7oGIad+jfLq2aKPmscw8LtnnpCdh147pTOVrBCiegtr XhjMSJFskckgk7B24tWObn+FXd9NMgCicq/vfL7/6XJAHJEFD2jKdaFofA5XExYH68ZU Youw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HYvUEoGI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb23si164532edb.75.2020.12.02.19.14.20; Wed, 02 Dec 2020 19:14:46 -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; dkim=pass header.i=@chromium.org header.s=google header.b=HYvUEoGI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729590AbgLCDKM (ORCPT + 99 others); Wed, 2 Dec 2020 22:10:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbgLCDKM (ORCPT ); Wed, 2 Dec 2020 22:10:12 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF703C061A4D for ; Wed, 2 Dec 2020 19:09:31 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id j1so356222pld.3 for ; Wed, 02 Dec 2020 19:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3HPjMiZ7r2vmNOesKbXHx10R/RkIYQVQPBYwT6NlQG0=; b=HYvUEoGI49+MPUkaFo90T8oSv8t7B1B2PHAwPzjXWy8nnUV00Ioup69H2B2Vnt4yaG EUON+5/nB36QJdMsrhFNnr47nFjhPBpBrrsEtK7Q3Nw6Uenez408SBlRqp5lrChHC4Ot n6yjmD0hXKg0UzAfOetXQoVKoJ3Pl/DBY68hY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3HPjMiZ7r2vmNOesKbXHx10R/RkIYQVQPBYwT6NlQG0=; b=KT9l3UCj6ZYbv5CLnPMUYzIfinq1g4c/SnF1/2Go8VdjWU1hYtBQyr0Fi/+ZPcYpGF d9rUH2atyrN4dQIiyQE5MKVJdqObrFNIluDSKkuwZlO4BtrYxlXPvJ0bj6FVDqBnYDtI qDwDEtU9wBp0Amq8/04pp5T+U8xSguvdm2mDgAySi40VWM6zpQd3fxq55jDFAWCkIXIC kS3J936nV9IgBuExqFWhxbKm72KlJV8IDTO5mlnbyYIoUjZmIb6JrP9iHYEQ361jvy/i 5bHsPfU7/vCfAho69uIqCP62bkM9aATZD3zyevIGSwic3mP9RscOHQFrS4f0zEkO6JXR n5xA== X-Gm-Message-State: AOAM532q81izhLTbcEymXdI7eYobfwRcaJGz3MSomwZ8bkWILmRrju7g 9QC1t0JrRbLUso0cs7zPRH+YMA== X-Received: by 2002:a17:90a:9f98:: with SMTP id o24mr1032229pjp.207.1606964971450; Wed, 02 Dec 2020 19:09:31 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id 14sm437080pfz.54.2020.12.02.19.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 19:09:30 -0800 (PST) From: Prashant Malani To: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com Cc: bleung@chromium.org, Prashant Malani , Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] usb: typec: Add bus type for plug alt modes Date: Wed, 2 Dec 2020 19:08:47 -0800 Message-Id: <20201203030846.51669-1-pmalani@chromium.org> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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