Skip to contentSkip to conversation

serial: Add flush function to NS16550 driver

PATCH Applied David Dgien 2 participants 2 messages May 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: Add flush function to NS16550 driver

Add flush function to NS16550 to remove bad characters being printed during reset

---
 drivers/serial/serial_ns16550.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/serial/serial_ns16550.c +12 -0
index 5d6cec82a..f117ab9dc 100644
@@ -308,6 +308,17 @@ static int ns16550_tstc(struct console_device *cdev)
 	return ((ns16550_read(cdev, lsr) & LSR_DR) != 0);
 }
 
+/**
+ * @brief Flush remaining characters in serial device
+ *
+ * @param[in] cdev pointer to console device
+ */
+static void ns16550_flush(struct console_device *cdev)
+{
+	/* Loop Doing Nothing */
+	while ((ns16550_read(cdev, lsr) & LSR_TEMT) == 0) ;
+}
+
 static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 {
 	struct device_node *np = dev->device_node;
@@ -501,6 +512,7 @@ static int ns16550_probe(struct device_d *dev)
 	cdev->putc = ns16550_putc;
 	cdev->getc = ns16550_getc;
 	cdev->setbrg = ns16550_setbaudrate;
+	cdev->flush = ns16550_flush;
 	cdev->linux_console_name = devtype->linux_console_name;
 
 	priv->fcrval = FCRVAL;
Signature · 7 lines
2.26.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 7 lines · David Dgien

Add flush function to NS16550 to remove bad characters being printed during reset

---
 drivers/serial/serial_ns16550.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Applied, thanks

Sascha

Quoted 40 lines
drivers/serial/serial_ns16550.c +12 -0
index 5d6cec82a..f117ab9dc 100644
@@ -308,6 +308,17 @@ static int ns16550_tstc(struct console_device *cdev)
 	return ((ns16550_read(cdev, lsr) & LSR_DR) != 0);
 }
 
+/**
+ * @brief Flush remaining characters in serial device
+ *
+ * @param[in] cdev pointer to console device
+ */
+static void ns16550_flush(struct console_device *cdev)
+{
+	/* Loop Doing Nothing */
+	while ((ns16550_read(cdev, lsr) & LSR_TEMT) == 0) ;
+}
+
 static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 {
 	struct device_node *np = dev->device_node;
@@ -501,6 +512,7 @@ static int ns16550_probe(struct device_d *dev)
 	cdev->putc = ns16550_putc;
 	cdev->getc = ns16550_getc;
 	cdev->setbrg = ns16550_setbaudrate;
+	cdev->flush = ns16550_flush;
 	cdev->linux_console_name = devtype->linux_console_name;
 
 	priv->fcrval = FCRVAL;
Signature · 7 lines
2.26.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox