ps8xxx: Check for register access errors
This adds error checking to ps8815_disable_rp_detect_workaround_check.
BRANCH=none
TEST=buildall passes
@@ -665,14 +665,14 @@ static int ps8xxx_dci_disable(int port)
return EC_ERROR_INVAL;
}
-__maybe_unused static void ps8815_transmit_buffer_workaround_check(int port)
+__maybe_unused static int ps8815_transmit_buffer_workaround_check(int port)
{
int p1_addr;
int val;
int status;
if (product_id[port] != PS8815_PRODUCT_ID)
- return;
+ return EC_SUCCESS;
/* P1 registers are always accessible on PS8815 */
p1_addr = PS8751_P3_TO_P1_FLAGS(tcpc_config[port].i2c_info.addr_flags);
@@ -680,7 +680,7 @@ __maybe_unused static void ps8815_transmit_buffer_workaround_check(int port)
status = tcpc_addr_read16(port, p1_addr, PS8815_P1_REG_HW_REVISION,
&val);
if (status != EC_SUCCESS)
- return;
+ return status;
switch (val) {
case 0x0a00:
@@ -690,9 +690,11 @@ __maybe_unused static void ps8815_transmit_buffer_workaround_check(int port)
default:
break;
}
+
+ return EC_SUCCESS;
}
-__maybe_unused static void ps8815_disable_rp_detect_workaround_check(int port)
+__maybe_unused static int ps8815_disable_rp_detect_workaround_check(int port)
{
int val;
int rv;
@@ -704,13 +706,15 @@ __maybe_unused static void ps8815_disable_rp_detect_workaround_check(int port)
reg = get_reg_by_product(port, REG_FW_VER);
rv = tcpc_read(port, reg, &val);
if (rv != EC_SUCCESS)
- return;
+ return rv;
/*
* RP detect is a problem in firmware version 0x10 and older.
*/
if (val <= 0x10)
ps8815_disable_rp_detect[port] = true;
+
+ return EC_SUCCESS;
}
__overridable void board_ps8xxx_tcpc_init(int port)
@@ -723,8 +727,12 @@ static int ps8xxx_tcpm_init(int port)
product_id[port] = board_get_ps8xxx_product_id(port);
if (IS_ENABLED(CONFIG_USB_PD_TCPM_PS8815)) {
- ps8815_transmit_buffer_workaround_check(port);
- ps8815_disable_rp_detect_workaround_check(port);
+ status = ps8815_transmit_buffer_workaround_check(port);
+ if (status != EC_SUCCESS)
+ return status;
+ status = ps8815_disable_rp_detect_workaround_check(port);
+ if (status != EC_SUCCESS)
+ return status;
}
board_ps8xxx_tcpc_init(port);
