From 368a2eb08ff291d863d5c273bfb09fc6fa6566d1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 8 Jan 2024 15:54:26 +1100 Subject: [PATCH] is31fl3733: change `write_register()` return type to `void` (#22824) --- drivers/led/issi/is31fl3733-mono.c | 12 +++--------- drivers/led/issi/is31fl3733-mono.h | 2 +- drivers/led/issi/is31fl3733.c | 12 +++--------- drivers/led/issi/is31fl3733.h | 2 +- keyboards/input_club/k_type/is31fl3733-dual.c | 12 +++--------- keyboards/input_club/k_type/is31fl3733-dual.h | 2 +- 6 files changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/led/issi/is31fl3733-mono.c b/drivers/led/issi/is31fl3733-mono.c index 21cd65a154..bd3d15c516 100644 --- a/drivers/led/issi/is31fl3733-mono.c +++ b/drivers/led/issi/is31fl3733-mono.c @@ -77,23 +77,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false}; uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0}; bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false}; -bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - // If the transaction fails function returns false. +void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { i2c_transfer_buffer[0] = reg; i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break; } #else - if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT); #endif - return true; } void is31fl3733_select_page(uint8_t addr, uint8_t page) { diff --git a/drivers/led/issi/is31fl3733-mono.h b/drivers/led/issi/is31fl3733-mono.h index dcb33e448f..5a588834b8 100644 --- a/drivers/led/issi/is31fl3733-mono.h +++ b/drivers/led/issi/is31fl3733-mono.h @@ -116,7 +116,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t addr, uint8_t sync); -bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); +void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3733_select_page(uint8_t addr, uint8_t page); bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c index 06de119c69..ad98bd3cec 100644 --- a/drivers/led/issi/is31fl3733.c +++ b/drivers/led/issi/is31fl3733.c @@ -76,23 +76,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false}; uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0}; bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false}; -bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - // If the transaction fails function returns false. +void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { i2c_transfer_buffer[0] = reg; i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break; } #else - if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT); #endif - return true; } void is31fl3733_select_page(uint8_t addr, uint8_t page) { diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h index a90325a6e9..f273f1f003 100644 --- a/drivers/led/issi/is31fl3733.h +++ b/drivers/led/issi/is31fl3733.h @@ -141,7 +141,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t addr, uint8_t sync); -bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); +void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data); void is31fl3733_select_page(uint8_t addr, uint8_t page); bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c index 385416439a..33734001e0 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.c +++ b/keyboards/input_club/k_type/is31fl3733-dual.c @@ -74,23 +74,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false}; uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0}; bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false}; -bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data) { - // If the transaction fails function returns false. +void is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data) { i2c_transfer_buffer[0] = reg; i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break; } #else - if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { - return false; - } + i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT); #endif - return true; } void is31fl3733_select_page(uint8_t index, uint8_t addr, uint8_t page) { diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h index 99a5ebbb82..3368794cba 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.h +++ b/keyboards/input_club/k_type/is31fl3733-dual.h @@ -83,7 +83,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT]; void is31fl3733_init_drivers(void); void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync); -bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data); +void is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data); void is31fl3733_select_page(uint8_t index, uint8_t addr, uint8_t page); bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer);