/* Poll the device for input. 
This is a non-blocking function. */
static int uart_altera_poll_in(const struct device *dev, unsigned char *p_char)
/* Poll the device for input. 
This is a non-blocking function. */
static int uart_altera_poll_in(const struct device *dev, unsigned char *p_char)
{
	const struct uart_altera_device_config *config = dev->config;
	struct uart_altera_device_data *data = dev->data;
	int ret_val = -1;
	uint32_t status;
	__ASSERT(p_char != NULL, "p_char is null pointer!");
	if (p_char == NULL) {
		return -EINVAL;
	}
	k_spinlock_key_t key = k_spin_lock(&data->lock);
	status = sys_read32(config->base + ALTERA_AVALON_UART_STATUS_REG_OFFSET);
	if (status & ALTERA_AVALON_UART_STATUS_RRDY_MSK) {
		*p_char = sys_read32(config->base + ALTERA_AVALON_UART_RXDATA_REG_OFFSET);
		ret_val = 0;
	}
	k_spin_unlock(&data->lock, key);
	return ret_val;
}