diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:09:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:22 -0400 |
commit | 95da310e66ee8090119596c70ca8432e57f9a97f (patch) | |
tree | 7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/omninet.c | |
parent | 1aa3692da57c773e5c76de55c5c4a953962d360e (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/omninet.c')
-rw-r--r-- | drivers/usb/serial/omninet.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 7b7422f49478..5a2d045562f0 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -61,12 +61,12 @@ static int debug; | |||
61 | #define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */ | 61 | #define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */ |
62 | 62 | ||
63 | /* function prototypes */ | 63 | /* function prototypes */ |
64 | static int omninet_open (struct usb_serial_port *port, struct file *filp); | 64 | static int omninet_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); |
65 | static void omninet_close (struct usb_serial_port *port, struct file *filp); | 65 | static void omninet_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); |
66 | static void omninet_read_bulk_callback (struct urb *urb); | 66 | static void omninet_read_bulk_callback (struct urb *urb); |
67 | static void omninet_write_bulk_callback (struct urb *urb); | 67 | static void omninet_write_bulk_callback (struct urb *urb); |
68 | static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 68 | static int omninet_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); |
69 | static int omninet_write_room (struct usb_serial_port *port); | 69 | static int omninet_write_room (struct tty_struct *tty); |
70 | static void omninet_shutdown (struct usb_serial *serial); | 70 | static void omninet_shutdown (struct usb_serial *serial); |
71 | static int omninet_attach (struct usb_serial *serial); | 71 | static int omninet_attach (struct usb_serial *serial); |
72 | 72 | ||
@@ -157,7 +157,8 @@ static int omninet_attach (struct usb_serial *serial) | |||
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
160 | static int omninet_open (struct usb_serial_port *port, struct file *filp) | 160 | static int omninet_open(struct tty_struct *tty, |
161 | struct usb_serial_port *port, struct file *filp) | ||
161 | { | 162 | { |
162 | struct usb_serial *serial = port->serial; | 163 | struct usb_serial *serial = port->serial; |
163 | struct usb_serial_port *wport; | 164 | struct usb_serial_port *wport; |
@@ -166,7 +167,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) | |||
166 | dbg("%s - port %d", __func__, port->number); | 167 | dbg("%s - port %d", __func__, port->number); |
167 | 168 | ||
168 | wport = serial->port[1]; | 169 | wport = serial->port[1]; |
169 | wport->tty = port->tty; | 170 | wport->port.tty = tty; /* FIXME */ |
170 | 171 | ||
171 | /* Start reading from the device */ | 172 | /* Start reading from the device */ |
172 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 173 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
@@ -181,7 +182,8 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) | |||
181 | return result; | 182 | return result; |
182 | } | 183 | } |
183 | 184 | ||
184 | static void omninet_close (struct usb_serial_port *port, struct file * filp) | 185 | static void omninet_close(struct tty_struct *tty, |
186 | struct usb_serial_port *port, struct file * filp) | ||
185 | { | 187 | { |
186 | dbg("%s - port %d", __func__, port->number); | 188 | dbg("%s - port %d", __func__, port->number); |
187 | usb_kill_urb(port->read_urb); | 189 | usb_kill_urb(port->read_urb); |
@@ -221,9 +223,9 @@ static void omninet_read_bulk_callback (struct urb *urb) | |||
221 | 223 | ||
222 | if (urb->actual_length && header->oh_len) { | 224 | if (urb->actual_length && header->oh_len) { |
223 | for (i = 0; i < header->oh_len; i++) { | 225 | for (i = 0; i < header->oh_len; i++) { |
224 | tty_insert_flip_char(port->tty, data[OMNINET_DATAOFFSET + i], 0); | 226 | tty_insert_flip_char(port->port.tty, data[OMNINET_DATAOFFSET + i], 0); |
225 | } | 227 | } |
226 | tty_flip_buffer_push(port->tty); | 228 | tty_flip_buffer_push(port->port.tty); |
227 | } | 229 | } |
228 | 230 | ||
229 | /* Continue trying to always read */ | 231 | /* Continue trying to always read */ |
@@ -238,7 +240,8 @@ static void omninet_read_bulk_callback (struct urb *urb) | |||
238 | return; | 240 | return; |
239 | } | 241 | } |
240 | 242 | ||
241 | static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count) | 243 | static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, |
244 | const unsigned char *buf, int count) | ||
242 | { | 245 | { |
243 | struct usb_serial *serial = port->serial; | 246 | struct usb_serial *serial = port->serial; |
244 | struct usb_serial_port *wport = serial->port[1]; | 247 | struct usb_serial_port *wport = serial->port[1]; |
@@ -290,8 +293,9 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf | |||
290 | } | 293 | } |
291 | 294 | ||
292 | 295 | ||
293 | static int omninet_write_room (struct usb_serial_port *port) | 296 | static int omninet_write_room (struct tty_struct *tty) |
294 | { | 297 | { |
298 | struct usb_serial_port *port = tty->driver_data; | ||
295 | struct usb_serial *serial = port->serial; | 299 | struct usb_serial *serial = port->serial; |
296 | struct usb_serial_port *wport = serial->port[1]; | 300 | struct usb_serial_port *wport = serial->port[1]; |
297 | 301 | ||