Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions subsys/pmci/mctp/mctp_i2c_gpio_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ int mctp_i2c_gpio_target_read_requested(struct i2c_target_config *config, uint8_
*val = pkt_len;
break;
case MCTP_I2C_GPIO_TX_MSG_ADDR:
if (b->tx_pkt == NULL || b->tx_pkt->start >= b->tx_pkt->end) {
LOG_WRN("No packet to send");
ret = -EIO;
break;
}
b->rxtx = true;
*val = b->tx_pkt->data[b->tx_pkt->start];
b->tx_idx = b->tx_pkt->start;
Expand All @@ -113,17 +118,21 @@ int mctp_i2c_gpio_target_read_processed(struct i2c_target_config *config, uint8_
struct mctp_binding_i2c_gpio_target *b =
CONTAINER_OF(config, struct mctp_binding_i2c_gpio_target, i2c_target_cfg);

b->tx_idx += 1;

if (b->reg_addr != MCTP_I2C_GPIO_TX_MSG_ADDR) {
goto out;
}

if (b->tx_idx > b->tx_pkt->end) {
if (b->tx_pkt == NULL) {
LOG_WRN("No packet to process");
return -EIO;
}

if (b->tx_idx + 1 >= b->tx_pkt->end) {
LOG_WRN("rrp past end reg %d", b->reg_addr);
return -EIO;
}

b->tx_idx += 1;
*val = b->tx_pkt->data[b->tx_idx];

out:
Expand Down Expand Up @@ -164,6 +173,10 @@ int mctp_i2c_gpio_target_stop(struct i2c_target_config *config)
}
}

/* After stop, a new register must be selected */
b->reg_addr = MCTP_I2C_GPIO_INVALID_ADDR;
b->rxtx = false;

return 0;
}

Expand Down