u-boot/drivers/serial/serial_nulldev.c
Wilson Lee b12907f279 serial: nulldev: Implement "pending" function to fix tstc return "true"
In U-boot, serial_tstc was use to determine is there have a character in
serial console that pending for read. If there is no "pending" function
implemented in serial driver, the serial-uclass will return "true(1)"
to indicate there have a character pending to read.

Thus, read a character from nulldev serial will result in continuous
getting -EAGAIN return which might lead system to hang.

This commit is to fix a bug in nulldev serial which implement "pending"
function in nulldev serial to always indicate there is no character in
console that pending for read.

Signed-off-by: Wilson Lee <wilson.lee@ni.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Keng Soon Cheah <keng.soon.cheah@ni.com>
Cc: Chen Yee Chew <chen.yee.chew@ni.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
2017-11-17 07:44:13 -05:00

54 lines
976 B
C

/*
* Copyright (c) 2015 National Instruments
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <serial.h>
static int nulldev_serial_setbrg(struct udevice *dev, int baudrate)
{
return 0;
}
static int nulldev_serial_getc(struct udevice *dev)
{
return -EAGAIN;
}
static int nulldev_serial_pending(struct udevice *dev, bool input)
{
return 0;
}
static int nulldev_serial_input(struct udevice *dev)
{
return 0;
}
static int nulldev_serial_putc(struct udevice *dev, const char ch)
{
return 0;
}
static const struct udevice_id nulldev_serial_ids[] = {
{ .compatible = "nulldev-serial" },
{ }
};
const struct dm_serial_ops nulldev_serial_ops = {
.putc = nulldev_serial_putc,
.pending = nulldev_serial_pending,
.getc = nulldev_serial_getc,
.setbrg = nulldev_serial_setbrg,
};
U_BOOT_DRIVER(serial_nulldev) = {
.name = "serial_nulldev",
.id = UCLASS_SERIAL,
.of_match = nulldev_serial_ids,
.ops = &nulldev_serial_ops,
};