summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/opticon.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2012-04-25 17:56:29 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-25 22:37:18 +0400
commit81d5a6729018ef18dcc1a555144ce91eb3c9abc4 (patch)
tree92e3fa4fa694477ff8a6210fb2bc590959e45e56 /drivers/usb/serial/opticon.c
parent33f7a67e477f780b82ef36ce358f6d5290d6a9b2 (diff)
downloadlinux-81d5a6729018ef18dcc1a555144ce91eb3c9abc4.tar.xz
USB: opticon: fix abuse of interface data
Fix abuse of interface data which was used to signal device disconnect. Use the usb_serial disconnect flag and mutex where appropriate. Note that tiocmget does not need to check for disconnect as it does not access the device. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/opticon.c')
-rw-r--r--drivers/usb/serial/opticon.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 82cc9d202b83..d31e997ebd27 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -401,8 +401,6 @@ static int opticon_tiocmget(struct tty_struct *tty)
int result = 0;
dbg("%s - port %d", __func__, port->number);
- if (!usb_get_intfdata(port->serial->interface))
- return -ENODEV;
spin_lock_irqsave(&priv->lock, flags);
if (priv->rts)
@@ -419,13 +417,13 @@ static int opticon_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{
struct usb_serial_port *port = tty->driver_data;
+ struct usb_serial *serial = port->serial;
struct opticon_private *priv = usb_get_serial_data(port->serial);
unsigned long flags;
bool rts;
bool changed = false;
+ int ret;
- if (!usb_get_intfdata(port->serial->interface))
- return -ENODEV;
/* We only support RTS so we only handle that */
spin_lock_irqsave(&priv->lock, flags);
@@ -441,7 +439,14 @@ static int opticon_tiocmset(struct tty_struct *tty,
return 0;
/* Send the new RTS state to the connected device */
- return send_control_msg(port, CONTROL_RTS, !rts);
+ mutex_lock(&serial->disc_mutex);
+ if (!serial->disconnected)
+ ret = send_control_msg(port, CONTROL_RTS, !rts);
+ else
+ ret = -ENODEV;
+ mutex_unlock(&serial->disc_mutex);
+
+ return ret;
}
static int get_serial_info(struct opticon_private *priv,