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

thunderbolt: Fix a logic error in wake on connect

commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
on USB4 ports") introduced a sysfs file to control wake up policy
for a given USB4 port that defaulted to disabled.

However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
on connect and disconnect over suspend") I found that it was working
even without making changes to the power/wakeup file (which defaults
to disabled). This is because of a logic error doing a bitwise or
of the wake-on-connect flag with device_may_wakeup() which should
have been a logical AND.

Adjust the logic so that policy is only applied when wakeup is
actually enabled.

Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

authored by

Mario Limonciello and committed by
Mika Westerberg
1a760d10 4bfeea6e

+2 -2
+2 -2
drivers/thunderbolt/usb4.c
··· 440 440 bool configured = val & PORT_CS_19_PC; 441 441 usb4 = port->usb4; 442 442 443 - if (((flags & TB_WAKE_ON_CONNECT) | 443 + if (((flags & TB_WAKE_ON_CONNECT) && 444 444 device_may_wakeup(&usb4->dev)) && !configured) 445 445 val |= PORT_CS_19_WOC; 446 - if (((flags & TB_WAKE_ON_DISCONNECT) | 446 + if (((flags & TB_WAKE_ON_DISCONNECT) && 447 447 device_may_wakeup(&usb4->dev)) && configured) 448 448 val |= PORT_CS_19_WOD; 449 449 if ((flags & TB_WAKE_ON_USB4) && configured)