diff options
author | Oliver Neukum <oliver@neukum.org> | 2008-01-22 07:56:18 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:35:05 -0500 |
commit | 95bef012ea4a3cce437a4fcf59bb097d14944b0d (patch) | |
tree | bc9991b335211030bcc2ee76fdc42ae2fcccb645 /drivers/usb | |
parent | e33fe4d86f91127f6f7d931ff59ed6cbda06e72b (diff) |
USB: more serial drivers writing after disconnect
this covers the rest of the obvious cases by using the flags
and locks to guard against disconnect which were introduced
in the earlier patch against mos7720.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/airprime.c | 5 | ||||
-rw-r--r-- | drivers/usb/serial/cp2101.c | 5 | ||||
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 4 | ||||
-rw-r--r-- | drivers/usb/serial/garmin_gps.c | 17 | ||||
-rw-r--r-- | drivers/usb/serial/visor.c | 2 |
5 files changed, 24 insertions, 9 deletions
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 77bb893bf2e9..f156dba0300f 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -217,7 +217,10 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) | |||
217 | priv->rts_state = 0; | 217 | priv->rts_state = 0; |
218 | priv->dtr_state = 0; | 218 | priv->dtr_state = 0; |
219 | 219 | ||
220 | airprime_send_setup(port); | 220 | mutex_lock(&port->serial->disc_mutex); |
221 | if (!port->serial->disconnected) | ||
222 | airprime_send_setup(port); | ||
223 | mutex_lock(&port->serial->disc_mutex); | ||
221 | 224 | ||
222 | for (i = 0; i < NUM_READ_URBS; ++i) { | 225 | for (i = 0; i < NUM_READ_URBS; ++i) { |
223 | usb_kill_urb (priv->read_urbp[i]); | 226 | usb_kill_urb (priv->read_urbp[i]); |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index cd5f71b7f637..f3ca66017a03 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -348,7 +348,10 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
348 | usb_kill_urb(port->write_urb); | 348 | usb_kill_urb(port->write_urb); |
349 | usb_kill_urb(port->read_urb); | 349 | usb_kill_urb(port->read_urb); |
350 | 350 | ||
351 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); | 351 | mutex_lock(&port->serial->disc_mutex); |
352 | if (!port->serial->disconnected) | ||
353 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); | ||
354 | mutex_unlock(&port->serial->disc_mutex); | ||
352 | } | 355 | } |
353 | 356 | ||
354 | /* | 357 | /* |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 2c142bb04fe1..90dcc625f70d 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -1198,7 +1198,8 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) | |||
1198 | 1198 | ||
1199 | dbg("%s", __FUNCTION__); | 1199 | dbg("%s", __FUNCTION__); |
1200 | 1200 | ||
1201 | if (c_cflag & HUPCL){ | 1201 | mutex_lock(&port->serial->disc_mutex); |
1202 | if (c_cflag & HUPCL && !port->serial->disconnected){ | ||
1202 | /* Disable flow control */ | 1203 | /* Disable flow control */ |
1203 | if (usb_control_msg(port->serial->dev, | 1204 | if (usb_control_msg(port->serial->dev, |
1204 | usb_sndctrlpipe(port->serial->dev, 0), | 1205 | usb_sndctrlpipe(port->serial->dev, 0), |
@@ -1212,6 +1213,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) | |||
1212 | /* drop RTS and DTR */ | 1213 | /* drop RTS and DTR */ |
1213 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 1214 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
1214 | } /* Note change no line if hupcl is off */ | 1215 | } /* Note change no line if hupcl is off */ |
1216 | mutex_unlock(&port->serial->disc_mutex); | ||
1215 | 1217 | ||
1216 | /* cancel any scheduled reading */ | 1218 | /* cancel any scheduled reading */ |
1217 | cancel_delayed_work(&priv->rx_work); | 1219 | cancel_delayed_work(&priv->rx_work); |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index f1c90cfe7251..d74e43d69230 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1020,19 +1020,26 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) | |||
1020 | if (!serial) | 1020 | if (!serial) |
1021 | return; | 1021 | return; |
1022 | 1022 | ||
1023 | garmin_clear(garmin_data_p); | 1023 | mutex_lock(&port->serial->disc_mutex); |
1024 | if (!port->serial->disconnected) | ||
1025 | garmin_clear(garmin_data_p); | ||
1024 | 1026 | ||
1025 | /* shutdown our urbs */ | 1027 | /* shutdown our urbs */ |
1026 | usb_kill_urb (port->read_urb); | 1028 | usb_kill_urb (port->read_urb); |
1027 | usb_kill_urb (port->write_urb); | 1029 | usb_kill_urb (port->write_urb); |
1028 | 1030 | ||
1029 | if (noResponseFromAppLayer(garmin_data_p) || | 1031 | if (!port->serial->disconnected) { |
1030 | ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { | 1032 | if (noResponseFromAppLayer(garmin_data_p) || |
1031 | process_resetdev_request(port); | 1033 | ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { |
1032 | garmin_data_p->state = STATE_RESET; | 1034 | process_resetdev_request(port); |
1035 | garmin_data_p->state = STATE_RESET; | ||
1036 | } else { | ||
1037 | garmin_data_p->state = STATE_DISCONNECTED; | ||
1038 | } | ||
1033 | } else { | 1039 | } else { |
1034 | garmin_data_p->state = STATE_DISCONNECTED; | 1040 | garmin_data_p->state = STATE_DISCONNECTED; |
1035 | } | 1041 | } |
1042 | mutex_unlock(&port->serial->disc_mutex); | ||
1036 | } | 1043 | } |
1037 | 1044 | ||
1038 | 1045 | ||
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index c2347995c786..22b3f78a388c 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -362,7 +362,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) | |||
362 | kfree (transfer_buffer); | 362 | kfree (transfer_buffer); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | mutex_lock(&port->serial->disc_mutex); | 365 | mutex_unlock(&port->serial->disc_mutex); |
366 | 366 | ||
367 | if (stats) | 367 | if (stats) |
368 | dev_info(&port->dev, "Bytes In = %d Bytes Out = %d\n", | 368 | dev_info(&port->dev, "Bytes In = %d Bytes Out = %d\n", |