/* Retrieves the Power Delivery message from the TCPC.  */
static int ucpd_get_rx_pending_msg(const struct device *dev, struct pd_msg *msg)
/* Retrieves the Power Delivery message from the TCPC.  */
static int ucpd_get_rx_pending_msg(const struct device *dev, struct pd_msg *msg)
{
	struct tcpc_data *data = dev->data;
	int ret = 0;
	if (*(uint32_t *)data->ucpd_rx_buffer == 0) {
		return -ENODATA;
	}
	if (msg == NULL) {
		return 0;
	}
	msg->type = *(uint16_t *)data->ucpd_rx_buffer;
	msg->header.raw_value = *((uint16_t *)data->ucpd_rx_buffer + 1);
	msg->len = PD_CONVERT_PD_HEADER_COUNT_TO_BYTES(msg->header.number_of_data_objects);
	memcpy(msg->data, (data->ucpd_rx_buffer +
			   PACKET_TYPE_SIZE +
			   MSG_HEADER_SIZE), msg->len);
	ret = msg->len + MSG_HEADER_SIZE;
	*(uint32_t *)data->ucpd_rx_buffer = 0;
	return ret;
}