From: Alessio Igor Bogani <abogani@texware.it>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Johan Hovold <jhovold@gmail.com>, Alan Cox <alan@linux.intel.com>,
Daniel Mack <daniel@caiaq.de>,
"Mark J. Adamson" <mark.adamson@ftdichip.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Alessio Igor Bogani <abogani@texware.it>
Subject: [PATCH] USB: ftdi_sio: Fix locking for change_speed() function
Date: Mon, 8 Mar 2010 14:10:03 +0100 [thread overview]
Message-ID: <1268053803-7666-1-git-send-email-abogani@texware.it> (raw)
The change_speed() function set the baudrate of the device: so this function
should be serialized against multiple calls. Use the cfg_lock mutex to do this.
Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
drivers/usb/serial/ftdi_sio.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 6af0dfa..963a70f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1272,8 +1272,8 @@ check_and_exit:
(priv->flags & ASYNC_SPD_MASK)) ||
(((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
(old_priv.custom_divisor != priv->custom_divisor))) {
- mutex_unlock(&priv->cfg_lock);
change_speed(tty, port);
+ mutex_unlock(&priv->cfg_lock);
}
else
mutex_unlock(&priv->cfg_lock);
@@ -2264,9 +2264,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
} else {
/* set the baudrate determined before */
+ mutex_lock(&priv->cfg_lock);
if (change_speed(tty, port))
dev_err(&port->dev, "%s urb failed to set baudrate\n",
__func__);
+ mutex_unlock(&priv->cfg_lock);
/* Ensure RTS and DTR are raised when baudrate changed from 0 */
if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
--
1.6.3.3
next reply other threads:[~2010-03-08 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 13:10 Alessio Igor Bogani [this message]
2010-03-08 17:35 ` Alan Cox
2010-03-13 17:35 Alessio Igor Bogani
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=1268053803-7666-1-git-send-email-abogani@texware.it \
--to=abogani@texware.it \
--cc=alan@linux.intel.com \
--cc=daniel@caiaq.de \
--cc=gregkh@suse.de \
--cc=jhovold@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark.adamson@ftdichip.com \
/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
all inboxes | Powered by JetHome®