From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: "Jaromír Škorpil" <Jerry@jrr.cz>, "Johan Hovold" <johan@kernel.org>
Subject: [PATCH 1/5] USB: serial: cp210x: disable interface on errors in open
Date: Mon, 13 Jul 2020 12:55:13 +0200 [thread overview]
Message-ID: <20200713105517.27796-2-johan@kernel.org> (raw)
In-Reply-To: <20200713105517.27796-1-johan@kernel.org>
Try to disable the serial interface in the unlikely event that generic
open() fails.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/cp210x.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index a90801ef0055..c01c7863dd1a 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -824,7 +824,16 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
if (tty)
cp210x_change_speed(tty, port, NULL);
- return usb_serial_generic_open(tty, port);
+ result = usb_serial_generic_open(tty, port);
+ if (result)
+ goto err_disable;
+
+ return 0;
+
+err_disable:
+ cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE);
+
+ return result;
}
static void cp210x_close(struct usb_serial_port *port)
--
2.26.2
next prev parent reply other threads:[~2020-07-13 10:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 10:55 [PATCH 0/5] USB: serial: cp210x: add support for line-status events Johan Hovold
2020-07-13 10:55 ` Johan Hovold [this message]
2020-07-13 10:55 ` [PATCH 2/5] " Johan Hovold
2020-07-13 10:55 ` [PATCH 3/5] USB: serial: cp210x: add support for TIOCGICOUNT Johan Hovold
2020-07-13 10:55 ` [PATCH 4/5] USB: serial: cp210x: drop unnecessary packed attributes Johan Hovold
2020-07-13 10:55 ` [PATCH 5/5] USB: serial: cp210x: use in-kernel types in port data Johan Hovold
2020-07-13 13:41 ` [PATCH 0/5] USB: serial: cp210x: add support for line-status events Greg KH
2020-07-14 9:55 ` Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200713105517.27796-2-johan@kernel.org \
--to=johan@kernel.org \
--cc=Jerry@jrr.cz \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).