From: Wilson Lee Date: Fri, 3 Nov 2017 06:39:51 +0000 (-0700) Subject: serial: nulldev: Implement "pending" function to fix tstc return "true" X-Git-Tag: v2018.01-rc1~98 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b12907f279ca25acb79838ede89905ff5c1dfcc5;p=oweals%2Fu-boot.git 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 Cc: Joe Hershberger Cc: Keng Soon Cheah Cc: Chen Yee Chew Cc: Bin Meng --- diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c index 07683086db..17b2310ee3 100644 --- a/drivers/serial/serial_nulldev.c +++ b/drivers/serial/serial_nulldev.c @@ -18,6 +18,11 @@ 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; @@ -36,6 +41,7 @@ static const struct udevice_id nulldev_serial_ids[] = { const struct dm_serial_ops nulldev_serial_ops = { .putc = nulldev_serial_putc, + .pending = nulldev_serial_pending, .getc = nulldev_serial_getc, .setbrg = nulldev_serial_setbrg, };