]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: ucsi: huawei_gaokun: move typec_altmode off stack
authorArnd Bergmann <arnd@arndb.de>
Thu, 18 Jun 2026 14:33:14 +0000 (16:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jul 2026 12:14:37 +0000 (14:14 +0200)
The typec_altmode structure contains a 'struct device' object
that cannot be allocated on the stack because of its size, even
when ignoring the lifetime rules:

drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c:326:13: error: stack frame size (1456) exceeds limit (1280) in 'gaokun_ucsi_usb_notify_ind' [-Werror,-Wframe-larger-than]
  326 | static void gaokun_ucsi_usb_notify_ind(struct gaokun_ucsi *uec)

Since the altmode is always associated with a port here, move
it into the port object and avoid at least the stack allocation
issue.

Fixes: 1c2b66a7d725 ("usb: ucsi: huawei_gaokun: support mode switching")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Pengyu Luo <mitltlatltl@gmail.com>
Link: https://patch.msgid.link/20260618143341.1900221-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c

index ad669d2f8b9ce3e8b31a8b61d96bd957794a3025..ca1b534cb183d9857f931e5f7d39dc33550c236e 100644 (file)
@@ -84,6 +84,8 @@ struct gaokun_ucsi_port {
        struct auxiliary_device *bridge;
 
        struct typec_mux *typec_mux;
+       struct typec_mux_state state;
+       struct typec_altmode dp_alt;
 
        int idx;
        enum gaokun_ucsi_ccx ccx;
@@ -292,24 +294,22 @@ static int gaokun_ucsi_refresh(struct gaokun_ucsi *uec)
 static void gaokun_ucsi_handle_usb_mode(struct gaokun_ucsi_port *port)
 {
        struct gaokun_ucsi *uec = port->ucsi;
-       struct typec_mux_state state = {};
-       struct typec_altmode dp_alt = {};
        int idx = port->idx, ret;
 
        /*
         * For every typec port on this platform, the only mode-switch is
         * controlled by its qmp combo phy which consumes svid and mode only.
         */
-       dp_alt.svid = port->svid;
-       state.mode = port->mode;
-       state.alt = &dp_alt;
+       port->dp_alt.svid = port->svid;
+       port->state.mode = port->mode;
+       port->state.alt = &port->dp_alt;
 
        if (idx >= uec->num_ports) {
                dev_warn(uec->dev, "altmode port out of range: %d\n", idx);
                return;
        }
 
-       ret = typec_mux_set(port->typec_mux, &state);
+       ret = typec_mux_set(port->typec_mux, &port->state);
        if (ret)
                dev_err(uec->dev, "failed to set mux %d\n", ret);