diff options
author | Madhusudanarao Amara <madhusudanarao.amara@intel.corp-partner.google.com> | 2021-01-26 00:12:43 +0530 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-26 00:02:00 +0000 |
commit | 7ebc7659f157e2dc787660773bf12b5641993c6b (patch) | |
tree | 52fe0971c194c61ec3cb2f831f847128444df457 | |
parent | 5305a5d619c78b8d249e196fa952ca0617859434 (diff) | |
download | chrome-ec-7ebc7659f157e2dc787660773bf12b5641993c6b.tar.gz |
usb_mux: Use atomic operations for updating the flag
Atomic operations used in updating the LPM flag
BUG=None
BRANCH=None
TEST=Disconnect typeC devices and then connect back, devices are detected
Signed-off-by: Madhusudanarao Amara <madhusudanarao.amara@intel.corp-partner.google.com>
Change-Id: I6c3fa4b9c63436a16465012fe715ce28995ed179
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2648145
Tested-by: Ayushee Shah <ayushee.shah@intel.com>
Reviewed-by: Tanu Malhotra <tanu.malhotra@intel.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r-- | driver/usb_mux/usb_mux.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c index f9b33c9c01..22be81843d 100644 --- a/driver/usb_mux/usb_mux.c +++ b/driver/usb_mux/usb_mux.c @@ -5,6 +5,7 @@ /* USB mux high-level driver. */ +#include "atomic.h" #include "common.h" #include "console.h" #include "hooks.h" @@ -28,7 +29,7 @@ static int enable_debug_prints; * Flags will reset to 0 after sysjump; This works for current flags as LPM will * get reset in the init method which is called during PD task startup. */ -static uint8_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; #define USB_MUX_FLAG_IN_LPM BIT(0) /* Device is in low power mode. */ @@ -143,7 +144,7 @@ static void enter_low_power_mode(int port) * want know know that we tried to put the device in low power mode * so we can re-initialize the device on the next access. */ - flags[port] |= USB_MUX_FLAG_IN_LPM; + atomic_or(&flags[port], USB_MUX_FLAG_IN_LPM); /* Apply any low power customization if present */ configure_mux(port, USB_MUX_LOW_POWER, NULL); @@ -173,9 +174,9 @@ void usb_mux_init(int port) * as in LPM mode to try initialization again. */ if (rv == EC_ERROR_NOT_POWERED) - flags[port] |= USB_MUX_FLAG_IN_LPM; + atomic_or(&flags[port], USB_MUX_FLAG_IN_LPM); else - flags[port] &= ~USB_MUX_FLAG_IN_LPM; + atomic_clear_bits(&flags[port], USB_MUX_FLAG_IN_LPM); } /* |