Re: [PATCH v2 01/22] usb: typec: Add alternate mode state notifiers
From: Heikki Krogerus
Date: Tue Sep 08 2026 - 08:01:42 EST
On Sun, Sep 06, 2026 at 08:36:24PM +0200, Sven Peter wrote:
> The Apple Silicon USB4/Thunderbolt driver needs to be made aware of
> 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/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 10a783b738ef..914a6f0844c5 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -19,6 +19,7 @@ struct typec_plug;
> struct typec_port;
> struct typec_altmode_ops;
> struct typec_cable_ops;
> +struct notifier_block;
>
> struct bus_type;
> struct fwnode_handle;
> @@ -184,6 +185,21 @@ struct typec_port *typec_altmode2port(struct typec_altmode *alt);
>
> void typec_altmode_update_active(struct typec_altmode *alt, bool active);
>
> +/**
> + * enum typec_altmode_event - USB Type-C alternate mode state event
> + * @TYPEC_ALTMODE_ENTERED: The alternate mode has been entered
> + * @TYPEC_ALTMODE_EXITED: The alternate mode has been exited
> + */
> +enum typec_altmode_event {
> + TYPEC_ALTMODE_ENTERED,
> + TYPEC_ALTMODE_EXITED,
> +};
Mode entry and exit are not the only state changes that can happen.
> +int typec_altmode_register_notifier(struct typec_altmode *alt,
> + struct notifier_block *nb);
> +int typec_altmode_unregister_notifier(struct typec_altmode *alt,
> + struct notifier_block *nb);
This is basically a partial revert of this commit bbe80c9a89b8 ("usb:
typec: altmode: Remove the notification chain"). Can you check if it
would enough to just completely revert that one.
Thanks,
--
heikki