diff options
author | Alan Cox <alan@redhat.com> | 2008-10-13 05:39:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 12:51:41 -0400 |
commit | 4a90f09b20f4622dcbff1f0e1e6bae1704f8ad8c (patch) | |
tree | 9b275f88f2705cb10121d5982741aef3a088a7c8 /drivers/usb/serial/keyspan_pda.c | |
parent | 95f9bfc6b76e862265a2d70ae061eec18fe14140 (diff) |
tty: usb-serial krefs
Use kref in the USB serial drivers so that we don't free tty structures
from under the URB receive handlers as has historically been the case if
you were unlucky. This also gives us a framework for general tty drivers to
use tty_port objects and refcount.
Contains two err->dev_err changes merged together to fix clashes in the
-next tree.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/keyspan_pda.c')
-rw-r--r-- | drivers/usb/serial/keyspan_pda.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 040040a267d9..99e9a14c5bf6 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -172,8 +172,9 @@ static void keyspan_pda_wakeup_write(struct work_struct *work) | |||
172 | struct keyspan_pda_private *priv = | 172 | struct keyspan_pda_private *priv = |
173 | container_of(work, struct keyspan_pda_private, wakeup_work); | 173 | container_of(work, struct keyspan_pda_private, wakeup_work); |
174 | struct usb_serial_port *port = priv->port; | 174 | struct usb_serial_port *port = priv->port; |
175 | 175 | struct tty_struct *tty = tty_port_tty_get(&port->port); | |
176 | tty_wakeup(port->port.tty); | 176 | tty_wakeup(tty); |
177 | tty_kref_put(tty); | ||
177 | } | 178 | } |
178 | 179 | ||
179 | static void keyspan_pda_request_unthrottle(struct work_struct *work) | 180 | static void keyspan_pda_request_unthrottle(struct work_struct *work) |
@@ -205,7 +206,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) | |||
205 | static void keyspan_pda_rx_interrupt(struct urb *urb) | 206 | static void keyspan_pda_rx_interrupt(struct urb *urb) |
206 | { | 207 | { |
207 | struct usb_serial_port *port = urb->context; | 208 | struct usb_serial_port *port = urb->context; |
208 | struct tty_struct *tty = port->port.tty; | 209 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
209 | unsigned char *data = urb->transfer_buffer; | 210 | unsigned char *data = urb->transfer_buffer; |
210 | int retval; | 211 | int retval; |
211 | int status = urb->status; | 212 | int status = urb->status; |
@@ -222,7 +223,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
222 | /* this urb is terminated, clean up */ | 223 | /* this urb is terminated, clean up */ |
223 | dbg("%s - urb shutting down with status: %d", | 224 | dbg("%s - urb shutting down with status: %d", |
224 | __func__, status); | 225 | __func__, status); |
225 | return; | 226 | goto out; |
226 | default: | 227 | default: |
227 | dbg("%s - nonzero urb status received: %d", | 228 | dbg("%s - nonzero urb status received: %d", |
228 | __func__, status); | 229 | __func__, status); |
@@ -261,8 +262,11 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) | |||
261 | exit: | 262 | exit: |
262 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 263 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
263 | if (retval) | 264 | if (retval) |
264 | err("%s - usb_submit_urb failed with result %d", | 265 | dev_err(&port->dev, |
265 | __func__, retval); | 266 | "%s - usb_submit_urb failed with result %d", |
267 | __func__, retval); | ||
268 | out: | ||
269 | tty_kref_put(tty); | ||
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||