aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/cyberjack.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:09:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:22 -0400
commit95da310e66ee8090119596c70ca8432e57f9a97f (patch)
tree7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/cyberjack.c
parent1aa3692da57c773e5c76de55c5c4a953962d360e (diff)
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/cyberjack.c')
-rw-r--r--drivers/usb/serial/cyberjack.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index c164e2cf2752..546178ea6f2d 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -57,15 +57,18 @@ static int debug;
57#define CYBERJACK_PRODUCT_ID 0x0100 57#define CYBERJACK_PRODUCT_ID 0x0100
58 58
59/* Function prototypes */ 59/* Function prototypes */
60static int cyberjack_startup (struct usb_serial *serial); 60static int cyberjack_startup(struct usb_serial *serial);
61static void cyberjack_shutdown (struct usb_serial *serial); 61static void cyberjack_shutdown(struct usb_serial *serial);
62static int cyberjack_open (struct usb_serial_port *port, struct file *filp); 62static int cyberjack_open(struct tty_struct *tty,
63static void cyberjack_close (struct usb_serial_port *port, struct file *filp); 63 struct usb_serial_port *port, struct file *filp);
64static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count); 64static void cyberjack_close(struct tty_struct *tty,
65static int cyberjack_write_room( struct usb_serial_port *port ); 65 struct usb_serial_port *port, struct file *filp);
66static void cyberjack_read_int_callback (struct urb *urb); 66static int cyberjack_write(struct tty_struct *tty,
67static void cyberjack_read_bulk_callback (struct urb *urb); 67 struct usb_serial_port *port, const unsigned char *buf, int count);
68static void cyberjack_write_bulk_callback (struct urb *urb); 68static int cyberjack_write_room( struct tty_struct *tty);
69static void cyberjack_read_int_callback(struct urb *urb);
70static void cyberjack_read_bulk_callback(struct urb *urb);
71static void cyberjack_write_bulk_callback(struct urb *urb);
69 72
70static struct usb_device_id id_table [] = { 73static struct usb_device_id id_table [] = {
71 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
@@ -111,7 +114,7 @@ struct cyberjack_private {
111}; 114};
112 115
113/* do some startup allocations not currently performed by usb_serial_probe() */ 116/* do some startup allocations not currently performed by usb_serial_probe() */
114static int cyberjack_startup (struct usb_serial *serial) 117static int cyberjack_startup(struct usb_serial *serial)
115{ 118{
116 struct cyberjack_private *priv; 119 struct cyberjack_private *priv;
117 int i; 120 int i;
@@ -145,7 +148,7 @@ static int cyberjack_startup (struct usb_serial *serial)
145 return( 0 ); 148 return( 0 );
146} 149}
147 150
148static void cyberjack_shutdown (struct usb_serial *serial) 151static void cyberjack_shutdown(struct usb_serial *serial)
149{ 152{
150 int i; 153 int i;
151 154
@@ -159,7 +162,8 @@ static void cyberjack_shutdown (struct usb_serial *serial)
159 } 162 }
160} 163}
161 164
162static int cyberjack_open (struct usb_serial_port *port, struct file *filp) 165static int cyberjack_open(struct tty_struct *tty,
166 struct usb_serial_port *port, struct file *filp)
163{ 167{
164 struct cyberjack_private *priv; 168 struct cyberjack_private *priv;
165 unsigned long flags; 169 unsigned long flags;
@@ -174,7 +178,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
174 * the data through, otherwise it is scheduled, and with high 178 * the data through, otherwise it is scheduled, and with high
175 * data rates (like with OHCI) data can get lost. 179 * data rates (like with OHCI) data can get lost.
176 */ 180 */
177 port->tty->low_latency = 1; 181 if (tty)
182 tty->low_latency = 1;
178 183
179 priv = usb_get_serial_port_data(port); 184 priv = usb_get_serial_port_data(port);
180 spin_lock_irqsave(&priv->lock, flags); 185 spin_lock_irqsave(&priv->lock, flags);
@@ -186,7 +191,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
186 return result; 191 return result;
187} 192}
188 193
189static void cyberjack_close (struct usb_serial_port *port, struct file *filp) 194static void cyberjack_close(struct tty_struct *tty,
195 struct usb_serial_port *port, struct file *filp)
190{ 196{
191 dbg("%s - port %d", __func__, port->number); 197 dbg("%s - port %d", __func__, port->number);
192 198
@@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
197 } 203 }
198} 204}
199 205
200static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count) 206static int cyberjack_write(struct tty_struct *tty,
207 struct usb_serial_port *port, const unsigned char *buf, int count)
201{ 208{
202 struct usb_serial *serial = port->serial; 209 struct usb_serial *serial = port->serial;
203 struct cyberjack_private *priv = usb_get_serial_port_data(port); 210 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -292,13 +299,13 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
292 return (count); 299 return (count);
293} 300}
294 301
295static int cyberjack_write_room( struct usb_serial_port *port ) 302static int cyberjack_write_room(struct tty_struct *tty)
296{ 303{
297 /* FIXME: .... */ 304 /* FIXME: .... */
298 return CYBERJACK_LOCAL_BUF_SIZE; 305 return CYBERJACK_LOCAL_BUF_SIZE;
299} 306}
300 307
301static void cyberjack_read_int_callback( struct urb *urb ) 308static void cyberjack_read_int_callback(struct urb *urb)
302{ 309{
303 struct usb_serial_port *port = urb->context; 310 struct usb_serial_port *port = urb->context;
304 struct cyberjack_private *priv = usb_get_serial_port_data(port); 311 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -355,7 +362,7 @@ resubmit:
355 dbg("%s - usb_submit_urb(int urb)", __func__); 362 dbg("%s - usb_submit_urb(int urb)", __func__);
356} 363}
357 364
358static void cyberjack_read_bulk_callback (struct urb *urb) 365static void cyberjack_read_bulk_callback(struct urb *urb)
359{ 366{
360 struct usb_serial_port *port = urb->context; 367 struct usb_serial_port *port = urb->context;
361 struct cyberjack_private *priv = usb_get_serial_port_data(port); 368 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -374,7 +381,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
374 return; 381 return;
375 } 382 }
376 383
377 tty = port->tty; 384 tty = port->port.tty;
378 if (!tty) { 385 if (!tty) {
379 dbg("%s - ignoring since device not open\n", __func__); 386 dbg("%s - ignoring since device not open\n", __func__);
380 return; 387 return;
@@ -407,7 +414,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
407 } 414 }
408} 415}
409 416
410static void cyberjack_write_bulk_callback (struct urb *urb) 417static void cyberjack_write_bulk_callback(struct urb *urb)
411{ 418{
412 struct usb_serial_port *port = urb->context; 419 struct usb_serial_port *port = urb->context;
413 struct cyberjack_private *priv = usb_get_serial_port_data(port); 420 struct cyberjack_private *priv = usb_get_serial_port_data(port);