Re: [PATCH v2 01/22] usb: typec: Add alternate mode state notifiers
From: Joshua Peisach
Date: Mon Sep 07 2026 - 09:36:08 EST
On Sun Sep 6, 2026 at 2:36 PM EDT, Sven Peter wrote:
The Apple Silicon USB4/Thunderbolt driver needs to be made aware ofspace/tab formatting
cable details and whenever USB4 or Thunderbolt is entered. The cable
details are already available as part of the typec subsystem but there
is no way to get a notification on typec_altmode_update_active() so
far.
Add a blocking notifier chain to each alternate mode and call it
whenever the mode is activated or deactivated right next to the already
existing sysfs and kobject_uevent notifications. Replay activations when a
notifier is registered.
Signed-off-by: Sven Peter <sven@xxxxxxxxxx>
---
drivers/usb/typec/bus.h | 6 +++++
drivers/usb/typec/class.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/usb/typec.h | 16 +++++++++++++
3 files changed, 81 insertions(+)
diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h
index 7df5deb1dd3a..4dc60c48c91e 100644
--- a/drivers/usb/typec/bus.h
+++ b/drivers/usb/typec/bus.h
@@ -3,6 +3,8 @@
#ifndef __USB_TYPEC_ALTMODE_H__
#define __USB_TYPEC_ALTMODE_H__
+#include <linux/mutex.h>
+#include <linux/notifier.h>
#include <linux/usb/typec_altmode.h>
struct typec_mux;
@@ -23,6 +25,10 @@ struct altmode {
struct altmode *partner;
struct altmode *plug[2];
+
+ /* Serializes active state changes and notifier registration. */
+ struct mutex state_lock;
+ struct blocking_notifier_head state_notifier;
};