Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: serial: imx: Only configure the wake register when device is set as wakeup source

Currently, the i.MX UART driver enables wake-related registers for all
UART devices by default. However, this is unnecessary for devices that
are not configured as wakeup sources. To address this, add a
device_may_wakeup() check before configuring the UART wake-related
registers.

Fixes: db1a9b55004c ("tty: serial: imx: Allow UART to be a source for wakeup")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251002045259.2725461-2-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sherry Sun and committed by
Greg Kroah-Hartman
d55f3d23 18bdfccf

+14
+14
drivers/tty/serial/imx.c
··· 2697 2697 /* called with irq off */ 2698 2698 static void imx_uart_enable_wakeup(struct imx_port *sport, bool on) 2699 2699 { 2700 + struct tty_port *port = &sport->port.state->port; 2701 + struct device *tty_dev; 2702 + bool may_wake = false; 2700 2703 u32 ucr3; 2704 + 2705 + scoped_guard(tty_port_tty, port) { 2706 + struct tty_struct *tty = scoped_tty(); 2707 + 2708 + tty_dev = tty->dev; 2709 + may_wake = tty_dev && device_may_wakeup(tty_dev); 2710 + } 2711 + 2712 + /* only configure the wake register when device set as wakeup source */ 2713 + if (!may_wake) 2714 + return; 2701 2715 2702 2716 uart_port_lock_irq(&sport->port); 2703 2717