linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] serdev: ttyport: enforce tty-driver open() requirement
@ 2017-10-16 13:06 Johan Hovold
  2017-10-16 13:06 ` [PATCH 2/2] serdev: ttyport: add missing open() error handling Johan Hovold
  2017-10-17 16:07 ` [PATCH 1/2] serdev: ttyport: enforce tty-driver open() requirement Rob Herring
  0 siblings, 2 replies; 7+ messages in thread
From: Johan Hovold @ 2017-10-16 13:06 UTC (permalink / raw)
  To: Rob Herring
  Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel,
	Johan Hovold

The tty-driver open routine is mandatory, but the serdev
tty-port-controller implementation did not treat it as such and would
instead fall back to calling tty_port_open() directly.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serdev/serdev-ttyport.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 302018d67efa..404f3fd070a7 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -102,10 +102,10 @@ static int ttyport_open(struct serdev_controller *ctrl)
 		return PTR_ERR(tty);
 	serport->tty = tty;
 
-	if (tty->ops->open)
-		tty->ops->open(serport->tty, NULL);
-	else
-		tty_port_open(serport->port, tty, NULL);
+	if (!tty->ops->open)
+		goto err_unlock;
+
+	tty->ops->open(serport->tty, NULL);
 
 	/* Bring the UART into a known 8 bits no parity hw fc state */
 	ktermios = tty->termios;
@@ -122,6 +122,12 @@ static int ttyport_open(struct serdev_controller *ctrl)
 
 	tty_unlock(serport->tty);
 	return 0;
+
+err_unlock:
+	tty_unlock(tty);
+	tty_release_struct(tty, serport->tty_idx);
+
+	return -ENODEV;
 }
 
 static void ttyport_close(struct serdev_controller *ctrl)
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-20 21:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-16 13:06 [PATCH 1/2] serdev: ttyport: enforce tty-driver open() requirement Johan Hovold
2017-10-16 13:06 ` [PATCH 2/2] serdev: ttyport: add missing open() error handling Johan Hovold
2017-10-17 16:08   ` Rob Herring
2017-10-18  7:01     ` Johan Hovold
2017-10-17 16:07 ` [PATCH 1/2] serdev: ttyport: enforce tty-driver open() requirement Rob Herring
2017-10-20 12:21   ` Greg Kroah-Hartman
2017-10-20 21:43     ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).