/* This routine read SHI input buffer to msg buffer until we have received a certain number of bytes  */
static int shi_npcx_read_inbuf_wait(const struct device *dev, uint32_t szbytes)
/* This routine read SHI input buffer to msg buffer until we have received a certain number of bytes  */
static int shi_npcx_read_inbuf_wait(const struct device *dev, uint32_t szbytes)
{
	struct shi_npcx_data *data = dev->data;
	struct shi_reg *const inst = HAL_INSTANCE(dev);
	for (uint32_t i = 0; i < szbytes; i++, data->rx_ctx->len++) {
		while (data->rx_buf == inst->IBUF + shi_npcx_read_buf_pointer(inst)) {
			if (k_cycle_get_64() >= data->rx_deadline) {
				return 0;
			}
		}
		*data->rx_msg++ = *data->rx_buf++;
	}
	return 1;
}