From f6111d49bbfeb90fdb86c4595ba339590b364da7 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 25 Feb 2020 14:10:04 +0000 Subject: Split - Avoid race condition during matrix_init_quantum (#8235) * Avoid race condition during matrix_init_quantum * spelling is hard --- quantum/split_common/split_util.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'quantum/split_common/split_util.c') diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 103bc97142..fb6a3b85af 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -81,19 +81,8 @@ __attribute__((weak)) bool is_keyboard_master(void) { return (usbstate == MASTER); } -static void keyboard_master_setup(void) { -#if defined(USE_I2C) -# ifdef SSD1306OLED - matrix_master_OLED_init(); -# endif -#endif - transport_master_init(); -} - -static void keyboard_slave_setup(void) { transport_slave_init(); } - // this code runs before the keyboard is fully initialized -void keyboard_split_setup(void) { +void split_pre_init(void) { isLeftHand = is_keyboard_left(); #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) @@ -106,8 +95,18 @@ void keyboard_split_setup(void) { #endif if (is_keyboard_master()) { - keyboard_master_setup(); - } else { - keyboard_slave_setup(); +#if defined(USE_I2C) && defined(SSD1306OLED) + matrix_master_OLED_init(); +#endif + transport_master_init(); + } +} + +// this code runs after the keyboard is fully initialized +// - avoids race condition during matrix_init_quantum where slave can start +// receiving before the init process has completed +void split_post_init(void) { + if (!is_keyboard_master()) { + transport_slave_init(); } } -- cgit v1.2.1