Re: [PATCH] platform/chrome: cros_ec_typec: Stop altmode work before unregistering ports

From: Tzung-Bi Shih

Date: Mon Sep 28 2026 - 08:42:48 EST


On Thu, Sep 17, 2026 at 04:42:09PM -0400, Myeonghun Pak wrote:
> partner altmodes. Disabling also prevents a partner callback from
> requeueing the work while its driver is being removed. Use the common

Would the work be scheduled even if the driver is about to remove()?

> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 50a68819ceb7bbfbd888ca919d678d4c75237c26..e91bbc219c077067294935dd5602c1aec636cfa6 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -378,6 +378,7 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
> if (!typec->ports[i])
> continue;
>
> + cros_typec_altmodes_stop(typec->ports[i]);

Shouldn't this be called in cros_typec_unregister_port_altmodes()?

> diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c
...
> +void cros_typec_altmodes_stop(struct cros_typec_port *port)
> +{
> + struct cros_typec_altmode_data *adata;
> + int i;
> +
> + for (i = 0; i < CROS_EC_ALTMODE_MAX; i++) {
> + if (!port->port_altmode[i])
> + continue;
> +
> + adata = typec_altmode_get_drvdata(port->port_altmode[i]);
> + if (adata)
> + disable_work_sync(&adata->work);

This is a driver teardown path: cancel_work_sync() should be sufficient.