Skip to content

Commit 0079614

Browse files
LeoCX-Tsaiquinchou77
authored andcommitted
fwk: lilac: fix ucsi.c use error count
pd_chip_ucsi_info should use controller not port count it will let cci get error data from wrong point after writing back will cause EC to crash BRANCH=fwk-lilac-27116 BUG=None TEST=boot to OS, unplug/replug AC, type any Key check EC will not crash. Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent 981a6e0 commit 0079614

File tree

1 file changed

+5
-5
lines changed
  • zephyr/program/framework/src

1 file changed

+5
-5
lines changed

zephyr/program/framework/src/ucsi.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int ucsi_write_tunnel(void)
156156
}
157157

158158
if (cmd_need_broadcast) {
159-
for (int i = 0; i < PD_PORT_COUNT; i++) {
159+
for (int i = 0; i < PD_CHIP_COUNT; i++) {
160160

161161
/**
162162
* If the controller does not needs to respond ACK,
@@ -336,9 +336,9 @@ int ucsi_read_tunnel(int controller)
336336
CPRINTS("CCI_REG failed");
337337
/* we need to offset the pd connector number to correct number */
338338
port_indicator = (pd_chip_ucsi_info[controller].cci & 0xFE)>>1;
339-
if (port_indicator <= 0 || port_indicator > PORTS_PER_CONTROLLER) {
339+
if (port_indicator <= 0 || port_indicator > PD_PORT_COUNT) {
340340
/* Print the invalid port for debugging */
341-
if (ucsi_debug_enable && port_indicator > PORTS_PER_CONTROLLER)
341+
if (ucsi_debug_enable && port_indicator > PD_PORT_COUNT)
342342
CPRINTS("UCSI read invalid type-c port:%d", port_indicator);
343343
} else {
344344
new_port = (pd_ucsi_port_map[controller*2+port_indicator-1]);
@@ -522,7 +522,7 @@ void check_ucsi_event_from_host(void)
522522
if (read_complete) {
523523

524524
/* The highest priority of the PD chip is pd 0 */
525-
for (i = (PD_PORT_COUNT - 1); i >= 0; i--) {
525+
for (i = (PD_CHIP_COUNT - 1); i >= 0; i--) {
526526
if (pd_chip_ucsi_info[i].read_tunnel_complete) {
527527
message_in = pd_chip_ucsi_info[i].message_in;
528528
cci = &pd_chip_ucsi_info[i].cci;
@@ -538,7 +538,7 @@ void check_ucsi_event_from_host(void)
538538
* both controllers
539539
*/
540540
if (ucsi_check_all_pd_status(OPERATOR_AND)) {
541-
for (i = 0; i < PD_PORT_COUNT; i++) {
541+
for (i = 0; i < PD_CHIP_COUNT; i++) {
542542
if (command == UCSI_CMD_GET_ERROR_STATUS) {
543543
uint16_t error_information =
544544
(pd_chip_ucsi_info[i].message_in[1] << 8) |

0 commit comments

Comments
 (0)