>From 8cca23b3064bf8b33e316245732a8baf834142d2 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 25 Nov 2025 10:38:04 +0100 Subject: [PATCH] usb: typec: Set the bus also for the port altmodes The port altmodes can't be bound to the altmode drivers because the altmode drivers are meant for partner commuication using the VDM (vendor defined messages), but they can still be part of the bus. The bus will make sure that the normal bus notifications are available also with the port altmodes. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/bus.c | 24 +++++++++++++++++++++++- drivers/usb/typec/class.c | 4 +--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index a884cec9ab7e..1daf7a353c01 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -445,7 +445,23 @@ static struct attribute *typec_attrs[] = { &dev_attr_description.attr, NULL }; -ATTRIBUTE_GROUPS(typec); + +static umode_t typec_is_visible(struct kobject *kobj, struct attribute *attr, int n) +{ + if (is_typec_port(kobj_to_dev(kobj)->parent)) + return 0; + return attr->mode; +} + +static const struct attribute_group typec_group = { + .is_visible = typec_is_visible, + .attrs = typec_attrs, +}; + +static const struct attribute_group *typec_groups[] = { + &typec_group, + NULL +}; static int typec_match(struct device *dev, const struct device_driver *driver) { @@ -453,6 +469,9 @@ static int typec_match(struct device *dev, const struct device_driver *driver) struct typec_altmode *altmode = to_typec_altmode(dev); const struct typec_device_id *id; + if (is_typec_port(dev->parent)) + return 0; + for (id = drv->id_table; id->svid; id++) if (id->svid == altmode->svid) return 1; @@ -469,6 +488,9 @@ static int typec_uevent(const struct device *dev, struct kobj_uevent_env *env) if (add_uevent_var(env, "MODE=%u", altmode->mode)) return -ENOMEM; + if (is_typec_port(dev->parent)) + return 0; + return add_uevent_var(env, "MODALIAS=typec:id%04X", altmode->svid); } diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 9b2647cb199b..26bf76328487 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -584,9 +584,7 @@ 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)) - alt->adev.dev.bus = &typec_bus; + alt->adev.dev.bus = &typec_bus; /* Plug alt modes need a class to generate udev events. */ if (is_typec_plug(parent)) -- 2.50.1