diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-30 03:54:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:47 -0400 |
commit | f34d7a5b7010b82fe97da95496b9971435530062 (patch) | |
tree | 87e2abec1e33ed4fe5e63ee2fd000bc2ad745e57 | |
parent | 251b8dd7eee30fda089a1dc088abf4fc9a0dee9c (diff) |
tty: The big operations rework
- Operations are now a shared const function block as with most other Linux
objects
- Introduce wrappers for some optional functions to get consistent behaviour
- Wrap put_char which used to be patched by the tty layer
- Document which functions are needed/optional
- Make put_char report success/fail
- Cache the driver->ops pointer in the tty as tty->ops
- Remove various surplus lock calls we no longer need
- Remove proc_write method as noted by Alexey Dobriyan
- Introduce some missing sanity checks where certain driver/ldisc
combinations would oops as they didn't check needed methods were present
[akpm@linux-foundation.org: fix fs/compat_ioctl.c build]
[akpm@linux-foundation.org: fix isicom]
[akpm@linux-foundation.org: fix arch/ia64/hp/sim/simserial.c build]
[akpm@linux-foundation.org: fix kgdb]
Signed-off-by: Alan Cox <alan@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
30 files changed, 537 insertions, 664 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index eb0c32a85fd7..23cafc80d2a4 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c | |||
@@ -210,21 +210,23 @@ static void do_softint(struct work_struct *private_) | |||
210 | printk(KERN_ERR "simserial: do_softint called\n"); | 210 | printk(KERN_ERR "simserial: do_softint called\n"); |
211 | } | 211 | } |
212 | 212 | ||
213 | static void rs_put_char(struct tty_struct *tty, unsigned char ch) | 213 | static int rs_put_char(struct tty_struct *tty, unsigned char ch) |
214 | { | 214 | { |
215 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 215 | struct async_struct *info = (struct async_struct *)tty->driver_data; |
216 | unsigned long flags; | 216 | unsigned long flags; |
217 | 217 | ||
218 | if (!tty || !info->xmit.buf) return; | 218 | if (!tty || !info->xmit.buf) |
219 | return 0; | ||
219 | 220 | ||
220 | local_irq_save(flags); | 221 | local_irq_save(flags); |
221 | if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) { | 222 | if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) { |
222 | local_irq_restore(flags); | 223 | local_irq_restore(flags); |
223 | return; | 224 | return 0; |
224 | } | 225 | } |
225 | info->xmit.buf[info->xmit.head] = ch; | 226 | info->xmit.buf[info->xmit.head] = ch; |
226 | info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1); | 227 | info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1); |
227 | local_irq_restore(flags); | 228 | local_irq_restore(flags); |
229 | return 1; | ||
228 | } | 230 | } |
229 | 231 | ||
230 | static void transmit_chars(struct async_struct *info, int *intr_done) | 232 | static void transmit_chars(struct async_struct *info, int *intr_done) |
@@ -621,7 +623,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
621 | * the line discipline to only process XON/XOFF characters. | 623 | * the line discipline to only process XON/XOFF characters. |
622 | */ | 624 | */ |
623 | shutdown(info); | 625 | shutdown(info); |
624 | if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); | 626 | if (tty->ops->flush_buffer) |
627 | tty->ops->flush_buffer(tty); | ||
625 | if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty); | 628 | if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty); |
626 | info->event = 0; | 629 | info->event = 0; |
627 | info->tty = NULL; | 630 | info->tty = NULL; |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 7e31d5f1bc8a..a6c2619ec782 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -143,7 +143,7 @@ restart: | |||
143 | int len; | 143 | int len; |
144 | 144 | ||
145 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 145 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
146 | len = tty->driver->write(tty, skb->data, skb->len); | 146 | len = tty->ops->write(tty, skb->data, skb->len); |
147 | hdev->stat.byte_tx += len; | 147 | hdev->stat.byte_tx += len; |
148 | 148 | ||
149 | skb_pull(skb, len); | 149 | skb_pull(skb, len); |
@@ -190,8 +190,7 @@ static int hci_uart_flush(struct hci_dev *hdev) | |||
190 | 190 | ||
191 | /* Flush any pending characters in the driver and discipline. */ | 191 | /* Flush any pending characters in the driver and discipline. */ |
192 | tty_ldisc_flush(tty); | 192 | tty_ldisc_flush(tty); |
193 | if (tty->driver && tty->driver->flush_buffer) | 193 | tty_driver_flush_buffer(tty); |
194 | tty->driver->flush_buffer(tty); | ||
195 | 194 | ||
196 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 195 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
197 | hu->proto->flush(hu); | 196 | hu->proto->flush(hu); |
@@ -285,9 +284,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
285 | 284 | ||
286 | if (tty->ldisc.flush_buffer) | 285 | if (tty->ldisc.flush_buffer) |
287 | tty->ldisc.flush_buffer(tty); | 286 | tty->ldisc.flush_buffer(tty); |
288 | 287 | tty_driver_flush_buffer(tty); | |
289 | if (tty->driver && tty->driver->flush_buffer) | ||
290 | tty->driver->flush_buffer(tty); | ||
291 | 288 | ||
292 | return 0; | 289 | return 0; |
293 | } | 290 | } |
@@ -374,8 +371,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *f | |||
374 | spin_unlock(&hu->rx_lock); | 371 | spin_unlock(&hu->rx_lock); |
375 | 372 | ||
376 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && | 373 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && |
377 | tty->driver->unthrottle) | 374 | tty->ops->unthrottle) |
378 | tty->driver->unthrottle(tty); | 375 | tty->ops->unthrottle(tty); |
379 | } | 376 | } |
380 | 377 | ||
381 | static int hci_uart_register_dev(struct hci_uart *hu) | 378 | static int hci_uart_register_dev(struct hci_uart *hu) |
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index c4f4ca31f7c0..5ef69dcd2588 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c | |||
@@ -169,7 +169,7 @@ static int Fip_firmware_size; | |||
169 | static int ip2_open(PTTY, struct file *); | 169 | static int ip2_open(PTTY, struct file *); |
170 | static void ip2_close(PTTY, struct file *); | 170 | static void ip2_close(PTTY, struct file *); |
171 | static int ip2_write(PTTY, const unsigned char *, int); | 171 | static int ip2_write(PTTY, const unsigned char *, int); |
172 | static void ip2_putchar(PTTY, unsigned char); | 172 | static int ip2_putchar(PTTY, unsigned char); |
173 | static void ip2_flush_chars(PTTY); | 173 | static void ip2_flush_chars(PTTY); |
174 | static int ip2_write_room(PTTY); | 174 | static int ip2_write_room(PTTY); |
175 | static int ip2_chars_in_buf(PTTY); | 175 | static int ip2_chars_in_buf(PTTY); |
@@ -1616,10 +1616,9 @@ ip2_close( PTTY tty, struct file *pFile ) | |||
1616 | 1616 | ||
1617 | serviceOutgoingFifo ( pCh->pMyBord ); | 1617 | serviceOutgoingFifo ( pCh->pMyBord ); |
1618 | 1618 | ||
1619 | if ( tty->driver->flush_buffer ) | 1619 | if ( tty->driver->ops->flush_buffer ) |
1620 | tty->driver->flush_buffer(tty); | 1620 | tty->driver->ops->flush_buffer(tty); |
1621 | if ( tty->ldisc.flush_buffer ) | 1621 | tty_ldisc_flush(tty); |
1622 | tty->ldisc.flush_buffer(tty); | ||
1623 | tty->closing = 0; | 1622 | tty->closing = 0; |
1624 | 1623 | ||
1625 | pCh->pTTY = NULL; | 1624 | pCh->pTTY = NULL; |
@@ -1738,7 +1737,7 @@ ip2_write( PTTY tty, const unsigned char *pData, int count) | |||
1738 | /* */ | 1737 | /* */ |
1739 | /* */ | 1738 | /* */ |
1740 | /******************************************************************************/ | 1739 | /******************************************************************************/ |
1741 | static void | 1740 | static int |
1742 | ip2_putchar( PTTY tty, unsigned char ch ) | 1741 | ip2_putchar( PTTY tty, unsigned char ch ) |
1743 | { | 1742 | { |
1744 | i2ChanStrPtr pCh = tty->driver_data; | 1743 | i2ChanStrPtr pCh = tty->driver_data; |
@@ -1753,6 +1752,7 @@ ip2_putchar( PTTY tty, unsigned char ch ) | |||
1753 | ip2_flush_chars( tty ); | 1752 | ip2_flush_chars( tty ); |
1754 | } else | 1753 | } else |
1755 | write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); | 1754 | write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); |
1755 | return 1; | ||
1756 | 1756 | ||
1757 | // ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch ); | 1757 | // ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch ); |
1758 | } | 1758 | } |
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 57b115272aaa..9c6be8da220c 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -1140,28 +1140,29 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf, | |||
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | /* put_char et all */ | 1142 | /* put_char et all */ |
1143 | static void isicom_put_char(struct tty_struct *tty, unsigned char ch) | 1143 | static int isicom_put_char(struct tty_struct *tty, unsigned char ch) |
1144 | { | 1144 | { |
1145 | struct isi_port *port = tty->driver_data; | 1145 | struct isi_port *port = tty->driver_data; |
1146 | struct isi_board *card = port->card; | 1146 | struct isi_board *card = port->card; |
1147 | unsigned long flags; | 1147 | unsigned long flags; |
1148 | 1148 | ||
1149 | if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) | 1149 | if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) |
1150 | return; | 1150 | return 0; |
1151 | 1151 | ||
1152 | if (!port->xmit_buf) | 1152 | if (!port->xmit_buf) |
1153 | return; | 1153 | return 0; |
1154 | 1154 | ||
1155 | spin_lock_irqsave(&card->card_lock, flags); | 1155 | spin_lock_irqsave(&card->card_lock, flags); |
1156 | if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) | 1156 | if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { |
1157 | goto out; | 1157 | spin_unlock_irqrestore(&card->card_lock, flags); |
1158 | return 0; | ||
1159 | } | ||
1158 | 1160 | ||
1159 | port->xmit_buf[port->xmit_head++] = ch; | 1161 | port->xmit_buf[port->xmit_head++] = ch; |
1160 | port->xmit_head &= (SERIAL_XMIT_SIZE - 1); | 1162 | port->xmit_head &= (SERIAL_XMIT_SIZE - 1); |
1161 | port->xmit_cnt++; | 1163 | port->xmit_cnt++; |
1162 | spin_unlock_irqrestore(&card->card_lock, flags); | 1164 | spin_unlock_irqrestore(&card->card_lock, flags); |
1163 | out: | 1165 | return 1; |
1164 | return; | ||
1165 | } | 1166 | } |
1166 | 1167 | ||
1167 | /* flush_chars et all */ | 1168 | /* flush_chars et all */ |
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 60b934adea65..d1c50b3302e5 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -1230,7 +1230,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1230 | 1230 | ||
1231 | if (rep && | 1231 | if (rep && |
1232 | (!vc_kbd_mode(kbd, VC_REPEAT) || | 1232 | (!vc_kbd_mode(kbd, VC_REPEAT) || |
1233 | (tty && !L_ECHO(tty) && tty->driver->chars_in_buffer(tty)))) { | 1233 | (tty && !L_ECHO(tty) && tty_chars_in_buffer(tty)))) { |
1234 | /* | 1234 | /* |
1235 | * Don't repeat a key if the input buffers are not empty and the | 1235 | * Don't repeat a key if the input buffers are not empty and the |
1236 | * characters get aren't echoed locally. This makes key repeat | 1236 | * characters get aren't echoed locally. This makes key repeat |
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c index a07c0af4819e..a35bfd7ee80e 100644 --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c | |||
@@ -342,12 +342,10 @@ static int n_hdlc_tty_open (struct tty_struct *tty) | |||
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | /* Flush any pending characters in the driver and discipline. */ | 344 | /* Flush any pending characters in the driver and discipline. */ |
345 | |||
346 | if (tty->ldisc.flush_buffer) | 345 | if (tty->ldisc.flush_buffer) |
347 | tty->ldisc.flush_buffer (tty); | 346 | tty->ldisc.flush_buffer(tty); |
348 | 347 | ||
349 | if (tty->driver->flush_buffer) | 348 | tty_driver_flush_buffer(tty); |
350 | tty->driver->flush_buffer (tty); | ||
351 | 349 | ||
352 | if (debuglevel >= DEBUG_LEVEL_INFO) | 350 | if (debuglevel >= DEBUG_LEVEL_INFO) |
353 | printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__); | 351 | printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__); |
@@ -399,7 +397,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) | |||
399 | 397 | ||
400 | /* Send the next block of data to device */ | 398 | /* Send the next block of data to device */ |
401 | tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); | 399 | tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); |
402 | actual = tty->driver->write(tty, tbuf->buf, tbuf->count); | 400 | actual = tty->ops->write(tty, tbuf->buf, tbuf->count); |
403 | 401 | ||
404 | /* rollback was possible and has been done */ | 402 | /* rollback was possible and has been done */ |
405 | if (actual == -ERESTARTSYS) { | 403 | if (actual == -ERESTARTSYS) { |
@@ -752,8 +750,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, | |||
752 | 750 | ||
753 | case TIOCOUTQ: | 751 | case TIOCOUTQ: |
754 | /* get the pending tx byte count in the driver */ | 752 | /* get the pending tx byte count in the driver */ |
755 | count = tty->driver->chars_in_buffer ? | 753 | count = tty_chars_in_buffer(tty); |
756 | tty->driver->chars_in_buffer(tty) : 0; | ||
757 | /* add size of next output frame in queue */ | 754 | /* add size of next output frame in queue */ |
758 | spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); | 755 | spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); |
759 | if (n_hdlc->tx_buf_list.head) | 756 | if (n_hdlc->tx_buf_list.head) |
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 3f6486e9f1ec..902169062332 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c | |||
@@ -376,8 +376,9 @@ static void put_char(struct r3964_info *pInfo, unsigned char ch) | |||
376 | if (tty == NULL) | 376 | if (tty == NULL) |
377 | return; | 377 | return; |
378 | 378 | ||
379 | if (tty->driver->put_char) { | 379 | /* FIXME: put_char should not be called from an IRQ */ |
380 | tty->driver->put_char(tty, ch); | 380 | if (tty->ops->put_char) { |
381 | tty->ops->put_char(tty, ch); | ||
381 | } | 382 | } |
382 | pInfo->bcc ^= ch; | 383 | pInfo->bcc ^= ch; |
383 | } | 384 | } |
@@ -386,12 +387,9 @@ static void flush(struct r3964_info *pInfo) | |||
386 | { | 387 | { |
387 | struct tty_struct *tty = pInfo->tty; | 388 | struct tty_struct *tty = pInfo->tty; |
388 | 389 | ||
389 | if (tty == NULL) | 390 | if (tty == NULL || tty->ops->flush_chars == NULL) |
390 | return; | 391 | return; |
391 | 392 | tty->ops->flush_chars(tty); | |
392 | if (tty->driver->flush_chars) { | ||
393 | tty->driver->flush_chars(tty); | ||
394 | } | ||
395 | } | 393 | } |
396 | 394 | ||
397 | static void trigger_transmit(struct r3964_info *pInfo) | 395 | static void trigger_transmit(struct r3964_info *pInfo) |
@@ -449,12 +447,11 @@ static void transmit_block(struct r3964_info *pInfo) | |||
449 | struct r3964_block_header *pBlock = pInfo->tx_first; | 447 | struct r3964_block_header *pBlock = pInfo->tx_first; |
450 | int room = 0; | 448 | int room = 0; |
451 | 449 | ||
452 | if ((tty == NULL) || (pBlock == NULL)) { | 450 | if (tty == NULL || pBlock == NULL) { |
453 | return; | 451 | return; |
454 | } | 452 | } |
455 | 453 | ||
456 | if (tty->driver->write_room) | 454 | room = tty_write_room(tty); |
457 | room = tty->driver->write_room(tty); | ||
458 | 455 | ||
459 | TRACE_PS("transmit_block %p, room %d, length %d", | 456 | TRACE_PS("transmit_block %p, room %d, length %d", |
460 | pBlock, room, pBlock->length); | 457 | pBlock, room, pBlock->length); |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index e1518e17e09d..abc93a93dcdd 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -149,8 +149,8 @@ static void check_unthrottle(struct tty_struct *tty) | |||
149 | { | 149 | { |
150 | if (tty->count && | 150 | if (tty->count && |
151 | test_and_clear_bit(TTY_THROTTLED, &tty->flags) && | 151 | test_and_clear_bit(TTY_THROTTLED, &tty->flags) && |
152 | tty->driver->unthrottle) | 152 | tty->ops->unthrottle) |
153 | tty->driver->unthrottle(tty); | 153 | tty->ops->unthrottle(tty); |
154 | } | 154 | } |
155 | 155 | ||
156 | /** | 156 | /** |
@@ -273,7 +273,7 @@ static int opost(unsigned char c, struct tty_struct *tty) | |||
273 | { | 273 | { |
274 | int space, spaces; | 274 | int space, spaces; |
275 | 275 | ||
276 | space = tty->driver->write_room(tty); | 276 | space = tty_write_room(tty); |
277 | if (!space) | 277 | if (!space) |
278 | return -1; | 278 | return -1; |
279 | 279 | ||
@@ -286,7 +286,7 @@ static int opost(unsigned char c, struct tty_struct *tty) | |||
286 | if (O_ONLCR(tty)) { | 286 | if (O_ONLCR(tty)) { |
287 | if (space < 2) | 287 | if (space < 2) |
288 | return -1; | 288 | return -1; |
289 | tty->driver->put_char(tty, '\r'); | 289 | tty_put_char(tty, '\r'); |
290 | tty->column = 0; | 290 | tty->column = 0; |
291 | } | 291 | } |
292 | tty->canon_column = tty->column; | 292 | tty->canon_column = tty->column; |
@@ -308,7 +308,7 @@ static int opost(unsigned char c, struct tty_struct *tty) | |||
308 | if (space < spaces) | 308 | if (space < spaces) |
309 | return -1; | 309 | return -1; |
310 | tty->column += spaces; | 310 | tty->column += spaces; |
311 | tty->driver->write(tty, " ", spaces); | 311 | tty->ops->write(tty, " ", spaces); |
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | tty->column += spaces; | 314 | tty->column += spaces; |
@@ -325,7 +325,7 @@ static int opost(unsigned char c, struct tty_struct *tty) | |||
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | tty->driver->put_char(tty, c); | 328 | tty_put_char(tty, c); |
329 | unlock_kernel(); | 329 | unlock_kernel(); |
330 | return 0; | 330 | return 0; |
331 | } | 331 | } |
@@ -352,7 +352,7 @@ static ssize_t opost_block(struct tty_struct *tty, | |||
352 | int i; | 352 | int i; |
353 | const unsigned char *cp; | 353 | const unsigned char *cp; |
354 | 354 | ||
355 | space = tty->driver->write_room(tty); | 355 | space = tty_write_room(tty); |
356 | if (!space) | 356 | if (!space) |
357 | return 0; | 357 | return 0; |
358 | if (nr > space) | 358 | if (nr > space) |
@@ -390,28 +390,15 @@ static ssize_t opost_block(struct tty_struct *tty, | |||
390 | } | 390 | } |
391 | } | 391 | } |
392 | break_out: | 392 | break_out: |
393 | if (tty->driver->flush_chars) | 393 | if (tty->ops->flush_chars) |
394 | tty->driver->flush_chars(tty); | 394 | tty->ops->flush_chars(tty); |
395 | i = tty->driver->write(tty, buf, i); | 395 | i = tty->ops->write(tty, buf, i); |
396 | unlock_kernel(); | 396 | unlock_kernel(); |
397 | return i; | 397 | return i; |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | /** | 401 | /** |
402 | * put_char - write character to driver | ||
403 | * @c: character (or part of unicode symbol) | ||
404 | * @tty: terminal device | ||
405 | * | ||
406 | * Queue a byte to the driver layer for output | ||
407 | */ | ||
408 | |||
409 | static inline void put_char(unsigned char c, struct tty_struct *tty) | ||
410 | { | ||
411 | tty->driver->put_char(tty, c); | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * echo_char - echo characters | 402 | * echo_char - echo characters |
416 | * @c: unicode byte to echo | 403 | * @c: unicode byte to echo |
417 | * @tty: terminal device | 404 | * @tty: terminal device |
@@ -423,8 +410,8 @@ static inline void put_char(unsigned char c, struct tty_struct *tty) | |||
423 | static void echo_char(unsigned char c, struct tty_struct *tty) | 410 | static void echo_char(unsigned char c, struct tty_struct *tty) |
424 | { | 411 | { |
425 | if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') { | 412 | if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') { |
426 | put_char('^', tty); | 413 | tty_put_char(tty, '^'); |
427 | put_char(c ^ 0100, tty); | 414 | tty_put_char(tty, c ^ 0100); |
428 | tty->column += 2; | 415 | tty->column += 2; |
429 | } else | 416 | } else |
430 | opost(c, tty); | 417 | opost(c, tty); |
@@ -433,7 +420,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty) | |||
433 | static inline void finish_erasing(struct tty_struct *tty) | 420 | static inline void finish_erasing(struct tty_struct *tty) |
434 | { | 421 | { |
435 | if (tty->erasing) { | 422 | if (tty->erasing) { |
436 | put_char('/', tty); | 423 | tty_put_char(tty, '/'); |
437 | tty->column++; | 424 | tty->column++; |
438 | tty->erasing = 0; | 425 | tty->erasing = 0; |
439 | } | 426 | } |
@@ -517,7 +504,7 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
517 | if (L_ECHO(tty)) { | 504 | if (L_ECHO(tty)) { |
518 | if (L_ECHOPRT(tty)) { | 505 | if (L_ECHOPRT(tty)) { |
519 | if (!tty->erasing) { | 506 | if (!tty->erasing) { |
520 | put_char('\\', tty); | 507 | tty_put_char(tty, '\\'); |
521 | tty->column++; | 508 | tty->column++; |
522 | tty->erasing = 1; | 509 | tty->erasing = 1; |
523 | } | 510 | } |
@@ -525,7 +512,7 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
525 | echo_char(c, tty); | 512 | echo_char(c, tty); |
526 | while (--cnt > 0) { | 513 | while (--cnt > 0) { |
527 | head = (head+1) & (N_TTY_BUF_SIZE-1); | 514 | head = (head+1) & (N_TTY_BUF_SIZE-1); |
528 | put_char(tty->read_buf[head], tty); | 515 | tty_put_char(tty, tty->read_buf[head]); |
529 | } | 516 | } |
530 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { | 517 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { |
531 | echo_char(ERASE_CHAR(tty), tty); | 518 | echo_char(ERASE_CHAR(tty), tty); |
@@ -553,22 +540,22 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
553 | /* Now backup to that column. */ | 540 | /* Now backup to that column. */ |
554 | while (tty->column > col) { | 541 | while (tty->column > col) { |
555 | /* Can't use opost here. */ | 542 | /* Can't use opost here. */ |
556 | put_char('\b', tty); | 543 | tty_put_char(tty, '\b'); |
557 | if (tty->column > 0) | 544 | if (tty->column > 0) |
558 | tty->column--; | 545 | tty->column--; |
559 | } | 546 | } |
560 | } else { | 547 | } else { |
561 | if (iscntrl(c) && L_ECHOCTL(tty)) { | 548 | if (iscntrl(c) && L_ECHOCTL(tty)) { |
562 | put_char('\b', tty); | 549 | tty_put_char(tty, '\b'); |
563 | put_char(' ', tty); | 550 | tty_put_char(tty, ' '); |
564 | put_char('\b', tty); | 551 | tty_put_char(tty, '\b'); |
565 | if (tty->column > 0) | 552 | if (tty->column > 0) |
566 | tty->column--; | 553 | tty->column--; |
567 | } | 554 | } |
568 | if (!iscntrl(c) || L_ECHOCTL(tty)) { | 555 | if (!iscntrl(c) || L_ECHOCTL(tty)) { |
569 | put_char('\b', tty); | 556 | tty_put_char(tty, '\b'); |
570 | put_char(' ', tty); | 557 | tty_put_char(tty, ' '); |
571 | put_char('\b', tty); | 558 | tty_put_char(tty, '\b'); |
572 | if (tty->column > 0) | 559 | if (tty->column > 0) |
573 | tty->column--; | 560 | tty->column--; |
574 | } | 561 | } |
@@ -599,8 +586,7 @@ static inline void isig(int sig, struct tty_struct *tty, int flush) | |||
599 | kill_pgrp(tty->pgrp, sig, 1); | 586 | kill_pgrp(tty->pgrp, sig, 1); |
600 | if (flush || !L_NOFLSH(tty)) { | 587 | if (flush || !L_NOFLSH(tty)) { |
601 | n_tty_flush_buffer(tty); | 588 | n_tty_flush_buffer(tty); |
602 | if (tty->driver->flush_buffer) | 589 | tty_driver_flush_buffer(tty); |
603 | tty->driver->flush_buffer(tty); | ||
604 | } | 590 | } |
605 | } | 591 | } |
606 | 592 | ||
@@ -732,7 +718,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
732 | tty->lnext = 0; | 718 | tty->lnext = 0; |
733 | if (L_ECHO(tty)) { | 719 | if (L_ECHO(tty)) { |
734 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { | 720 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { |
735 | put_char('\a', tty); /* beep if no space */ | 721 | tty_put_char(tty, '\a'); /* beep if no space */ |
736 | return; | 722 | return; |
737 | } | 723 | } |
738 | /* Record the column of first canon char. */ | 724 | /* Record the column of first canon char. */ |
@@ -776,8 +762,7 @@ send_signal: | |||
776 | */ | 762 | */ |
777 | if (!L_NOFLSH(tty)) { | 763 | if (!L_NOFLSH(tty)) { |
778 | n_tty_flush_buffer(tty); | 764 | n_tty_flush_buffer(tty); |
779 | if (tty->driver->flush_buffer) | 765 | tty_driver_flush_buffer(tty); |
780 | tty->driver->flush_buffer(tty); | ||
781 | } | 766 | } |
782 | if (L_ECHO(tty)) | 767 | if (L_ECHO(tty)) |
783 | echo_char(c, tty); | 768 | echo_char(c, tty); |
@@ -806,8 +791,8 @@ send_signal: | |||
806 | if (L_ECHO(tty)) { | 791 | if (L_ECHO(tty)) { |
807 | finish_erasing(tty); | 792 | finish_erasing(tty); |
808 | if (L_ECHOCTL(tty)) { | 793 | if (L_ECHOCTL(tty)) { |
809 | put_char('^', tty); | 794 | tty_put_char(tty, '^'); |
810 | put_char('\b', tty); | 795 | tty_put_char(tty, '\b'); |
811 | } | 796 | } |
812 | } | 797 | } |
813 | return; | 798 | return; |
@@ -828,7 +813,7 @@ send_signal: | |||
828 | if (c == '\n') { | 813 | if (c == '\n') { |
829 | if (L_ECHO(tty) || L_ECHONL(tty)) { | 814 | if (L_ECHO(tty) || L_ECHONL(tty)) { |
830 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) | 815 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) |
831 | put_char('\a', tty); | 816 | tty_put_char(tty, '\a'); |
832 | opost('\n', tty); | 817 | opost('\n', tty); |
833 | } | 818 | } |
834 | goto handle_newline; | 819 | goto handle_newline; |
@@ -846,7 +831,7 @@ send_signal: | |||
846 | */ | 831 | */ |
847 | if (L_ECHO(tty)) { | 832 | if (L_ECHO(tty)) { |
848 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) | 833 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) |
849 | put_char('\a', tty); | 834 | tty_put_char(tty, '\a'); |
850 | /* Record the column of first canon char. */ | 835 | /* Record the column of first canon char. */ |
851 | if (tty->canon_head == tty->read_head) | 836 | if (tty->canon_head == tty->read_head) |
852 | tty->canon_column = tty->column; | 837 | tty->canon_column = tty->column; |
@@ -876,7 +861,7 @@ handle_newline: | |||
876 | finish_erasing(tty); | 861 | finish_erasing(tty); |
877 | if (L_ECHO(tty)) { | 862 | if (L_ECHO(tty)) { |
878 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { | 863 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { |
879 | put_char('\a', tty); /* beep if no space */ | 864 | tty_put_char(tty, '\a'); /* beep if no space */ |
880 | return; | 865 | return; |
881 | } | 866 | } |
882 | if (c == '\n') | 867 | if (c == '\n') |
@@ -980,8 +965,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
980 | break; | 965 | break; |
981 | } | 966 | } |
982 | } | 967 | } |
983 | if (tty->driver->flush_chars) | 968 | if (tty->ops->flush_chars) |
984 | tty->driver->flush_chars(tty); | 969 | tty->ops->flush_chars(tty); |
985 | } | 970 | } |
986 | 971 | ||
987 | n_tty_set_room(tty); | 972 | n_tty_set_room(tty); |
@@ -1000,8 +985,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
1000 | if (tty->receive_room < TTY_THRESHOLD_THROTTLE) { | 985 | if (tty->receive_room < TTY_THRESHOLD_THROTTLE) { |
1001 | /* check TTY_THROTTLED first so it indicates our state */ | 986 | /* check TTY_THROTTLED first so it indicates our state */ |
1002 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && | 987 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && |
1003 | tty->driver->throttle) | 988 | tty->ops->throttle) |
1004 | tty->driver->throttle(tty); | 989 | tty->ops->throttle(tty); |
1005 | } | 990 | } |
1006 | } | 991 | } |
1007 | 992 | ||
@@ -1086,6 +1071,9 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
1086 | tty->real_raw = 0; | 1071 | tty->real_raw = 0; |
1087 | } | 1072 | } |
1088 | n_tty_set_room(tty); | 1073 | n_tty_set_room(tty); |
1074 | /* The termios change make the tty ready for I/O */ | ||
1075 | wake_up_interruptible(&tty->write_wait); | ||
1076 | wake_up_interruptible(&tty->read_wait); | ||
1089 | } | 1077 | } |
1090 | 1078 | ||
1091 | /** | 1079 | /** |
@@ -1513,11 +1501,11 @@ static ssize_t write_chan(struct tty_struct *tty, struct file *file, | |||
1513 | break; | 1501 | break; |
1514 | b++; nr--; | 1502 | b++; nr--; |
1515 | } | 1503 | } |
1516 | if (tty->driver->flush_chars) | 1504 | if (tty->ops->flush_chars) |
1517 | tty->driver->flush_chars(tty); | 1505 | tty->ops->flush_chars(tty); |
1518 | } else { | 1506 | } else { |
1519 | while (nr > 0) { | 1507 | while (nr > 0) { |
1520 | c = tty->driver->write(tty, b, nr); | 1508 | c = tty->ops->write(tty, b, nr); |
1521 | if (c < 0) { | 1509 | if (c < 0) { |
1522 | retval = c; | 1510 | retval = c; |
1523 | goto break_out; | 1511 | goto break_out; |
@@ -1554,11 +1542,6 @@ break_out: | |||
1554 | * | 1542 | * |
1555 | * This code must be sure never to sleep through a hangup. | 1543 | * This code must be sure never to sleep through a hangup. |
1556 | * Called without the kernel lock held - fine | 1544 | * Called without the kernel lock held - fine |
1557 | * | ||
1558 | * FIXME: if someone changes the VMIN or discipline settings for the | ||
1559 | * terminal while another process is in poll() the poll does not | ||
1560 | * recompute the new limits. Possibly set_termios should issue | ||
1561 | * a read wakeup to fix this bug. | ||
1562 | */ | 1545 | */ |
1563 | 1546 | ||
1564 | static unsigned int normal_poll(struct tty_struct *tty, struct file *file, | 1547 | static unsigned int normal_poll(struct tty_struct *tty, struct file *file, |
@@ -1582,9 +1565,9 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file, | |||
1582 | else | 1565 | else |
1583 | tty->minimum_to_wake = 1; | 1566 | tty->minimum_to_wake = 1; |
1584 | } | 1567 | } |
1585 | if (!tty_is_writelocked(tty) && | 1568 | if (tty->ops->write && !tty_is_writelocked(tty) && |
1586 | tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS && | 1569 | tty_chars_in_buffer(tty) < WAKEUP_CHARS && |
1587 | tty->driver->write_room(tty) > 0) | 1570 | tty_write_room(tty) > 0) |
1588 | mask |= POLLOUT | POLLWRNORM; | 1571 | mask |= POLLOUT | POLLWRNORM; |
1589 | return mask; | 1572 | return mask; |
1590 | } | 1573 | } |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index b1692afd797e..f69fb8d7a680 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1108,8 +1108,8 @@ restart: | |||
1108 | a reference to the old ldisc. If we ended up flipping back | 1108 | a reference to the old ldisc. If we ended up flipping back |
1109 | to the existing ldisc we have two references to it */ | 1109 | to the existing ldisc we have two references to it */ |
1110 | 1110 | ||
1111 | if (tty->ldisc.num != o_ldisc.num && tty->driver->set_ldisc) | 1111 | if (tty->ldisc.num != o_ldisc.num && tty->ops->set_ldisc) |
1112 | tty->driver->set_ldisc(tty); | 1112 | tty->ops->set_ldisc(tty); |
1113 | 1113 | ||
1114 | tty_ldisc_put(o_ldisc.num); | 1114 | tty_ldisc_put(o_ldisc.num); |
1115 | 1115 | ||
@@ -1181,9 +1181,8 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) | |||
1181 | if (*str == '\0') | 1181 | if (*str == '\0') |
1182 | str = NULL; | 1182 | str = NULL; |
1183 | 1183 | ||
1184 | if (tty_line >= 0 && tty_line <= p->num && p->poll_init && | 1184 | if (tty_line >= 0 && tty_line <= p->num && p->ops && |
1185 | !p->poll_init(p, tty_line, str)) { | 1185 | p->ops->poll_init && !p->ops->poll_init(p, tty_line, str)) { |
1186 | |||
1187 | res = p; | 1186 | res = p; |
1188 | *line = tty_line; | 1187 | *line = tty_line; |
1189 | break; | 1188 | break; |
@@ -1452,8 +1451,7 @@ static void do_tty_hangup(struct work_struct *work) | |||
1452 | /* We may have no line discipline at this point */ | 1451 | /* We may have no line discipline at this point */ |
1453 | if (ld->flush_buffer) | 1452 | if (ld->flush_buffer) |
1454 | ld->flush_buffer(tty); | 1453 | ld->flush_buffer(tty); |
1455 | if (tty->driver->flush_buffer) | 1454 | tty_driver_flush_buffer(tty); |
1456 | tty->driver->flush_buffer(tty); | ||
1457 | if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) && | 1455 | if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) && |
1458 | ld->write_wakeup) | 1456 | ld->write_wakeup) |
1459 | ld->write_wakeup(tty); | 1457 | ld->write_wakeup(tty); |
@@ -1516,11 +1514,11 @@ static void do_tty_hangup(struct work_struct *work) | |||
1516 | * So we just call close() the right number of times. | 1514 | * So we just call close() the right number of times. |
1517 | */ | 1515 | */ |
1518 | if (cons_filp) { | 1516 | if (cons_filp) { |
1519 | if (tty->driver->close) | 1517 | if (tty->ops->close) |
1520 | for (n = 0; n < closecount; n++) | 1518 | for (n = 0; n < closecount; n++) |
1521 | tty->driver->close(tty, cons_filp); | 1519 | tty->ops->close(tty, cons_filp); |
1522 | } else if (tty->driver->hangup) | 1520 | } else if (tty->ops->hangup) |
1523 | (tty->driver->hangup)(tty); | 1521 | (tty->ops->hangup)(tty); |
1524 | /* | 1522 | /* |
1525 | * We don't want to have driver/ldisc interactions beyond | 1523 | * We don't want to have driver/ldisc interactions beyond |
1526 | * the ones we did here. The driver layer expects no | 1524 | * the ones we did here. The driver layer expects no |
@@ -1752,8 +1750,8 @@ void stop_tty(struct tty_struct *tty) | |||
1752 | wake_up_interruptible(&tty->link->read_wait); | 1750 | wake_up_interruptible(&tty->link->read_wait); |
1753 | } | 1751 | } |
1754 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 1752 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
1755 | if (tty->driver->stop) | 1753 | if (tty->ops->stop) |
1756 | (tty->driver->stop)(tty); | 1754 | (tty->ops->stop)(tty); |
1757 | } | 1755 | } |
1758 | 1756 | ||
1759 | EXPORT_SYMBOL(stop_tty); | 1757 | EXPORT_SYMBOL(stop_tty); |
@@ -1786,8 +1784,8 @@ void start_tty(struct tty_struct *tty) | |||
1786 | wake_up_interruptible(&tty->link->read_wait); | 1784 | wake_up_interruptible(&tty->link->read_wait); |
1787 | } | 1785 | } |
1788 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 1786 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
1789 | if (tty->driver->start) | 1787 | if (tty->ops->start) |
1790 | (tty->driver->start)(tty); | 1788 | (tty->ops->start)(tty); |
1791 | /* If we have a running line discipline it may need kicking */ | 1789 | /* If we have a running line discipline it may need kicking */ |
1792 | tty_wakeup(tty); | 1790 | tty_wakeup(tty); |
1793 | } | 1791 | } |
@@ -1972,10 +1970,13 @@ static ssize_t tty_write(struct file *file, const char __user *buf, | |||
1972 | tty = (struct tty_struct *)file->private_data; | 1970 | tty = (struct tty_struct *)file->private_data; |
1973 | if (tty_paranoia_check(tty, inode, "tty_write")) | 1971 | if (tty_paranoia_check(tty, inode, "tty_write")) |
1974 | return -EIO; | 1972 | return -EIO; |
1975 | if (!tty || !tty->driver->write || | 1973 | if (!tty || !tty->ops->write || |
1976 | (test_bit(TTY_IO_ERROR, &tty->flags))) | 1974 | (test_bit(TTY_IO_ERROR, &tty->flags))) |
1977 | return -EIO; | 1975 | return -EIO; |
1978 | 1976 | /* Short term debug to catch buggy drivers */ | |
1977 | if (tty->ops->write_room == NULL) | ||
1978 | printk(KERN_ERR "tty driver %s lacks a write_room method.\n", | ||
1979 | tty->driver->name); | ||
1979 | ld = tty_ldisc_ref_wait(tty); | 1980 | ld = tty_ldisc_ref_wait(tty); |
1980 | if (!ld->write) | 1981 | if (!ld->write) |
1981 | ret = -EIO; | 1982 | ret = -EIO; |
@@ -2122,6 +2123,7 @@ static int init_dev(struct tty_driver *driver, int idx, | |||
2122 | goto fail_no_mem; | 2123 | goto fail_no_mem; |
2123 | initialize_tty_struct(tty); | 2124 | initialize_tty_struct(tty); |
2124 | tty->driver = driver; | 2125 | tty->driver = driver; |
2126 | tty->ops = driver->ops; | ||
2125 | tty->index = idx; | 2127 | tty->index = idx; |
2126 | tty_line_name(driver, idx, tty->name); | 2128 | tty_line_name(driver, idx, tty->name); |
2127 | 2129 | ||
@@ -2152,6 +2154,7 @@ static int init_dev(struct tty_driver *driver, int idx, | |||
2152 | goto free_mem_out; | 2154 | goto free_mem_out; |
2153 | initialize_tty_struct(o_tty); | 2155 | initialize_tty_struct(o_tty); |
2154 | o_tty->driver = driver->other; | 2156 | o_tty->driver = driver->other; |
2157 | o_tty->ops = driver->ops; | ||
2155 | o_tty->index = idx; | 2158 | o_tty->index = idx; |
2156 | tty_line_name(driver->other, idx, o_tty->name); | 2159 | tty_line_name(driver->other, idx, o_tty->name); |
2157 | 2160 | ||
@@ -2456,8 +2459,8 @@ static void release_dev(struct file *filp) | |||
2456 | } | 2459 | } |
2457 | } | 2460 | } |
2458 | #endif | 2461 | #endif |
2459 | if (tty->driver->close) | 2462 | if (tty->ops->close) |
2460 | tty->driver->close(tty, filp); | 2463 | tty->ops->close(tty, filp); |
2461 | 2464 | ||
2462 | /* | 2465 | /* |
2463 | * Sanity check: if tty->count is going to zero, there shouldn't be | 2466 | * Sanity check: if tty->count is going to zero, there shouldn't be |
@@ -2740,8 +2743,8 @@ got_driver: | |||
2740 | printk(KERN_DEBUG "opening %s...", tty->name); | 2743 | printk(KERN_DEBUG "opening %s...", tty->name); |
2741 | #endif | 2744 | #endif |
2742 | if (!retval) { | 2745 | if (!retval) { |
2743 | if (tty->driver->open) | 2746 | if (tty->ops->open) |
2744 | retval = tty->driver->open(tty, filp); | 2747 | retval = tty->ops->open(tty, filp); |
2745 | else | 2748 | else |
2746 | retval = -ENODEV; | 2749 | retval = -ENODEV; |
2747 | } | 2750 | } |
@@ -2840,7 +2843,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
2840 | goto out1; | 2843 | goto out1; |
2841 | 2844 | ||
2842 | check_tty_count(tty, "tty_open"); | 2845 | check_tty_count(tty, "tty_open"); |
2843 | retval = ptm_driver->open(tty, filp); | 2846 | retval = ptm_driver->ops->open(tty, filp); |
2844 | if (!retval) | 2847 | if (!retval) |
2845 | return 0; | 2848 | return 0; |
2846 | out1: | 2849 | out1: |
@@ -3336,25 +3339,20 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) | |||
3336 | 3339 | ||
3337 | static int send_break(struct tty_struct *tty, unsigned int duration) | 3340 | static int send_break(struct tty_struct *tty, unsigned int duration) |
3338 | { | 3341 | { |
3339 | int retval = -EINTR; | ||
3340 | |||
3341 | lock_kernel(); | ||
3342 | if (tty_write_lock(tty, 0) < 0) | 3342 | if (tty_write_lock(tty, 0) < 0) |
3343 | goto out; | 3343 | return -EINTR; |
3344 | tty->driver->break_ctl(tty, -1); | 3344 | tty->ops->break_ctl(tty, -1); |
3345 | if (!signal_pending(current)) | 3345 | if (!signal_pending(current)) |
3346 | msleep_interruptible(duration); | 3346 | msleep_interruptible(duration); |
3347 | tty->driver->break_ctl(tty, 0); | 3347 | tty->ops->break_ctl(tty, 0); |
3348 | tty_write_unlock(tty); | 3348 | tty_write_unlock(tty); |
3349 | if (!signal_pending(current)) | 3349 | if (!signal_pending(current)) |
3350 | retval = 0; | 3350 | return -EINTR; |
3351 | out: | 3351 | return 0; |
3352 | unlock_kernel(); | ||
3353 | return retval; | ||
3354 | } | 3352 | } |
3355 | 3353 | ||
3356 | /** | 3354 | /** |
3357 | * tiocmget - get modem status | 3355 | * tty_tiocmget - get modem status |
3358 | * @tty: tty device | 3356 | * @tty: tty device |
3359 | * @file: user file pointer | 3357 | * @file: user file pointer |
3360 | * @p: pointer to result | 3358 | * @p: pointer to result |
@@ -3369,10 +3367,8 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p | |||
3369 | { | 3367 | { |
3370 | int retval = -EINVAL; | 3368 | int retval = -EINVAL; |
3371 | 3369 | ||
3372 | if (tty->driver->tiocmget) { | 3370 | if (tty->ops->tiocmget) { |
3373 | lock_kernel(); | 3371 | retval = tty->ops->tiocmget(tty, file); |
3374 | retval = tty->driver->tiocmget(tty, file); | ||
3375 | unlock_kernel(); | ||
3376 | 3372 | ||
3377 | if (retval >= 0) | 3373 | if (retval >= 0) |
3378 | retval = put_user(retval, p); | 3374 | retval = put_user(retval, p); |
@@ -3381,7 +3377,7 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p | |||
3381 | } | 3377 | } |
3382 | 3378 | ||
3383 | /** | 3379 | /** |
3384 | * tiocmset - set modem status | 3380 | * tty_tiocmset - set modem status |
3385 | * @tty: tty device | 3381 | * @tty: tty device |
3386 | * @file: user file pointer | 3382 | * @file: user file pointer |
3387 | * @cmd: command - clear bits, set bits or set all | 3383 | * @cmd: command - clear bits, set bits or set all |
@@ -3398,7 +3394,7 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int | |||
3398 | { | 3394 | { |
3399 | int retval = -EINVAL; | 3395 | int retval = -EINVAL; |
3400 | 3396 | ||
3401 | if (tty->driver->tiocmset) { | 3397 | if (tty->ops->tiocmset) { |
3402 | unsigned int set, clear, val; | 3398 | unsigned int set, clear, val; |
3403 | 3399 | ||
3404 | retval = get_user(val, p); | 3400 | retval = get_user(val, p); |
@@ -3422,9 +3418,7 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int | |||
3422 | set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; | 3418 | set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; |
3423 | clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; | 3419 | clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; |
3424 | 3420 | ||
3425 | lock_kernel(); | 3421 | retval = tty->ops->tiocmset(tty, file, set, clear); |
3426 | retval = tty->driver->tiocmset(tty, file, set, clear); | ||
3427 | unlock_kernel(); | ||
3428 | } | 3422 | } |
3429 | return retval; | 3423 | return retval; |
3430 | } | 3424 | } |
@@ -3455,23 +3449,25 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3455 | 3449 | ||
3456 | retval = -EINVAL; | 3450 | retval = -EINVAL; |
3457 | 3451 | ||
3458 | if (!tty->driver->break_ctl) { | 3452 | if (!tty->ops->break_ctl) { |
3459 | switch (cmd) { | 3453 | switch (cmd) { |
3460 | case TIOCSBRK: | 3454 | case TIOCSBRK: |
3461 | case TIOCCBRK: | 3455 | case TIOCCBRK: |
3462 | if (tty->driver->ioctl) | 3456 | if (tty->ops->ioctl) |
3463 | retval = tty->driver->ioctl(tty, file, cmd, arg); | 3457 | retval = tty->ops->ioctl(tty, file, cmd, arg); |
3458 | if (retval != -EINVAL && retval != -ENOIOCTLCMD) | ||
3459 | printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name); | ||
3464 | return retval; | 3460 | return retval; |
3465 | 3461 | ||
3466 | /* These two ioctl's always return success; even if */ | 3462 | /* These two ioctl's always return success; even if */ |
3467 | /* the driver doesn't support them. */ | 3463 | /* the driver doesn't support them. */ |
3468 | case TCSBRK: | 3464 | case TCSBRK: |
3469 | case TCSBRKP: | 3465 | case TCSBRKP: |
3470 | if (!tty->driver->ioctl) | 3466 | if (!tty->ops->ioctl) |
3471 | return 0; | 3467 | return 0; |
3472 | lock_kernel(); | 3468 | retval = tty->ops->ioctl(tty, file, cmd, arg); |
3473 | retval = tty->driver->ioctl(tty, file, cmd, arg); | 3469 | if (retval != -EINVAL && retval != -ENOIOCTLCMD) |
3474 | unlock_kernel(); | 3470 | printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name); |
3475 | if (retval == -ENOIOCTLCMD) | 3471 | if (retval == -ENOIOCTLCMD) |
3476 | retval = 0; | 3472 | retval = 0; |
3477 | return retval; | 3473 | return retval; |
@@ -3491,9 +3487,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3491 | if (retval) | 3487 | if (retval) |
3492 | return retval; | 3488 | return retval; |
3493 | if (cmd != TIOCCBRK) { | 3489 | if (cmd != TIOCCBRK) { |
3494 | lock_kernel(); | ||
3495 | tty_wait_until_sent(tty, 0); | 3490 | tty_wait_until_sent(tty, 0); |
3496 | unlock_kernel(); | ||
3497 | if (signal_pending(current)) | 3491 | if (signal_pending(current)) |
3498 | return -EINTR; | 3492 | return -EINTR; |
3499 | } | 3493 | } |
@@ -3531,7 +3525,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3531 | case TIOCGSID: | 3525 | case TIOCGSID: |
3532 | return tiocgsid(tty, real_tty, p); | 3526 | return tiocgsid(tty, real_tty, p); |
3533 | case TIOCGETD: | 3527 | case TIOCGETD: |
3534 | /* FIXME: check this is ok */ | ||
3535 | return put_user(tty->ldisc.num, (int __user *)p); | 3528 | return put_user(tty->ldisc.num, (int __user *)p); |
3536 | case TIOCSETD: | 3529 | case TIOCSETD: |
3537 | return tiocsetd(tty, p); | 3530 | return tiocsetd(tty, p); |
@@ -3543,15 +3536,13 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3543 | * Break handling | 3536 | * Break handling |
3544 | */ | 3537 | */ |
3545 | case TIOCSBRK: /* Turn break on, unconditionally */ | 3538 | case TIOCSBRK: /* Turn break on, unconditionally */ |
3546 | lock_kernel(); | 3539 | if (tty->ops->break_ctl) |
3547 | tty->driver->break_ctl(tty, -1); | 3540 | tty->ops->break_ctl(tty, -1); |
3548 | unlock_kernel(); | ||
3549 | return 0; | 3541 | return 0; |
3550 | 3542 | ||
3551 | case TIOCCBRK: /* Turn break off, unconditionally */ | 3543 | case TIOCCBRK: /* Turn break off, unconditionally */ |
3552 | lock_kernel(); | 3544 | if (tty->ops->break_ctl) |
3553 | tty->driver->break_ctl(tty, 0); | 3545 | tty->ops->break_ctl(tty, 0); |
3554 | unlock_kernel(); | ||
3555 | return 0; | 3546 | return 0; |
3556 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | 3547 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
3557 | /* non-zero arg means wait for all output data | 3548 | /* non-zero arg means wait for all output data |
@@ -3580,8 +3571,8 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3580 | } | 3571 | } |
3581 | break; | 3572 | break; |
3582 | } | 3573 | } |
3583 | if (tty->driver->ioctl) { | 3574 | if (tty->ops->ioctl) { |
3584 | retval = (tty->driver->ioctl)(tty, file, cmd, arg); | 3575 | retval = (tty->ops->ioctl)(tty, file, cmd, arg); |
3585 | if (retval != -ENOIOCTLCMD) | 3576 | if (retval != -ENOIOCTLCMD) |
3586 | return retval; | 3577 | return retval; |
3587 | } | 3578 | } |
@@ -3608,8 +3599,8 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd, | |||
3608 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | 3599 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) |
3609 | return -EINVAL; | 3600 | return -EINVAL; |
3610 | 3601 | ||
3611 | if (tty->driver->compat_ioctl) { | 3602 | if (tty->ops->compat_ioctl) { |
3612 | retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg); | 3603 | retval = (tty->ops->compat_ioctl)(tty, file, cmd, arg); |
3613 | if (retval != -ENOIOCTLCMD) | 3604 | if (retval != -ENOIOCTLCMD) |
3614 | return retval; | 3605 | return retval; |
3615 | } | 3606 | } |
@@ -3659,8 +3650,7 @@ void __do_SAK(struct tty_struct *tty) | |||
3659 | 3650 | ||
3660 | tty_ldisc_flush(tty); | 3651 | tty_ldisc_flush(tty); |
3661 | 3652 | ||
3662 | if (tty->driver->flush_buffer) | 3653 | tty_driver_flush_buffer(tty); |
3663 | tty->driver->flush_buffer(tty); | ||
3664 | 3654 | ||
3665 | read_lock(&tasklist_lock); | 3655 | read_lock(&tasklist_lock); |
3666 | /* Kill the entire session */ | 3656 | /* Kill the entire session */ |
@@ -3871,15 +3861,27 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
3871 | INIT_WORK(&tty->SAK_work, do_SAK_work); | 3861 | INIT_WORK(&tty->SAK_work, do_SAK_work); |
3872 | } | 3862 | } |
3873 | 3863 | ||
3874 | /* | 3864 | /** |
3875 | * The default put_char routine if the driver did not define one. | 3865 | * tty_put_char - write one character to a tty |
3866 | * @tty: tty | ||
3867 | * @ch: character | ||
3868 | * | ||
3869 | * Write one byte to the tty using the provided put_char method | ||
3870 | * if present. Returns the number of characters successfully output. | ||
3871 | * | ||
3872 | * Note: the specific put_char operation in the driver layer may go | ||
3873 | * away soon. Don't call it directly, use this method | ||
3876 | */ | 3874 | */ |
3877 | 3875 | ||
3878 | static void tty_default_put_char(struct tty_struct *tty, unsigned char ch) | 3876 | int tty_put_char(struct tty_struct *tty, unsigned char ch) |
3879 | { | 3877 | { |
3880 | tty->driver->write(tty, &ch, 1); | 3878 | if (tty->ops->put_char) |
3879 | return tty->ops->put_char(tty, ch); | ||
3880 | return tty->ops->write(tty, &ch, 1); | ||
3881 | } | 3881 | } |
3882 | 3882 | ||
3883 | EXPORT_SYMBOL_GPL(tty_put_char); | ||
3884 | |||
3883 | static struct class *tty_class; | 3885 | static struct class *tty_class; |
3884 | 3886 | ||
3885 | /** | 3887 | /** |
@@ -3962,37 +3964,8 @@ void put_tty_driver(struct tty_driver *driver) | |||
3962 | void tty_set_operations(struct tty_driver *driver, | 3964 | void tty_set_operations(struct tty_driver *driver, |
3963 | const struct tty_operations *op) | 3965 | const struct tty_operations *op) |
3964 | { | 3966 | { |
3965 | driver->open = op->open; | 3967 | driver->ops = op; |
3966 | driver->close = op->close; | 3968 | }; |
3967 | driver->write = op->write; | ||
3968 | driver->put_char = op->put_char; | ||
3969 | driver->flush_chars = op->flush_chars; | ||
3970 | driver->write_room = op->write_room; | ||
3971 | driver->chars_in_buffer = op->chars_in_buffer; | ||
3972 | driver->ioctl = op->ioctl; | ||
3973 | driver->compat_ioctl = op->compat_ioctl; | ||
3974 | driver->set_termios = op->set_termios; | ||
3975 | driver->throttle = op->throttle; | ||
3976 | driver->unthrottle = op->unthrottle; | ||
3977 | driver->stop = op->stop; | ||
3978 | driver->start = op->start; | ||
3979 | driver->hangup = op->hangup; | ||
3980 | driver->break_ctl = op->break_ctl; | ||
3981 | driver->flush_buffer = op->flush_buffer; | ||
3982 | driver->set_ldisc = op->set_ldisc; | ||
3983 | driver->wait_until_sent = op->wait_until_sent; | ||
3984 | driver->send_xchar = op->send_xchar; | ||
3985 | driver->read_proc = op->read_proc; | ||
3986 | driver->write_proc = op->write_proc; | ||
3987 | driver->tiocmget = op->tiocmget; | ||
3988 | driver->tiocmset = op->tiocmset; | ||
3989 | #ifdef CONFIG_CONSOLE_POLL | ||
3990 | driver->poll_init = op->poll_init; | ||
3991 | driver->poll_get_char = op->poll_get_char; | ||
3992 | driver->poll_put_char = op->poll_put_char; | ||
3993 | #endif | ||
3994 | } | ||
3995 | |||
3996 | 3969 | ||
3997 | EXPORT_SYMBOL(alloc_tty_driver); | 3970 | EXPORT_SYMBOL(alloc_tty_driver); |
3998 | EXPORT_SYMBOL(put_tty_driver); | 3971 | EXPORT_SYMBOL(put_tty_driver); |
@@ -4055,9 +4028,6 @@ int tty_register_driver(struct tty_driver *driver) | |||
4055 | return error; | 4028 | return error; |
4056 | } | 4029 | } |
4057 | 4030 | ||
4058 | if (!driver->put_char) | ||
4059 | driver->put_char = tty_default_put_char; | ||
4060 | |||
4061 | mutex_lock(&tty_mutex); | 4031 | mutex_lock(&tty_mutex); |
4062 | list_add(&driver->tty_drivers, &tty_drivers); | 4032 | list_add(&driver->tty_drivers, &tty_drivers); |
4063 | mutex_unlock(&tty_mutex); | 4033 | mutex_unlock(&tty_mutex); |
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index 8c4bf3e48d5b..c10d40c4c5ca 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c | |||
@@ -40,6 +40,34 @@ | |||
40 | #define TERMIOS_OLD 8 | 40 | #define TERMIOS_OLD 8 |
41 | 41 | ||
42 | 42 | ||
43 | int tty_chars_in_buffer(struct tty_struct *tty) | ||
44 | { | ||
45 | if (tty->ops->chars_in_buffer) | ||
46 | return tty->ops->chars_in_buffer(tty); | ||
47 | else | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | EXPORT_SYMBOL(tty_chars_in_buffer); | ||
52 | |||
53 | int tty_write_room(struct tty_struct *tty) | ||
54 | { | ||
55 | if (tty->ops->write_room) | ||
56 | return tty->ops->write_room(tty); | ||
57 | return 2048; | ||
58 | } | ||
59 | |||
60 | EXPORT_SYMBOL(tty_write_room); | ||
61 | |||
62 | void tty_driver_flush_buffer(struct tty_struct *tty) | ||
63 | { | ||
64 | if (tty->ops->flush_buffer) | ||
65 | tty->ops->flush_buffer(tty); | ||
66 | } | ||
67 | |||
68 | EXPORT_SYMBOL(tty_driver_flush_buffer); | ||
69 | |||
70 | |||
43 | /** | 71 | /** |
44 | * tty_wait_until_sent - wait for I/O to finish | 72 | * tty_wait_until_sent - wait for I/O to finish |
45 | * @tty: tty we are waiting for | 73 | * @tty: tty we are waiting for |
@@ -58,17 +86,13 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout) | |||
58 | 86 | ||
59 | printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); | 87 | printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); |
60 | #endif | 88 | #endif |
61 | if (!tty->driver->chars_in_buffer) | ||
62 | return; | ||
63 | if (!timeout) | 89 | if (!timeout) |
64 | timeout = MAX_SCHEDULE_TIMEOUT; | 90 | timeout = MAX_SCHEDULE_TIMEOUT; |
65 | lock_kernel(); | ||
66 | if (wait_event_interruptible_timeout(tty->write_wait, | 91 | if (wait_event_interruptible_timeout(tty->write_wait, |
67 | !tty->driver->chars_in_buffer(tty), timeout) >= 0) { | 92 | !tty_chars_in_buffer(tty), timeout) >= 0) { |
68 | if (tty->driver->wait_until_sent) | 93 | if (tty->ops->wait_until_sent) |
69 | tty->driver->wait_until_sent(tty, timeout); | 94 | tty->ops->wait_until_sent(tty, timeout); |
70 | } | 95 | } |
71 | unlock_kernel(); | ||
72 | } | 96 | } |
73 | EXPORT_SYMBOL(tty_wait_until_sent); | 97 | EXPORT_SYMBOL(tty_wait_until_sent); |
74 | 98 | ||
@@ -444,8 +468,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) | |||
444 | } | 468 | } |
445 | } | 469 | } |
446 | 470 | ||
447 | if (tty->driver->set_termios) | 471 | if (tty->ops->set_termios) |
448 | (*tty->driver->set_termios)(tty, &old_termios); | 472 | (*tty->ops->set_termios)(tty, &old_termios); |
449 | else | 473 | else |
450 | tty_termios_copy_hw(tty->termios, &old_termios); | 474 | tty_termios_copy_hw(tty->termios, &old_termios); |
451 | 475 | ||
@@ -748,8 +772,8 @@ static int send_prio_char(struct tty_struct *tty, char ch) | |||
748 | { | 772 | { |
749 | int was_stopped = tty->stopped; | 773 | int was_stopped = tty->stopped; |
750 | 774 | ||
751 | if (tty->driver->send_xchar) { | 775 | if (tty->ops->send_xchar) { |
752 | tty->driver->send_xchar(tty, ch); | 776 | tty->ops->send_xchar(tty, ch); |
753 | return 0; | 777 | return 0; |
754 | } | 778 | } |
755 | 779 | ||
@@ -758,7 +782,7 @@ static int send_prio_char(struct tty_struct *tty, char ch) | |||
758 | 782 | ||
759 | if (was_stopped) | 783 | if (was_stopped) |
760 | start_tty(tty); | 784 | start_tty(tty); |
761 | tty->driver->write(tty, &ch, 1); | 785 | tty->ops->write(tty, &ch, 1); |
762 | if (was_stopped) | 786 | if (was_stopped) |
763 | stop_tty(tty); | 787 | stop_tty(tty); |
764 | tty_write_unlock(tty); | 788 | tty_write_unlock(tty); |
@@ -778,13 +802,14 @@ static int tty_change_softcar(struct tty_struct *tty, int arg) | |||
778 | { | 802 | { |
779 | int ret = 0; | 803 | int ret = 0; |
780 | int bit = arg ? CLOCAL : 0; | 804 | int bit = arg ? CLOCAL : 0; |
781 | struct ktermios old = *tty->termios; | 805 | struct ktermios old; |
782 | 806 | ||
783 | mutex_lock(&tty->termios_mutex); | 807 | mutex_lock(&tty->termios_mutex); |
808 | old = *tty->termios; | ||
784 | tty->termios->c_cflag &= ~CLOCAL; | 809 | tty->termios->c_cflag &= ~CLOCAL; |
785 | tty->termios->c_cflag |= bit; | 810 | tty->termios->c_cflag |= bit; |
786 | if (tty->driver->set_termios) | 811 | if (tty->ops->set_termios) |
787 | tty->driver->set_termios(tty, &old); | 812 | tty->ops->set_termios(tty, &old); |
788 | if ((tty->termios->c_cflag & CLOCAL) != bit) | 813 | if ((tty->termios->c_cflag & CLOCAL) != bit) |
789 | ret = -EINVAL; | 814 | ret = -EINVAL; |
790 | mutex_unlock(&tty->termios_mutex); | 815 | mutex_unlock(&tty->termios_mutex); |
@@ -926,8 +951,7 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) | |||
926 | ld->flush_buffer(tty); | 951 | ld->flush_buffer(tty); |
927 | /* fall through */ | 952 | /* fall through */ |
928 | case TCOFLUSH: | 953 | case TCOFLUSH: |
929 | if (tty->driver->flush_buffer) | 954 | tty_driver_flush_buffer(tty); |
930 | tty->driver->flush_buffer(tty); | ||
931 | break; | 955 | break; |
932 | default: | 956 | default: |
933 | tty_ldisc_deref(ld); | 957 | tty_ldisc_deref(ld); |
@@ -984,9 +1008,7 @@ int n_tty_ioctl(struct tty_struct *tty, struct file *file, | |||
984 | case TCFLSH: | 1008 | case TCFLSH: |
985 | return tty_perform_flush(tty, arg); | 1009 | return tty_perform_flush(tty, arg); |
986 | case TIOCOUTQ: | 1010 | case TIOCOUTQ: |
987 | return put_user(tty->driver->chars_in_buffer ? | 1011 | return put_user(tty_chars_in_buffer(tty), (int __user *) arg); |
988 | tty->driver->chars_in_buffer(tty) : 0, | ||
989 | (int __user *) arg); | ||
990 | case TIOCINQ: | 1012 | case TIOCINQ: |
991 | retval = tty->read_cnt; | 1013 | retval = tty->read_cnt; |
992 | if (L_ICANON(tty)) | 1014 | if (L_ICANON(tty)) |
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index e1a3a79ab3f9..7ff71ba7b7c9 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c | |||
@@ -46,7 +46,7 @@ struct serport { | |||
46 | static int serport_serio_write(struct serio *serio, unsigned char data) | 46 | static int serport_serio_write(struct serio *serio, unsigned char data) |
47 | { | 47 | { |
48 | struct serport *serport = serio->port_data; | 48 | struct serport *serport = serio->port_data; |
49 | return -(serport->tty->driver->write(serport->tty, &data, 1) != 1); | 49 | return -(serport->tty->ops->write(serport->tty, &data, 1) != 1); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int serport_serio_open(struct serio *serio) | 52 | static int serport_serio_open(struct serio *serio) |
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c index fceeb1d57682..45d1ee93cd39 100644 --- a/drivers/isdn/gigaset/ser-gigaset.c +++ b/drivers/isdn/gigaset/ser-gigaset.c | |||
@@ -68,10 +68,10 @@ static int write_modem(struct cardstate *cs) | |||
68 | struct tty_struct *tty = cs->hw.ser->tty; | 68 | struct tty_struct *tty = cs->hw.ser->tty; |
69 | struct bc_state *bcs = &cs->bcs[0]; /* only one channel */ | 69 | struct bc_state *bcs = &cs->bcs[0]; /* only one channel */ |
70 | struct sk_buff *skb = bcs->tx_skb; | 70 | struct sk_buff *skb = bcs->tx_skb; |
71 | int sent; | 71 | int sent = -EOPNOTSUPP; |
72 | 72 | ||
73 | if (!tty || !tty->driver || !skb) | 73 | if (!tty || !tty->driver || !skb) |
74 | return -EFAULT; | 74 | return -EINVAL; |
75 | 75 | ||
76 | if (!skb->len) { | 76 | if (!skb->len) { |
77 | dev_kfree_skb_any(skb); | 77 | dev_kfree_skb_any(skb); |
@@ -80,7 +80,8 @@ static int write_modem(struct cardstate *cs) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 82 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
83 | sent = tty->driver->write(tty, skb->data, skb->len); | 83 | if (tty->ops->write) |
84 | sent = tty->ops->write(tty, skb->data, skb->len); | ||
84 | gig_dbg(DEBUG_OUTPUT, "write_modem: sent %d", sent); | 85 | gig_dbg(DEBUG_OUTPUT, "write_modem: sent %d", sent); |
85 | if (sent < 0) { | 86 | if (sent < 0) { |
86 | /* error */ | 87 | /* error */ |
@@ -120,7 +121,7 @@ static int send_cb(struct cardstate *cs) | |||
120 | 121 | ||
121 | if (cb->len) { | 122 | if (cb->len) { |
122 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 123 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
123 | sent = tty->driver->write(tty, cb->buf + cb->offset, cb->len); | 124 | sent = tty->ops->write(tty, cb->buf + cb->offset, cb->len); |
124 | if (sent < 0) { | 125 | if (sent < 0) { |
125 | /* error */ | 126 | /* error */ |
126 | gig_dbg(DEBUG_OUTPUT, "send_cb: write error %d", sent); | 127 | gig_dbg(DEBUG_OUTPUT, "send_cb: write error %d", sent); |
@@ -440,14 +441,14 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, unsi | |||
440 | struct tty_struct *tty = cs->hw.ser->tty; | 441 | struct tty_struct *tty = cs->hw.ser->tty; |
441 | unsigned int set, clear; | 442 | unsigned int set, clear; |
442 | 443 | ||
443 | if (!tty || !tty->driver || !tty->driver->tiocmset) | 444 | if (!tty || !tty->driver || !tty->ops->tiocmset) |
444 | return -EFAULT; | 445 | return -EINVAL; |
445 | set = new_state & ~old_state; | 446 | set = new_state & ~old_state; |
446 | clear = old_state & ~new_state; | 447 | clear = old_state & ~new_state; |
447 | if (!set && !clear) | 448 | if (!set && !clear) |
448 | return 0; | 449 | return 0; |
449 | gig_dbg(DEBUG_IF, "tiocmset set %x clear %x", set, clear); | 450 | gig_dbg(DEBUG_IF, "tiocmset set %x clear %x", set, clear); |
450 | return tty->driver->tiocmset(tty, NULL, set, clear); | 451 | return tty->ops->tiocmset(tty, NULL, set, clear); |
451 | } | 452 | } |
452 | 453 | ||
453 | static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) | 454 | static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) |
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 1da55dd2a5a0..82a36266dfc9 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c | |||
@@ -148,13 +148,13 @@ static void sp_xmit_on_air(unsigned long channel) | |||
148 | 148 | ||
149 | if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { | 149 | if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { |
150 | sp->led_state = 0x70; | 150 | sp->led_state = 0x70; |
151 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 151 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
152 | sp->tx_enable = 1; | 152 | sp->tx_enable = 1; |
153 | actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2); | 153 | actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); |
154 | sp->xleft -= actual; | 154 | sp->xleft -= actual; |
155 | sp->xhead += actual; | 155 | sp->xhead += actual; |
156 | sp->led_state = 0x60; | 156 | sp->led_state = 0x60; |
157 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 157 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
158 | sp->status2 = 0; | 158 | sp->status2 = 0; |
159 | } else | 159 | } else |
160 | mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); | 160 | mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); |
@@ -220,13 +220,13 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len) | |||
220 | */ | 220 | */ |
221 | if (sp->duplex == 1) { | 221 | if (sp->duplex == 1) { |
222 | sp->led_state = 0x70; | 222 | sp->led_state = 0x70; |
223 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 223 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
224 | sp->tx_enable = 1; | 224 | sp->tx_enable = 1; |
225 | actual = sp->tty->driver->write(sp->tty, sp->xbuff, count); | 225 | actual = sp->tty->ops->write(sp->tty, sp->xbuff, count); |
226 | sp->xleft = count - actual; | 226 | sp->xleft = count - actual; |
227 | sp->xhead = sp->xbuff + actual; | 227 | sp->xhead = sp->xbuff + actual; |
228 | sp->led_state = 0x60; | 228 | sp->led_state = 0x60; |
229 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 229 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
230 | } else { | 230 | } else { |
231 | sp->xleft = count; | 231 | sp->xleft = count; |
232 | sp->xhead = sp->xbuff; | 232 | sp->xhead = sp->xbuff; |
@@ -444,7 +444,7 @@ static void sixpack_write_wakeup(struct tty_struct *tty) | |||
444 | } | 444 | } |
445 | 445 | ||
446 | if (sp->tx_enable) { | 446 | if (sp->tx_enable) { |
447 | actual = tty->driver->write(tty, sp->xhead, sp->xleft); | 447 | actual = tty->ops->write(tty, sp->xhead, sp->xleft); |
448 | sp->xleft -= actual; | 448 | sp->xleft -= actual; |
449 | sp->xhead += actual; | 449 | sp->xhead += actual; |
450 | } | 450 | } |
@@ -492,8 +492,8 @@ static void sixpack_receive_buf(struct tty_struct *tty, | |||
492 | 492 | ||
493 | sp_put(sp); | 493 | sp_put(sp); |
494 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) | 494 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) |
495 | && tty->driver->unthrottle) | 495 | && tty->ops->unthrottle) |
496 | tty->driver->unthrottle(tty); | 496 | tty->ops->unthrottle(tty); |
497 | } | 497 | } |
498 | 498 | ||
499 | /* | 499 | /* |
@@ -554,8 +554,8 @@ static void resync_tnc(unsigned long channel) | |||
554 | /* resync the TNC */ | 554 | /* resync the TNC */ |
555 | 555 | ||
556 | sp->led_state = 0x60; | 556 | sp->led_state = 0x60; |
557 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 557 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
558 | sp->tty->driver->write(sp->tty, &resync_cmd, 1); | 558 | sp->tty->ops->write(sp->tty, &resync_cmd, 1); |
559 | 559 | ||
560 | 560 | ||
561 | /* Start resync timer again -- the TNC might be still absent */ | 561 | /* Start resync timer again -- the TNC might be still absent */ |
@@ -573,7 +573,7 @@ static inline int tnc_init(struct sixpack *sp) | |||
573 | 573 | ||
574 | tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); | 574 | tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); |
575 | 575 | ||
576 | sp->tty->driver->write(sp->tty, &inbyte, 1); | 576 | sp->tty->ops->write(sp->tty, &inbyte, 1); |
577 | 577 | ||
578 | del_timer(&sp->resync_t); | 578 | del_timer(&sp->resync_t); |
579 | sp->resync_t.data = (unsigned long) sp; | 579 | sp->resync_t.data = (unsigned long) sp; |
@@ -601,6 +601,8 @@ static int sixpack_open(struct tty_struct *tty) | |||
601 | 601 | ||
602 | if (!capable(CAP_NET_ADMIN)) | 602 | if (!capable(CAP_NET_ADMIN)) |
603 | return -EPERM; | 603 | return -EPERM; |
604 | if (tty->ops->write == NULL) | ||
605 | return -EOPNOTSUPP; | ||
604 | 606 | ||
605 | dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup); | 607 | dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup); |
606 | if (!dev) { | 608 | if (!dev) { |
@@ -914,9 +916,9 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd) | |||
914 | } else { /* output watchdog char if idle */ | 916 | } else { /* output watchdog char if idle */ |
915 | if ((sp->status2 != 0) && (sp->duplex == 1)) { | 917 | if ((sp->status2 != 0) && (sp->duplex == 1)) { |
916 | sp->led_state = 0x70; | 918 | sp->led_state = 0x70; |
917 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 919 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
918 | sp->tx_enable = 1; | 920 | sp->tx_enable = 1; |
919 | actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2); | 921 | actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); |
920 | sp->xleft -= actual; | 922 | sp->xleft -= actual; |
921 | sp->xhead += actual; | 923 | sp->xhead += actual; |
922 | sp->led_state = 0x60; | 924 | sp->led_state = 0x60; |
@@ -926,7 +928,7 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd) | |||
926 | } | 928 | } |
927 | 929 | ||
928 | /* needed to trigger the TNC watchdog */ | 930 | /* needed to trigger the TNC watchdog */ |
929 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 931 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
930 | 932 | ||
931 | /* if the state byte has been received, the TNC is present, | 933 | /* if the state byte has been received, the TNC is present, |
932 | so the resync timer can be reset. */ | 934 | so the resync timer can be reset. */ |
@@ -956,12 +958,12 @@ static void decode_std_command(struct sixpack *sp, unsigned char cmd) | |||
956 | if ((sp->status & SIXP_RX_DCD_MASK) == | 958 | if ((sp->status & SIXP_RX_DCD_MASK) == |
957 | SIXP_RX_DCD_MASK) { | 959 | SIXP_RX_DCD_MASK) { |
958 | sp->led_state = 0x68; | 960 | sp->led_state = 0x68; |
959 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 961 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
960 | } | 962 | } |
961 | } else { | 963 | } else { |
962 | sp->led_state = 0x60; | 964 | sp->led_state = 0x60; |
963 | /* fill trailing bytes with zeroes */ | 965 | /* fill trailing bytes with zeroes */ |
964 | sp->tty->driver->write(sp->tty, &sp->led_state, 1); | 966 | sp->tty->ops->write(sp->tty, &sp->led_state, 1); |
965 | rest = sp->rx_count; | 967 | rest = sp->rx_count; |
966 | if (rest != 0) | 968 | if (rest != 0) |
967 | for (i = rest; i <= 3; i++) | 969 | for (i = rest; i <= 3; i++) |
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 30c9b3b0d131..ebcc5adee7cc 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -516,7 +516,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) | |||
516 | spin_unlock_bh(&ax->buflock); | 516 | spin_unlock_bh(&ax->buflock); |
517 | 517 | ||
518 | set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); | 518 | set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); |
519 | actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); | 519 | actual = ax->tty->ops->write(ax->tty, ax->xbuff, count); |
520 | ax->stats.tx_packets++; | 520 | ax->stats.tx_packets++; |
521 | ax->stats.tx_bytes += actual; | 521 | ax->stats.tx_bytes += actual; |
522 | 522 | ||
@@ -546,7 +546,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev) | |||
546 | } | 546 | } |
547 | 547 | ||
548 | printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name, | 548 | printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name, |
549 | (ax->tty->driver->chars_in_buffer(ax->tty) || ax->xleft) ? | 549 | (ax->tty->ops->chars_in_buffer(ax->tty) || ax->xleft) ? |
550 | "bad line quality" : "driver error"); | 550 | "bad line quality" : "driver error"); |
551 | 551 | ||
552 | ax->xleft = 0; | 552 | ax->xleft = 0; |
@@ -736,6 +736,8 @@ static int mkiss_open(struct tty_struct *tty) | |||
736 | 736 | ||
737 | if (!capable(CAP_NET_ADMIN)) | 737 | if (!capable(CAP_NET_ADMIN)) |
738 | return -EPERM; | 738 | return -EPERM; |
739 | if (tty->ops->write == NULL) | ||
740 | return -EOPNOTSUPP; | ||
739 | 741 | ||
740 | dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup); | 742 | dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup); |
741 | if (!dev) { | 743 | if (!dev) { |
@@ -754,8 +756,7 @@ static int mkiss_open(struct tty_struct *tty) | |||
754 | tty->disc_data = ax; | 756 | tty->disc_data = ax; |
755 | tty->receive_room = 65535; | 757 | tty->receive_room = 65535; |
756 | 758 | ||
757 | if (tty->driver->flush_buffer) | 759 | tty_driver_flush_buffer(tty); |
758 | tty->driver->flush_buffer(tty); | ||
759 | 760 | ||
760 | /* Restore default settings */ | 761 | /* Restore default settings */ |
761 | dev->type = ARPHRD_AX25; | 762 | dev->type = ARPHRD_AX25; |
@@ -936,8 +937,8 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
936 | 937 | ||
937 | mkiss_put(ax); | 938 | mkiss_put(ax); |
938 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) | 939 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) |
939 | && tty->driver->unthrottle) | 940 | && tty->ops->unthrottle) |
940 | tty->driver->unthrottle(tty); | 941 | tty->ops->unthrottle(tty); |
941 | } | 942 | } |
942 | 943 | ||
943 | /* | 944 | /* |
@@ -962,7 +963,7 @@ static void mkiss_write_wakeup(struct tty_struct *tty) | |||
962 | goto out; | 963 | goto out; |
963 | } | 964 | } |
964 | 965 | ||
965 | actual = tty->driver->write(tty, ax->xhead, ax->xleft); | 966 | actual = tty->ops->write(tty, ax->xhead, ax->xleft); |
966 | ax->xleft -= actual; | 967 | ax->xleft -= actual; |
967 | ax->xhead += actual; | 968 | ax->xhead += actual; |
968 | 969 | ||
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c index fc753d7f674e..e6f40b7f9041 100644 --- a/drivers/net/irda/irtty-sir.c +++ b/drivers/net/irda/irtty-sir.c | |||
@@ -64,7 +64,7 @@ static int irtty_chars_in_buffer(struct sir_dev *dev) | |||
64 | IRDA_ASSERT(priv != NULL, return -1;); | 64 | IRDA_ASSERT(priv != NULL, return -1;); |
65 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); | 65 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); |
66 | 66 | ||
67 | return priv->tty->driver->chars_in_buffer(priv->tty); | 67 | return tty_chars_in_buffer(priv->tty); |
68 | } | 68 | } |
69 | 69 | ||
70 | /* Wait (sleep) until underlaying hardware finished transmission | 70 | /* Wait (sleep) until underlaying hardware finished transmission |
@@ -93,10 +93,8 @@ static void irtty_wait_until_sent(struct sir_dev *dev) | |||
93 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;); | 93 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;); |
94 | 94 | ||
95 | tty = priv->tty; | 95 | tty = priv->tty; |
96 | if (tty->driver->wait_until_sent) { | 96 | if (tty->ops->wait_until_sent) { |
97 | lock_kernel(); | 97 | tty->ops->wait_until_sent(tty, msecs_to_jiffies(100)); |
98 | tty->driver->wait_until_sent(tty, msecs_to_jiffies(100)); | ||
99 | unlock_kernel(); | ||
100 | } | 98 | } |
101 | else { | 99 | else { |
102 | msleep(USBSERIAL_TX_DONE_DELAY); | 100 | msleep(USBSERIAL_TX_DONE_DELAY); |
@@ -125,48 +123,14 @@ static int irtty_change_speed(struct sir_dev *dev, unsigned speed) | |||
125 | 123 | ||
126 | tty = priv->tty; | 124 | tty = priv->tty; |
127 | 125 | ||
128 | lock_kernel(); | 126 | mutex_lock(&tty->termios_mutex); |
129 | old_termios = *(tty->termios); | 127 | old_termios = *(tty->termios); |
130 | cflag = tty->termios->c_cflag; | 128 | cflag = tty->termios->c_cflag; |
131 | 129 | tty_encode_baud_rate(tty, speed, speed); | |
132 | cflag &= ~CBAUD; | 130 | if (tty->ops->set_termios) |
133 | 131 | tty->ops->set_termios(tty, &old_termios); | |
134 | IRDA_DEBUG(2, "%s(), Setting speed to %d\n", __FUNCTION__, speed); | ||
135 | |||
136 | switch (speed) { | ||
137 | case 1200: | ||
138 | cflag |= B1200; | ||
139 | break; | ||
140 | case 2400: | ||
141 | cflag |= B2400; | ||
142 | break; | ||
143 | case 4800: | ||
144 | cflag |= B4800; | ||
145 | break; | ||
146 | case 19200: | ||
147 | cflag |= B19200; | ||
148 | break; | ||
149 | case 38400: | ||
150 | cflag |= B38400; | ||
151 | break; | ||
152 | case 57600: | ||
153 | cflag |= B57600; | ||
154 | break; | ||
155 | case 115200: | ||
156 | cflag |= B115200; | ||
157 | break; | ||
158 | case 9600: | ||
159 | default: | ||
160 | cflag |= B9600; | ||
161 | break; | ||
162 | } | ||
163 | |||
164 | tty->termios->c_cflag = cflag; | ||
165 | if (tty->driver->set_termios) | ||
166 | tty->driver->set_termios(tty, &old_termios); | ||
167 | unlock_kernel(); | ||
168 | |||
169 | priv->io.speed = speed; | 132 | priv->io.speed = speed; |
133 | mutex_unlock(&tty->termios_mutex); | ||
170 | 134 | ||
171 | return 0; | 135 | return 0; |
172 | } | 136 | } |
@@ -202,8 +166,8 @@ static int irtty_set_dtr_rts(struct sir_dev *dev, int dtr, int rts) | |||
202 | * This function is not yet defined for all tty driver, so | 166 | * This function is not yet defined for all tty driver, so |
203 | * let's be careful... Jean II | 167 | * let's be careful... Jean II |
204 | */ | 168 | */ |
205 | IRDA_ASSERT(priv->tty->driver->tiocmset != NULL, return -1;); | 169 | IRDA_ASSERT(priv->tty->ops->tiocmset != NULL, return -1;); |
206 | priv->tty->driver->tiocmset(priv->tty, NULL, set, clear); | 170 | priv->tty->ops->tiocmset(priv->tty, NULL, set, clear); |
207 | 171 | ||
208 | return 0; | 172 | return 0; |
209 | } | 173 | } |
@@ -225,17 +189,13 @@ static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t | |||
225 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); | 189 | IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); |
226 | 190 | ||
227 | tty = priv->tty; | 191 | tty = priv->tty; |
228 | if (!tty->driver->write) | 192 | if (!tty->ops->write) |
229 | return 0; | 193 | return 0; |
230 | tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); | 194 | tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); |
231 | if (tty->driver->write_room) { | 195 | writelen = tty_write_room(tty); |
232 | writelen = tty->driver->write_room(tty); | 196 | if (writelen > len) |
233 | if (writelen > len) | ||
234 | writelen = len; | ||
235 | } | ||
236 | else | ||
237 | writelen = len; | 197 | writelen = len; |
238 | return tty->driver->write(tty, ptr, writelen); | 198 | return tty->ops->write(tty, ptr, writelen); |
239 | } | 199 | } |
240 | 200 | ||
241 | /* ------------------------------------------------------- */ | 201 | /* ------------------------------------------------------- */ |
@@ -321,7 +281,7 @@ static inline void irtty_stop_receiver(struct tty_struct *tty, int stop) | |||
321 | struct ktermios old_termios; | 281 | struct ktermios old_termios; |
322 | int cflag; | 282 | int cflag; |
323 | 283 | ||
324 | lock_kernel(); | 284 | mutex_lock(&tty->termios_mutex); |
325 | old_termios = *(tty->termios); | 285 | old_termios = *(tty->termios); |
326 | cflag = tty->termios->c_cflag; | 286 | cflag = tty->termios->c_cflag; |
327 | 287 | ||
@@ -331,9 +291,9 @@ static inline void irtty_stop_receiver(struct tty_struct *tty, int stop) | |||
331 | cflag |= CREAD; | 291 | cflag |= CREAD; |
332 | 292 | ||
333 | tty->termios->c_cflag = cflag; | 293 | tty->termios->c_cflag = cflag; |
334 | if (tty->driver->set_termios) | 294 | if (tty->ops->set_termios) |
335 | tty->driver->set_termios(tty, &old_termios); | 295 | tty->ops->set_termios(tty, &old_termios); |
336 | unlock_kernel(); | 296 | mutex_unlock(&tty->termios_mutex); |
337 | } | 297 | } |
338 | 298 | ||
339 | /*****************************************************************/ | 299 | /*****************************************************************/ |
@@ -359,8 +319,8 @@ static int irtty_start_dev(struct sir_dev *dev) | |||
359 | 319 | ||
360 | tty = priv->tty; | 320 | tty = priv->tty; |
361 | 321 | ||
362 | if (tty->driver->start) | 322 | if (tty->ops->start) |
363 | tty->driver->start(tty); | 323 | tty->ops->start(tty); |
364 | /* Make sure we can receive more data */ | 324 | /* Make sure we can receive more data */ |
365 | irtty_stop_receiver(tty, FALSE); | 325 | irtty_stop_receiver(tty, FALSE); |
366 | 326 | ||
@@ -388,8 +348,8 @@ static int irtty_stop_dev(struct sir_dev *dev) | |||
388 | 348 | ||
389 | /* Make sure we don't receive more data */ | 349 | /* Make sure we don't receive more data */ |
390 | irtty_stop_receiver(tty, TRUE); | 350 | irtty_stop_receiver(tty, TRUE); |
391 | if (tty->driver->stop) | 351 | if (tty->ops->stop) |
392 | tty->driver->stop(tty); | 352 | tty->ops->stop(tty); |
393 | 353 | ||
394 | mutex_unlock(&irtty_mutex); | 354 | mutex_unlock(&irtty_mutex); |
395 | 355 | ||
@@ -483,11 +443,10 @@ static int irtty_open(struct tty_struct *tty) | |||
483 | 443 | ||
484 | /* stop the underlying driver */ | 444 | /* stop the underlying driver */ |
485 | irtty_stop_receiver(tty, TRUE); | 445 | irtty_stop_receiver(tty, TRUE); |
486 | if (tty->driver->stop) | 446 | if (tty->ops->stop) |
487 | tty->driver->stop(tty); | 447 | tty->ops->stop(tty); |
488 | 448 | ||
489 | if (tty->driver->flush_buffer) | 449 | tty_driver_flush_buffer(tty); |
490 | tty->driver->flush_buffer(tty); | ||
491 | 450 | ||
492 | /* apply mtt override */ | 451 | /* apply mtt override */ |
493 | sir_tty_drv.qos_mtt_bits = qos_mtt_bits; | 452 | sir_tty_drv.qos_mtt_bits = qos_mtt_bits; |
@@ -564,8 +523,8 @@ static void irtty_close(struct tty_struct *tty) | |||
564 | /* Stop tty */ | 523 | /* Stop tty */ |
565 | irtty_stop_receiver(tty, TRUE); | 524 | irtty_stop_receiver(tty, TRUE); |
566 | tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); | 525 | tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); |
567 | if (tty->driver->stop) | 526 | if (tty->ops->stop) |
568 | tty->driver->stop(tty); | 527 | tty->ops->stop(tty); |
569 | 528 | ||
570 | kfree(priv); | 529 | kfree(priv); |
571 | 530 | ||
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index f023d5b67e6e..1c4b7e37912c 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c | |||
@@ -158,6 +158,9 @@ ppp_asynctty_open(struct tty_struct *tty) | |||
158 | struct asyncppp *ap; | 158 | struct asyncppp *ap; |
159 | int err; | 159 | int err; |
160 | 160 | ||
161 | if (tty->ops->write == NULL) | ||
162 | return -EOPNOTSUPP; | ||
163 | |||
161 | err = -ENOMEM; | 164 | err = -ENOMEM; |
162 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); | 165 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
163 | if (!ap) | 166 | if (!ap) |
@@ -359,8 +362,8 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, | |||
359 | tasklet_schedule(&ap->tsk); | 362 | tasklet_schedule(&ap->tsk); |
360 | ap_put(ap); | 363 | ap_put(ap); |
361 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) | 364 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) |
362 | && tty->driver->unthrottle) | 365 | && tty->ops->unthrottle) |
363 | tty->driver->unthrottle(tty); | 366 | tty->ops->unthrottle(tty); |
364 | } | 367 | } |
365 | 368 | ||
366 | static void | 369 | static void |
@@ -676,7 +679,7 @@ ppp_async_push(struct asyncppp *ap) | |||
676 | if (!tty_stuffed && ap->optr < ap->olim) { | 679 | if (!tty_stuffed && ap->optr < ap->olim) { |
677 | avail = ap->olim - ap->optr; | 680 | avail = ap->olim - ap->optr; |
678 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 681 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
679 | sent = tty->driver->write(tty, ap->optr, avail); | 682 | sent = tty->ops->write(tty, ap->optr, avail); |
680 | if (sent < 0) | 683 | if (sent < 0) |
681 | goto flush; /* error, e.g. loss of CD */ | 684 | goto flush; /* error, e.g. loss of CD */ |
682 | ap->optr += sent; | 685 | ap->optr += sent; |
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c index 0d80fa546719..48ed5fdbfe18 100644 --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c | |||
@@ -207,6 +207,9 @@ ppp_sync_open(struct tty_struct *tty) | |||
207 | struct syncppp *ap; | 207 | struct syncppp *ap; |
208 | int err; | 208 | int err; |
209 | 209 | ||
210 | if (tty->ops->write == NULL) | ||
211 | return -EOPNOTSUPP; | ||
212 | |||
210 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); | 213 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
211 | err = -ENOMEM; | 214 | err = -ENOMEM; |
212 | if (!ap) | 215 | if (!ap) |
@@ -399,8 +402,8 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, | |||
399 | tasklet_schedule(&ap->tsk); | 402 | tasklet_schedule(&ap->tsk); |
400 | sp_put(ap); | 403 | sp_put(ap); |
401 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) | 404 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) |
402 | && tty->driver->unthrottle) | 405 | && tty->ops->unthrottle) |
403 | tty->driver->unthrottle(tty); | 406 | tty->ops->unthrottle(tty); |
404 | } | 407 | } |
405 | 408 | ||
406 | static void | 409 | static void |
@@ -653,7 +656,7 @@ ppp_sync_push(struct syncppp *ap) | |||
653 | tty_stuffed = 0; | 656 | tty_stuffed = 0; |
654 | if (!tty_stuffed && ap->tpkt) { | 657 | if (!tty_stuffed && ap->tpkt) { |
655 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 658 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
656 | sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); | 659 | sent = tty->ops->write(tty, ap->tpkt->data, ap->tpkt->len); |
657 | if (sent < 0) | 660 | if (sent < 0) |
658 | goto flush; /* error, e.g. loss of CD */ | 661 | goto flush; /* error, e.g. loss of CD */ |
659 | if (sent < ap->tpkt->len) { | 662 | if (sent < ap->tpkt->len) { |
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 5a55ede352f4..84af68fdb6c2 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -396,14 +396,14 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len) | |||
396 | 396 | ||
397 | /* Order of next two lines is *very* important. | 397 | /* Order of next two lines is *very* important. |
398 | * When we are sending a little amount of data, | 398 | * When we are sending a little amount of data, |
399 | * the transfer may be completed inside driver.write() | 399 | * the transfer may be completed inside the ops->write() |
400 | * routine, because it's running with interrupts enabled. | 400 | * routine, because it's running with interrupts enabled. |
401 | * In this case we *never* got WRITE_WAKEUP event, | 401 | * In this case we *never* got WRITE_WAKEUP event, |
402 | * if we did not request it before write operation. | 402 | * if we did not request it before write operation. |
403 | * 14 Oct 1994 Dmitry Gorodchanin. | 403 | * 14 Oct 1994 Dmitry Gorodchanin. |
404 | */ | 404 | */ |
405 | sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); | 405 | sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); |
406 | actual = sl->tty->driver->write(sl->tty, sl->xbuff, count); | 406 | actual = sl->tty->ops->write(sl->tty, sl->xbuff, count); |
407 | #ifdef SL_CHECK_TRANSMIT | 407 | #ifdef SL_CHECK_TRANSMIT |
408 | sl->dev->trans_start = jiffies; | 408 | sl->dev->trans_start = jiffies; |
409 | #endif | 409 | #endif |
@@ -437,7 +437,7 @@ static void slip_write_wakeup(struct tty_struct *tty) | |||
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | 439 | ||
440 | actual = tty->driver->write(tty, sl->xhead, sl->xleft); | 440 | actual = tty->ops->write(tty, sl->xhead, sl->xleft); |
441 | sl->xleft -= actual; | 441 | sl->xleft -= actual; |
442 | sl->xhead += actual; | 442 | sl->xhead += actual; |
443 | } | 443 | } |
@@ -462,7 +462,7 @@ static void sl_tx_timeout(struct net_device *dev) | |||
462 | } | 462 | } |
463 | printk(KERN_WARNING "%s: transmit timed out, %s?\n", | 463 | printk(KERN_WARNING "%s: transmit timed out, %s?\n", |
464 | dev->name, | 464 | dev->name, |
465 | (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ? | 465 | (tty_chars_in_buffer(sl->tty) || sl->xleft) ? |
466 | "bad line quality" : "driver error"); | 466 | "bad line quality" : "driver error"); |
467 | sl->xleft = 0; | 467 | sl->xleft = 0; |
468 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); | 468 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); |
@@ -830,6 +830,9 @@ static int slip_open(struct tty_struct *tty) | |||
830 | if (!capable(CAP_NET_ADMIN)) | 830 | if (!capable(CAP_NET_ADMIN)) |
831 | return -EPERM; | 831 | return -EPERM; |
832 | 832 | ||
833 | if (tty->ops->write == NULL) | ||
834 | return -EOPNOTSUPP; | ||
835 | |||
833 | /* RTnetlink lock is misused here to serialize concurrent | 836 | /* RTnetlink lock is misused here to serialize concurrent |
834 | opens of slip channels. There are better ways, but it is | 837 | opens of slip channels. There are better ways, but it is |
835 | the simplest one. | 838 | the simplest one. |
@@ -1432,7 +1435,7 @@ static void sl_outfill(unsigned long sls) | |||
1432 | /* put END into tty queue. Is it right ??? */ | 1435 | /* put END into tty queue. Is it right ??? */ |
1433 | if (!netif_queue_stopped(sl->dev)) { | 1436 | if (!netif_queue_stopped(sl->dev)) { |
1434 | /* if device busy no outfill */ | 1437 | /* if device busy no outfill */ |
1435 | sl->tty->driver->write(sl->tty, &s, 1); | 1438 | sl->tty->ops->write(sl->tty, &s, 1); |
1436 | } | 1439 | } |
1437 | } else | 1440 | } else |
1438 | set_bit(SLF_OUTWAIT, &sl->flags); | 1441 | set_bit(SLF_OUTWAIT, &sl->flags); |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 0f8aca8a4d43..249e18053d5f 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | #include <asm/system.h> | 19 | #include <asm/system.h> |
20 | #include <asm/uaccess.h> | 20 | #include <linux/uaccess.h> |
21 | #include <linux/bitops.h> | 21 | #include <linux/bitops.h> |
22 | #include <linux/string.h> | 22 | #include <linux/string.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
@@ -95,7 +95,7 @@ static struct x25_asy *x25_asy_alloc(void) | |||
95 | x25_asy_devs[i] = dev; | 95 | x25_asy_devs[i] = dev; |
96 | return sl; | 96 | return sl; |
97 | } else { | 97 | } else { |
98 | printk("x25_asy_alloc() - register_netdev() failure.\n"); | 98 | printk(KERN_WARNING "x25_asy_alloc() - register_netdev() failure.\n"); |
99 | free_netdev(dev); | 99 | free_netdev(dev); |
100 | } | 100 | } |
101 | } | 101 | } |
@@ -112,23 +112,22 @@ static void x25_asy_free(struct x25_asy *sl) | |||
112 | kfree(sl->xbuff); | 112 | kfree(sl->xbuff); |
113 | sl->xbuff = NULL; | 113 | sl->xbuff = NULL; |
114 | 114 | ||
115 | if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { | 115 | if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) |
116 | printk("%s: x25_asy_free for already free unit.\n", sl->dev->name); | 116 | printk(KERN_ERR "%s: x25_asy_free for already free unit.\n", |
117 | } | 117 | sl->dev->name); |
118 | } | 118 | } |
119 | 119 | ||
120 | static int x25_asy_change_mtu(struct net_device *dev, int newmtu) | 120 | static int x25_asy_change_mtu(struct net_device *dev, int newmtu) |
121 | { | 121 | { |
122 | struct x25_asy *sl = dev->priv; | 122 | struct x25_asy *sl = dev->priv; |
123 | unsigned char *xbuff, *rbuff; | 123 | unsigned char *xbuff, *rbuff; |
124 | int len = 2* newmtu; | 124 | int len = 2 * newmtu; |
125 | 125 | ||
126 | xbuff = kmalloc(len + 4, GFP_ATOMIC); | 126 | xbuff = kmalloc(len + 4, GFP_ATOMIC); |
127 | rbuff = kmalloc(len + 4, GFP_ATOMIC); | 127 | rbuff = kmalloc(len + 4, GFP_ATOMIC); |
128 | 128 | ||
129 | if (xbuff == NULL || rbuff == NULL) | 129 | if (xbuff == NULL || rbuff == NULL) { |
130 | { | 130 | printk(KERN_WARNING "%s: unable to grow X.25 buffers, MTU change cancelled.\n", |
131 | printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", | ||
132 | dev->name); | 131 | dev->name); |
133 | kfree(xbuff); | 132 | kfree(xbuff); |
134 | kfree(rbuff); | 133 | kfree(rbuff); |
@@ -193,25 +192,23 @@ static void x25_asy_bump(struct x25_asy *sl) | |||
193 | int err; | 192 | int err; |
194 | 193 | ||
195 | count = sl->rcount; | 194 | count = sl->rcount; |
196 | sl->stats.rx_bytes+=count; | 195 | sl->stats.rx_bytes += count; |
197 | 196 | ||
198 | skb = dev_alloc_skb(count+1); | 197 | skb = dev_alloc_skb(count+1); |
199 | if (skb == NULL) | 198 | if (skb == NULL) { |
200 | { | 199 | printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", |
201 | printk("%s: memory squeeze, dropping packet.\n", sl->dev->name); | 200 | sl->dev->name); |
202 | sl->stats.rx_dropped++; | 201 | sl->stats.rx_dropped++; |
203 | return; | 202 | return; |
204 | } | 203 | } |
205 | skb_push(skb,1); /* LAPB internal control */ | 204 | skb_push(skb, 1); /* LAPB internal control */ |
206 | memcpy(skb_put(skb,count), sl->rbuff, count); | 205 | memcpy(skb_put(skb, count), sl->rbuff, count); |
207 | skb->protocol = x25_type_trans(skb, sl->dev); | 206 | skb->protocol = x25_type_trans(skb, sl->dev); |
208 | if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK) | 207 | err = lapb_data_received(skb->dev, skb); |
209 | { | 208 | if (err != LAPB_OK) { |
210 | kfree_skb(skb); | 209 | kfree_skb(skb); |
211 | printk(KERN_DEBUG "x25_asy: data received err - %d\n",err); | 210 | printk(KERN_DEBUG "x25_asy: data received err - %d\n", err); |
212 | } | 211 | } else { |
213 | else | ||
214 | { | ||
215 | netif_rx(skb); | 212 | netif_rx(skb); |
216 | sl->dev->last_rx = jiffies; | 213 | sl->dev->last_rx = jiffies; |
217 | sl->stats.rx_packets++; | 214 | sl->stats.rx_packets++; |
@@ -224,10 +221,11 @@ static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len) | |||
224 | unsigned char *p; | 221 | unsigned char *p; |
225 | int actual, count, mtu = sl->dev->mtu; | 222 | int actual, count, mtu = sl->dev->mtu; |
226 | 223 | ||
227 | if (len > mtu) | 224 | if (len > mtu) { |
228 | { /* Sigh, shouldn't occur BUT ... */ | 225 | /* Sigh, shouldn't occur BUT ... */ |
229 | len = mtu; | 226 | len = mtu; |
230 | printk ("%s: truncating oversized transmit packet!\n", sl->dev->name); | 227 | printk(KERN_DEBUG "%s: truncating oversized transmit packet!\n", |
228 | sl->dev->name); | ||
231 | sl->stats.tx_dropped++; | 229 | sl->stats.tx_dropped++; |
232 | x25_asy_unlock(sl); | 230 | x25_asy_unlock(sl); |
233 | return; | 231 | return; |
@@ -245,7 +243,7 @@ static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len) | |||
245 | * 14 Oct 1994 Dmitry Gorodchanin. | 243 | * 14 Oct 1994 Dmitry Gorodchanin. |
246 | */ | 244 | */ |
247 | sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); | 245 | sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); |
248 | actual = sl->tty->driver->write(sl->tty, sl->xbuff, count); | 246 | actual = sl->tty->ops->write(sl->tty, sl->xbuff, count); |
249 | sl->xleft = count - actual; | 247 | sl->xleft = count - actual; |
250 | sl->xhead = sl->xbuff + actual; | 248 | sl->xhead = sl->xbuff + actual; |
251 | /* VSV */ | 249 | /* VSV */ |
@@ -265,8 +263,7 @@ static void x25_asy_write_wakeup(struct tty_struct *tty) | |||
265 | if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev)) | 263 | if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev)) |
266 | return; | 264 | return; |
267 | 265 | ||
268 | if (sl->xleft <= 0) | 266 | if (sl->xleft <= 0) { |
269 | { | ||
270 | /* Now serial buffer is almost free & we can start | 267 | /* Now serial buffer is almost free & we can start |
271 | * transmission of another packet */ | 268 | * transmission of another packet */ |
272 | sl->stats.tx_packets++; | 269 | sl->stats.tx_packets++; |
@@ -275,14 +272,14 @@ static void x25_asy_write_wakeup(struct tty_struct *tty) | |||
275 | return; | 272 | return; |
276 | } | 273 | } |
277 | 274 | ||
278 | actual = tty->driver->write(tty, sl->xhead, sl->xleft); | 275 | actual = tty->ops->write(tty, sl->xhead, sl->xleft); |
279 | sl->xleft -= actual; | 276 | sl->xleft -= actual; |
280 | sl->xhead += actual; | 277 | sl->xhead += actual; |
281 | } | 278 | } |
282 | 279 | ||
283 | static void x25_asy_timeout(struct net_device *dev) | 280 | static void x25_asy_timeout(struct net_device *dev) |
284 | { | 281 | { |
285 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 282 | struct x25_asy *sl = dev->priv; |
286 | 283 | ||
287 | spin_lock(&sl->lock); | 284 | spin_lock(&sl->lock); |
288 | if (netif_queue_stopped(dev)) { | 285 | if (netif_queue_stopped(dev)) { |
@@ -290,7 +287,7 @@ static void x25_asy_timeout(struct net_device *dev) | |||
290 | * 14 Oct 1994 Dmitry Gorodchanin. | 287 | * 14 Oct 1994 Dmitry Gorodchanin. |
291 | */ | 288 | */ |
292 | printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, | 289 | printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, |
293 | (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ? | 290 | (tty_chars_in_buffer(sl->tty) || sl->xleft) ? |
294 | "bad line quality" : "driver error"); | 291 | "bad line quality" : "driver error"); |
295 | sl->xleft = 0; | 292 | sl->xleft = 0; |
296 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); | 293 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); |
@@ -303,31 +300,34 @@ static void x25_asy_timeout(struct net_device *dev) | |||
303 | 300 | ||
304 | static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | 301 | static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) |
305 | { | 302 | { |
306 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 303 | struct x25_asy *sl = dev->priv; |
307 | int err; | 304 | int err; |
308 | 305 | ||
309 | if (!netif_running(sl->dev)) { | 306 | if (!netif_running(sl->dev)) { |
310 | printk("%s: xmit call when iface is down\n", dev->name); | 307 | printk(KERN_ERR "%s: xmit call when iface is down\n", |
308 | dev->name); | ||
311 | kfree_skb(skb); | 309 | kfree_skb(skb); |
312 | return 0; | 310 | return 0; |
313 | } | 311 | } |
314 | 312 | ||
315 | switch(skb->data[0]) | 313 | switch (skb->data[0]) { |
316 | { | 314 | case 0x00: |
317 | case 0x00:break; | 315 | break; |
318 | case 0x01: /* Connection request .. do nothing */ | 316 | case 0x01: /* Connection request .. do nothing */ |
319 | if((err=lapb_connect_request(dev))!=LAPB_OK) | 317 | err = lapb_connect_request(dev); |
320 | printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); | 318 | if (err != LAPB_OK) |
321 | kfree_skb(skb); | 319 | printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); |
322 | return 0; | 320 | kfree_skb(skb); |
323 | case 0x02: /* Disconnect request .. do nothing - hang up ?? */ | 321 | return 0; |
324 | if((err=lapb_disconnect_request(dev))!=LAPB_OK) | 322 | case 0x02: /* Disconnect request .. do nothing - hang up ?? */ |
325 | printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); | 323 | err = lapb_disconnect_request(dev); |
326 | default: | 324 | if (err != LAPB_OK) |
327 | kfree_skb(skb); | 325 | printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); |
328 | return 0; | 326 | default: |
327 | kfree_skb(skb); | ||
328 | return 0; | ||
329 | } | 329 | } |
330 | skb_pull(skb,1); /* Remove control byte */ | 330 | skb_pull(skb, 1); /* Remove control byte */ |
331 | /* | 331 | /* |
332 | * If we are busy already- too bad. We ought to be able | 332 | * If we are busy already- too bad. We ought to be able |
333 | * to queue things at this point, to allow for a little | 333 | * to queue things at this point, to allow for a little |
@@ -338,10 +338,10 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
338 | * So, no queues ! | 338 | * So, no queues ! |
339 | * 14 Oct 1994 Dmitry Gorodchanin. | 339 | * 14 Oct 1994 Dmitry Gorodchanin. |
340 | */ | 340 | */ |
341 | 341 | ||
342 | if((err=lapb_data_request(dev,skb))!=LAPB_OK) | 342 | err = lapb_data_request(dev, skb); |
343 | { | 343 | if (err != LAPB_OK) { |
344 | printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); | 344 | printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err); |
345 | kfree_skb(skb); | 345 | kfree_skb(skb); |
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
@@ -357,7 +357,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
357 | * Called when I frame data arrives. We did the work above - throw it | 357 | * Called when I frame data arrives. We did the work above - throw it |
358 | * at the net layer. | 358 | * at the net layer. |
359 | */ | 359 | */ |
360 | 360 | ||
361 | static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) | 361 | static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) |
362 | { | 362 | { |
363 | skb->dev->last_rx = jiffies; | 363 | skb->dev->last_rx = jiffies; |
@@ -369,24 +369,22 @@ static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) | |||
369 | * busy cases too well. Its tricky to see how to do this nicely - | 369 | * busy cases too well. Its tricky to see how to do this nicely - |
370 | * perhaps lapb should allow us to bounce this ? | 370 | * perhaps lapb should allow us to bounce this ? |
371 | */ | 371 | */ |
372 | 372 | ||
373 | static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) | 373 | static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) |
374 | { | 374 | { |
375 | struct x25_asy *sl=dev->priv; | 375 | struct x25_asy *sl = dev->priv; |
376 | 376 | ||
377 | spin_lock(&sl->lock); | 377 | spin_lock(&sl->lock); |
378 | if (netif_queue_stopped(sl->dev) || sl->tty == NULL) | 378 | if (netif_queue_stopped(sl->dev) || sl->tty == NULL) { |
379 | { | ||
380 | spin_unlock(&sl->lock); | 379 | spin_unlock(&sl->lock); |
381 | printk(KERN_ERR "x25_asy: tbusy drop\n"); | 380 | printk(KERN_ERR "x25_asy: tbusy drop\n"); |
382 | kfree_skb(skb); | 381 | kfree_skb(skb); |
383 | return; | 382 | return; |
384 | } | 383 | } |
385 | /* We were not busy, so we are now... :-) */ | 384 | /* We were not busy, so we are now... :-) */ |
386 | if (skb != NULL) | 385 | if (skb != NULL) { |
387 | { | ||
388 | x25_asy_lock(sl); | 386 | x25_asy_lock(sl); |
389 | sl->stats.tx_bytes+=skb->len; | 387 | sl->stats.tx_bytes += skb->len; |
390 | x25_asy_encaps(sl, skb->data, skb->len); | 388 | x25_asy_encaps(sl, skb->data, skb->len); |
391 | dev_kfree_skb(skb); | 389 | dev_kfree_skb(skb); |
392 | } | 390 | } |
@@ -396,15 +394,16 @@ static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) | |||
396 | /* | 394 | /* |
397 | * LAPB connection establish/down information. | 395 | * LAPB connection establish/down information. |
398 | */ | 396 | */ |
399 | 397 | ||
400 | static void x25_asy_connected(struct net_device *dev, int reason) | 398 | static void x25_asy_connected(struct net_device *dev, int reason) |
401 | { | 399 | { |
402 | struct x25_asy *sl = dev->priv; | 400 | struct x25_asy *sl = dev->priv; |
403 | struct sk_buff *skb; | 401 | struct sk_buff *skb; |
404 | unsigned char *ptr; | 402 | unsigned char *ptr; |
405 | 403 | ||
406 | if ((skb = dev_alloc_skb(1)) == NULL) { | 404 | skb = dev_alloc_skb(1); |
407 | printk(KERN_ERR "lapbeth: out of memory\n"); | 405 | if (skb == NULL) { |
406 | printk(KERN_ERR "x25_asy: out of memory\n"); | ||
408 | return; | 407 | return; |
409 | } | 408 | } |
410 | 409 | ||
@@ -422,7 +421,8 @@ static void x25_asy_disconnected(struct net_device *dev, int reason) | |||
422 | struct sk_buff *skb; | 421 | struct sk_buff *skb; |
423 | unsigned char *ptr; | 422 | unsigned char *ptr; |
424 | 423 | ||
425 | if ((skb = dev_alloc_skb(1)) == NULL) { | 424 | skb = dev_alloc_skb(1); |
425 | if (skb == NULL) { | ||
426 | printk(KERN_ERR "x25_asy: out of memory\n"); | 426 | printk(KERN_ERR "x25_asy: out of memory\n"); |
427 | return; | 427 | return; |
428 | } | 428 | } |
@@ -449,7 +449,7 @@ static struct lapb_register_struct x25_asy_callbacks = { | |||
449 | /* Open the low-level part of the X.25 channel. Easy! */ | 449 | /* Open the low-level part of the X.25 channel. Easy! */ |
450 | static int x25_asy_open(struct net_device *dev) | 450 | static int x25_asy_open(struct net_device *dev) |
451 | { | 451 | { |
452 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 452 | struct x25_asy *sl = dev->priv; |
453 | unsigned long len; | 453 | unsigned long len; |
454 | int err; | 454 | int err; |
455 | 455 | ||
@@ -466,13 +466,11 @@ static int x25_asy_open(struct net_device *dev) | |||
466 | len = dev->mtu * 2; | 466 | len = dev->mtu * 2; |
467 | 467 | ||
468 | sl->rbuff = kmalloc(len + 4, GFP_KERNEL); | 468 | sl->rbuff = kmalloc(len + 4, GFP_KERNEL); |
469 | if (sl->rbuff == NULL) { | 469 | if (sl->rbuff == NULL) |
470 | goto norbuff; | 470 | goto norbuff; |
471 | } | ||
472 | sl->xbuff = kmalloc(len + 4, GFP_KERNEL); | 471 | sl->xbuff = kmalloc(len + 4, GFP_KERNEL); |
473 | if (sl->xbuff == NULL) { | 472 | if (sl->xbuff == NULL) |
474 | goto noxbuff; | 473 | goto noxbuff; |
475 | } | ||
476 | 474 | ||
477 | sl->buffsize = len; | 475 | sl->buffsize = len; |
478 | sl->rcount = 0; | 476 | sl->rcount = 0; |
@@ -480,11 +478,12 @@ static int x25_asy_open(struct net_device *dev) | |||
480 | sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */ | 478 | sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */ |
481 | 479 | ||
482 | netif_start_queue(dev); | 480 | netif_start_queue(dev); |
483 | 481 | ||
484 | /* | 482 | /* |
485 | * Now attach LAPB | 483 | * Now attach LAPB |
486 | */ | 484 | */ |
487 | if((err=lapb_register(dev, &x25_asy_callbacks))==LAPB_OK) | 485 | err = lapb_register(dev, &x25_asy_callbacks); |
486 | if (err == LAPB_OK) | ||
488 | return 0; | 487 | return 0; |
489 | 488 | ||
490 | /* Cleanup */ | 489 | /* Cleanup */ |
@@ -499,18 +498,20 @@ norbuff: | |||
499 | /* Close the low-level part of the X.25 channel. Easy! */ | 498 | /* Close the low-level part of the X.25 channel. Easy! */ |
500 | static int x25_asy_close(struct net_device *dev) | 499 | static int x25_asy_close(struct net_device *dev) |
501 | { | 500 | { |
502 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 501 | struct x25_asy *sl = dev->priv; |
503 | int err; | 502 | int err; |
504 | 503 | ||
505 | spin_lock(&sl->lock); | 504 | spin_lock(&sl->lock); |
506 | if (sl->tty) | 505 | if (sl->tty) |
507 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); | 506 | sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); |
508 | 507 | ||
509 | netif_stop_queue(dev); | 508 | netif_stop_queue(dev); |
510 | sl->rcount = 0; | 509 | sl->rcount = 0; |
511 | sl->xleft = 0; | 510 | sl->xleft = 0; |
512 | if((err=lapb_unregister(dev))!=LAPB_OK) | 511 | err = lapb_unregister(dev); |
513 | printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",err); | 512 | if (err != LAPB_OK) |
513 | printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n", | ||
514 | err); | ||
514 | spin_unlock(&sl->lock); | 515 | spin_unlock(&sl->lock); |
515 | return 0; | 516 | return 0; |
516 | } | 517 | } |
@@ -521,8 +522,9 @@ static int x25_asy_close(struct net_device *dev) | |||
521 | * a block of X.25 data has been received, which can now be decapsulated | 522 | * a block of X.25 data has been received, which can now be decapsulated |
522 | * and sent on to some IP layer for further processing. | 523 | * and sent on to some IP layer for further processing. |
523 | */ | 524 | */ |
524 | 525 | ||
525 | static void x25_asy_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) | 526 | static void x25_asy_receive_buf(struct tty_struct *tty, |
527 | const unsigned char *cp, char *fp, int count) | ||
526 | { | 528 | { |
527 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; | 529 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; |
528 | 530 | ||
@@ -533,9 +535,8 @@ static void x25_asy_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
533 | /* Read the characters out of the buffer */ | 535 | /* Read the characters out of the buffer */ |
534 | while (count--) { | 536 | while (count--) { |
535 | if (fp && *fp++) { | 537 | if (fp && *fp++) { |
536 | if (!test_and_set_bit(SLF_ERROR, &sl->flags)) { | 538 | if (!test_and_set_bit(SLF_ERROR, &sl->flags)) |
537 | sl->stats.rx_errors++; | 539 | sl->stats.rx_errors++; |
538 | } | ||
539 | cp++; | 540 | cp++; |
540 | continue; | 541 | continue; |
541 | } | 542 | } |
@@ -556,31 +557,31 @@ static int x25_asy_open_tty(struct tty_struct *tty) | |||
556 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; | 557 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; |
557 | int err; | 558 | int err; |
558 | 559 | ||
560 | if (tty->ops->write == NULL) | ||
561 | return -EOPNOTSUPP; | ||
562 | |||
559 | /* First make sure we're not already connected. */ | 563 | /* First make sure we're not already connected. */ |
560 | if (sl && sl->magic == X25_ASY_MAGIC) { | 564 | if (sl && sl->magic == X25_ASY_MAGIC) |
561 | return -EEXIST; | 565 | return -EEXIST; |
562 | } | ||
563 | 566 | ||
564 | /* OK. Find a free X.25 channel to use. */ | 567 | /* OK. Find a free X.25 channel to use. */ |
565 | if ((sl = x25_asy_alloc()) == NULL) { | 568 | sl = x25_asy_alloc(); |
569 | if (sl == NULL) | ||
566 | return -ENFILE; | 570 | return -ENFILE; |
567 | } | ||
568 | 571 | ||
569 | sl->tty = tty; | 572 | sl->tty = tty; |
570 | tty->disc_data = sl; | 573 | tty->disc_data = sl; |
571 | tty->receive_room = 65536; | 574 | tty->receive_room = 65536; |
572 | if (tty->driver->flush_buffer) { | 575 | tty_driver_flush_buffer(tty); |
573 | tty->driver->flush_buffer(tty); | ||
574 | } | ||
575 | tty_ldisc_flush(tty); | 576 | tty_ldisc_flush(tty); |
576 | 577 | ||
577 | /* Restore default settings */ | 578 | /* Restore default settings */ |
578 | sl->dev->type = ARPHRD_X25; | 579 | sl->dev->type = ARPHRD_X25; |
579 | 580 | ||
580 | /* Perform the low-level X.25 async init */ | 581 | /* Perform the low-level X.25 async init */ |
581 | if ((err = x25_asy_open(sl->dev))) | 582 | err = x25_asy_open(sl->dev); |
583 | if (err) | ||
582 | return err; | 584 | return err; |
583 | |||
584 | /* Done. We have linked the TTY line to a channel. */ | 585 | /* Done. We have linked the TTY line to a channel. */ |
585 | return sl->dev->base_addr; | 586 | return sl->dev->base_addr; |
586 | } | 587 | } |
@@ -601,9 +602,7 @@ static void x25_asy_close_tty(struct tty_struct *tty) | |||
601 | return; | 602 | return; |
602 | 603 | ||
603 | if (sl->dev->flags & IFF_UP) | 604 | if (sl->dev->flags & IFF_UP) |
604 | { | 605 | dev_close(sl->dev); |
605 | (void) dev_close(sl->dev); | ||
606 | } | ||
607 | 606 | ||
608 | tty->disc_data = NULL; | 607 | tty->disc_data = NULL; |
609 | sl->tty = NULL; | 608 | sl->tty = NULL; |
@@ -613,8 +612,7 @@ static void x25_asy_close_tty(struct tty_struct *tty) | |||
613 | 612 | ||
614 | static struct net_device_stats *x25_asy_get_stats(struct net_device *dev) | 613 | static struct net_device_stats *x25_asy_get_stats(struct net_device *dev) |
615 | { | 614 | { |
616 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 615 | struct x25_asy *sl = dev->priv; |
617 | |||
618 | return &sl->stats; | 616 | return &sl->stats; |
619 | } | 617 | } |
620 | 618 | ||
@@ -641,21 +639,19 @@ int x25_asy_esc(unsigned char *s, unsigned char *d, int len) | |||
641 | * character sequence, according to the X.25 protocol. | 639 | * character sequence, according to the X.25 protocol. |
642 | */ | 640 | */ |
643 | 641 | ||
644 | while (len-- > 0) | 642 | while (len-- > 0) { |
645 | { | 643 | switch (c = *s++) { |
646 | switch(c = *s++) | 644 | case X25_END: |
647 | { | 645 | *ptr++ = X25_ESC; |
648 | case X25_END: | 646 | *ptr++ = X25_ESCAPE(X25_END); |
649 | *ptr++ = X25_ESC; | 647 | break; |
650 | *ptr++ = X25_ESCAPE(X25_END); | 648 | case X25_ESC: |
651 | break; | 649 | *ptr++ = X25_ESC; |
652 | case X25_ESC: | 650 | *ptr++ = X25_ESCAPE(X25_ESC); |
653 | *ptr++ = X25_ESC; | 651 | break; |
654 | *ptr++ = X25_ESCAPE(X25_ESC); | 652 | default: |
655 | break; | 653 | *ptr++ = c; |
656 | default: | 654 | break; |
657 | *ptr++ = c; | ||
658 | break; | ||
659 | } | 655 | } |
660 | } | 656 | } |
661 | *ptr++ = X25_END; | 657 | *ptr++ = X25_END; |
@@ -665,31 +661,25 @@ int x25_asy_esc(unsigned char *s, unsigned char *d, int len) | |||
665 | static void x25_asy_unesc(struct x25_asy *sl, unsigned char s) | 661 | static void x25_asy_unesc(struct x25_asy *sl, unsigned char s) |
666 | { | 662 | { |
667 | 663 | ||
668 | switch(s) | 664 | switch (s) { |
669 | { | 665 | case X25_END: |
670 | case X25_END: | 666 | if (!test_and_clear_bit(SLF_ERROR, &sl->flags) |
671 | if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) | 667 | && sl->rcount > 2) |
672 | { | 668 | x25_asy_bump(sl); |
673 | x25_asy_bump(sl); | 669 | clear_bit(SLF_ESCAPE, &sl->flags); |
674 | } | 670 | sl->rcount = 0; |
675 | clear_bit(SLF_ESCAPE, &sl->flags); | 671 | return; |
676 | sl->rcount = 0; | 672 | case X25_ESC: |
677 | return; | 673 | set_bit(SLF_ESCAPE, &sl->flags); |
678 | 674 | return; | |
679 | case X25_ESC: | 675 | case X25_ESCAPE(X25_ESC): |
680 | set_bit(SLF_ESCAPE, &sl->flags); | 676 | case X25_ESCAPE(X25_END): |
681 | return; | 677 | if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) |
682 | 678 | s = X25_UNESCAPE(s); | |
683 | case X25_ESCAPE(X25_ESC): | 679 | break; |
684 | case X25_ESCAPE(X25_END): | 680 | } |
685 | if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) | 681 | if (!test_bit(SLF_ERROR, &sl->flags)) { |
686 | s = X25_UNESCAPE(s); | 682 | if (sl->rcount < sl->buffsize) { |
687 | break; | ||
688 | } | ||
689 | if (!test_bit(SLF_ERROR, &sl->flags)) | ||
690 | { | ||
691 | if (sl->rcount < sl->buffsize) | ||
692 | { | ||
693 | sl->rbuff[sl->rcount++] = s; | 683 | sl->rbuff[sl->rcount++] = s; |
694 | return; | 684 | return; |
695 | } | 685 | } |
@@ -709,7 +699,7 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, | |||
709 | if (!sl || sl->magic != X25_ASY_MAGIC) | 699 | if (!sl || sl->magic != X25_ASY_MAGIC) |
710 | return -EINVAL; | 700 | return -EINVAL; |
711 | 701 | ||
712 | switch(cmd) { | 702 | switch (cmd) { |
713 | case SIOCGIFNAME: | 703 | case SIOCGIFNAME: |
714 | if (copy_to_user((void __user *)arg, sl->dev->name, | 704 | if (copy_to_user((void __user *)arg, sl->dev->name, |
715 | strlen(sl->dev->name) + 1)) | 705 | strlen(sl->dev->name) + 1)) |
@@ -724,8 +714,8 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, | |||
724 | 714 | ||
725 | static int x25_asy_open_dev(struct net_device *dev) | 715 | static int x25_asy_open_dev(struct net_device *dev) |
726 | { | 716 | { |
727 | struct x25_asy *sl = (struct x25_asy*)(dev->priv); | 717 | struct x25_asy *sl = dev->priv; |
728 | if(sl->tty==NULL) | 718 | if (sl->tty == NULL) |
729 | return -ENODEV; | 719 | return -ENODEV; |
730 | return 0; | 720 | return 0; |
731 | } | 721 | } |
@@ -741,9 +731,9 @@ static void x25_asy_setup(struct net_device *dev) | |||
741 | set_bit(SLF_INUSE, &sl->flags); | 731 | set_bit(SLF_INUSE, &sl->flags); |
742 | 732 | ||
743 | /* | 733 | /* |
744 | * Finish setting up the DEVICE info. | 734 | * Finish setting up the DEVICE info. |
745 | */ | 735 | */ |
746 | 736 | ||
747 | dev->mtu = SL_MTU; | 737 | dev->mtu = SL_MTU; |
748 | dev->hard_start_xmit = x25_asy_xmit; | 738 | dev->hard_start_xmit = x25_asy_xmit; |
749 | dev->tx_timeout = x25_asy_timeout; | 739 | dev->tx_timeout = x25_asy_timeout; |
@@ -778,9 +768,10 @@ static int __init init_x25_asy(void) | |||
778 | x25_asy_maxdev = 4; /* Sanity */ | 768 | x25_asy_maxdev = 4; /* Sanity */ |
779 | 769 | ||
780 | printk(KERN_INFO "X.25 async: version 0.00 ALPHA " | 770 | printk(KERN_INFO "X.25 async: version 0.00 ALPHA " |
781 | "(dynamic channels, max=%d).\n", x25_asy_maxdev ); | 771 | "(dynamic channels, max=%d).\n", x25_asy_maxdev); |
782 | 772 | ||
783 | x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device*), GFP_KERNEL); | 773 | x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *), |
774 | GFP_KERNEL); | ||
784 | if (!x25_asy_devs) { | 775 | if (!x25_asy_devs) { |
785 | printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " | 776 | printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " |
786 | "array! Uaargh! (-> No X.25 available)\n"); | 777 | "array! Uaargh! (-> No X.25 available)\n"); |
@@ -802,7 +793,7 @@ static void __exit exit_x25_asy(void) | |||
802 | struct x25_asy *sl = dev->priv; | 793 | struct x25_asy *sl = dev->priv; |
803 | 794 | ||
804 | spin_lock_bh(&sl->lock); | 795 | spin_lock_bh(&sl->lock); |
805 | if (sl->tty) | 796 | if (sl->tty) |
806 | tty_hangup(sl->tty); | 797 | tty_hangup(sl->tty); |
807 | 798 | ||
808 | spin_unlock_bh(&sl->lock); | 799 | spin_unlock_bh(&sl->lock); |
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c index 9cf03327386a..eadc1ab6bbce 100644 --- a/drivers/serial/kgdboc.c +++ b/drivers/serial/kgdboc.c | |||
@@ -96,12 +96,14 @@ static void cleanup_kgdboc(void) | |||
96 | 96 | ||
97 | static int kgdboc_get_char(void) | 97 | static int kgdboc_get_char(void) |
98 | { | 98 | { |
99 | return kgdb_tty_driver->poll_get_char(kgdb_tty_driver, kgdb_tty_line); | 99 | return kgdb_tty_driver->ops->poll_get_char(kgdb_tty_driver, |
100 | kgdb_tty_line); | ||
100 | } | 101 | } |
101 | 102 | ||
102 | static void kgdboc_put_char(u8 chr) | 103 | static void kgdboc_put_char(u8 chr) |
103 | { | 104 | { |
104 | kgdb_tty_driver->poll_put_char(kgdb_tty_driver, kgdb_tty_line, chr); | 105 | kgdb_tty_driver->ops->poll_put_char(kgdb_tty_driver, |
106 | kgdb_tty_line, chr); | ||
105 | } | 107 | } |
106 | 108 | ||
107 | static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp) | 109 | static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp) |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 6c7a5cf76582..1e2b9d826f69 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -532,15 +532,25 @@ uart_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
532 | static int uart_write_room(struct tty_struct *tty) | 532 | static int uart_write_room(struct tty_struct *tty) |
533 | { | 533 | { |
534 | struct uart_state *state = tty->driver_data; | 534 | struct uart_state *state = tty->driver_data; |
535 | unsigned long flags; | ||
536 | int ret; | ||
535 | 537 | ||
536 | return uart_circ_chars_free(&state->info->xmit); | 538 | spin_lock_irqsave(&state->port->lock, flags); |
539 | ret = uart_circ_chars_free(&state->info->xmit); | ||
540 | spin_unlock_irqrestore(&state->port->lock, flags); | ||
541 | return ret; | ||
537 | } | 542 | } |
538 | 543 | ||
539 | static int uart_chars_in_buffer(struct tty_struct *tty) | 544 | static int uart_chars_in_buffer(struct tty_struct *tty) |
540 | { | 545 | { |
541 | struct uart_state *state = tty->driver_data; | 546 | struct uart_state *state = tty->driver_data; |
547 | unsigned long flags; | ||
548 | int ret; | ||
542 | 549 | ||
543 | return uart_circ_chars_pending(&state->info->xmit); | 550 | spin_lock_irqsave(&state->port->lock, flags); |
551 | ret = uart_circ_chars_pending(&state->info->xmit); | ||
552 | spin_unlock_irqrestore(&state->port->lock, flags); | ||
553 | return ret; | ||
544 | } | 554 | } |
545 | 555 | ||
546 | static void uart_flush_buffer(struct tty_struct *tty) | 556 | static void uart_flush_buffer(struct tty_struct *tty) |
@@ -622,6 +632,11 @@ static int uart_get_info(struct uart_state *state, | |||
622 | struct serial_struct tmp; | 632 | struct serial_struct tmp; |
623 | 633 | ||
624 | memset(&tmp, 0, sizeof(tmp)); | 634 | memset(&tmp, 0, sizeof(tmp)); |
635 | |||
636 | /* Ensure the state we copy is consistent and no hardware changes | ||
637 | occur as we go */ | ||
638 | mutex_lock(&state->mutex); | ||
639 | |||
625 | tmp.type = port->type; | 640 | tmp.type = port->type; |
626 | tmp.line = port->line; | 641 | tmp.line = port->line; |
627 | tmp.port = port->iobase; | 642 | tmp.port = port->iobase; |
@@ -641,6 +656,8 @@ static int uart_get_info(struct uart_state *state, | |||
641 | tmp.iomem_reg_shift = port->regshift; | 656 | tmp.iomem_reg_shift = port->regshift; |
642 | tmp.iomem_base = (void *)(unsigned long)port->mapbase; | 657 | tmp.iomem_base = (void *)(unsigned long)port->mapbase; |
643 | 658 | ||
659 | mutex_unlock(&state->mutex); | ||
660 | |||
644 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) | 661 | if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) |
645 | return -EFAULT; | 662 | return -EFAULT; |
646 | return 0; | 663 | return 0; |
@@ -918,14 +935,12 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state) | |||
918 | struct uart_state *state = tty->driver_data; | 935 | struct uart_state *state = tty->driver_data; |
919 | struct uart_port *port = state->port; | 936 | struct uart_port *port = state->port; |
920 | 937 | ||
921 | lock_kernel(); | ||
922 | mutex_lock(&state->mutex); | 938 | mutex_lock(&state->mutex); |
923 | 939 | ||
924 | if (port->type != PORT_UNKNOWN) | 940 | if (port->type != PORT_UNKNOWN) |
925 | port->ops->break_ctl(port, break_state); | 941 | port->ops->break_ctl(port, break_state); |
926 | 942 | ||
927 | mutex_unlock(&state->mutex); | 943 | mutex_unlock(&state->mutex); |
928 | unlock_kernel(); | ||
929 | } | 944 | } |
930 | 945 | ||
931 | static int uart_do_autoconfig(struct uart_state *state) | 946 | static int uart_do_autoconfig(struct uart_state *state) |
@@ -1074,7 +1089,6 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, | |||
1074 | int ret = -ENOIOCTLCMD; | 1089 | int ret = -ENOIOCTLCMD; |
1075 | 1090 | ||
1076 | 1091 | ||
1077 | lock_kernel(); | ||
1078 | /* | 1092 | /* |
1079 | * These ioctls don't rely on the hardware to be present. | 1093 | * These ioctls don't rely on the hardware to be present. |
1080 | */ | 1094 | */ |
@@ -1144,10 +1158,9 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, | |||
1144 | break; | 1158 | break; |
1145 | } | 1159 | } |
1146 | } | 1160 | } |
1147 | out_up: | 1161 | out_up: |
1148 | mutex_unlock(&state->mutex); | 1162 | mutex_unlock(&state->mutex); |
1149 | out: | 1163 | out: |
1150 | unlock_kernel(); | ||
1151 | return ret; | 1164 | return ret; |
1152 | } | 1165 | } |
1153 | 1166 | ||
@@ -1173,7 +1186,6 @@ static void uart_set_termios(struct tty_struct *tty, | |||
1173 | return; | 1186 | return; |
1174 | } | 1187 | } |
1175 | 1188 | ||
1176 | lock_kernel(); | ||
1177 | uart_change_speed(state, old_termios); | 1189 | uart_change_speed(state, old_termios); |
1178 | 1190 | ||
1179 | /* Handle transition to B0 status */ | 1191 | /* Handle transition to B0 status */ |
@@ -1206,7 +1218,6 @@ static void uart_set_termios(struct tty_struct *tty, | |||
1206 | } | 1218 | } |
1207 | spin_unlock_irqrestore(&state->port->lock, flags); | 1219 | spin_unlock_irqrestore(&state->port->lock, flags); |
1208 | } | 1220 | } |
1209 | unlock_kernel(); | ||
1210 | #if 0 | 1221 | #if 0 |
1211 | /* | 1222 | /* |
1212 | * No need to wake up processes in open wait, since they | 1223 | * No need to wake up processes in open wait, since they |
@@ -1322,11 +1333,11 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1322 | struct uart_port *port = state->port; | 1333 | struct uart_port *port = state->port; |
1323 | unsigned long char_time, expire; | 1334 | unsigned long char_time, expire; |
1324 | 1335 | ||
1325 | BUG_ON(!kernel_locked()); | ||
1326 | |||
1327 | if (port->type == PORT_UNKNOWN || port->fifosize == 0) | 1336 | if (port->type == PORT_UNKNOWN || port->fifosize == 0) |
1328 | return; | 1337 | return; |
1329 | 1338 | ||
1339 | lock_kernel(); | ||
1340 | |||
1330 | /* | 1341 | /* |
1331 | * Set the check interval to be 1/5 of the estimated time to | 1342 | * Set the check interval to be 1/5 of the estimated time to |
1332 | * send a single character, and make it at least 1. The check | 1343 | * send a single character, and make it at least 1. The check |
@@ -1372,6 +1383,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1372 | break; | 1383 | break; |
1373 | } | 1384 | } |
1374 | set_current_state(TASK_RUNNING); /* might not be needed */ | 1385 | set_current_state(TASK_RUNNING); /* might not be needed */ |
1386 | unlock_kernel(); | ||
1375 | } | 1387 | } |
1376 | 1388 | ||
1377 | /* | 1389 | /* |
@@ -2085,7 +2097,9 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port) | |||
2085 | int ret; | 2097 | int ret; |
2086 | 2098 | ||
2087 | uart_change_pm(state, 0); | 2099 | uart_change_pm(state, 0); |
2100 | spin_lock_irq(&port->lock); | ||
2088 | ops->set_mctrl(port, 0); | 2101 | ops->set_mctrl(port, 0); |
2102 | spin_unlock_irq(&port->lock); | ||
2089 | ret = ops->startup(port); | 2103 | ret = ops->startup(port); |
2090 | if (ret == 0) { | 2104 | if (ret == 0) { |
2091 | uart_change_speed(state, NULL); | 2105 | uart_change_speed(state, NULL); |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index d17d1645714f..04a56f300ea6 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -1421,8 +1421,7 @@ static void digi_close(struct usb_serial_port *port, struct file *filp) | |||
1421 | tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT); | 1421 | tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT); |
1422 | 1422 | ||
1423 | /* flush driver and line discipline buffers */ | 1423 | /* flush driver and line discipline buffers */ |
1424 | if (tty->driver->flush_buffer) | 1424 | tty_driver_flush_buffer(tty); |
1425 | tty->driver->flush_buffer(tty); | ||
1426 | tty_ldisc_flush(tty); | 1425 | tty_ldisc_flush(tty); |
1427 | 1426 | ||
1428 | if (port->serial->dev) { | 1427 | if (port->serial->dev) { |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index a9934a3f9845..0cb0d77dc429 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -296,16 +296,14 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int | |||
296 | struct usb_serial_port *port = tty->driver_data; | 296 | struct usb_serial_port *port = tty->driver_data; |
297 | int retval = -ENODEV; | 297 | int retval = -ENODEV; |
298 | 298 | ||
299 | if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) | 299 | if (port->serial->dev->state == USB_STATE_NOTATTACHED) |
300 | goto exit; | 300 | goto exit; |
301 | 301 | ||
302 | dbg("%s - port %d, %d byte(s)", __func__, port->number, count); | 302 | dbg("%s - port %d, %d byte(s)", __func__, port->number, count); |
303 | 303 | ||
304 | if (!port->open_count) { | 304 | /* open_count is managed under the mutex lock for the tty so cannot |
305 | retval = -EINVAL; | 305 | drop to zero until after the last close completes */ |
306 | dbg("%s - port not opened", __func__); | 306 | WARN_ON(!port->open_count); |
307 | goto exit; | ||
308 | } | ||
309 | 307 | ||
310 | /* pass on to the driver specific version of this function */ | 308 | /* pass on to the driver specific version of this function */ |
311 | retval = port->serial->type->write(port, buf, count); | 309 | retval = port->serial->type->write(port, buf, count); |
@@ -317,61 +315,28 @@ exit: | |||
317 | static int serial_write_room (struct tty_struct *tty) | 315 | static int serial_write_room (struct tty_struct *tty) |
318 | { | 316 | { |
319 | struct usb_serial_port *port = tty->driver_data; | 317 | struct usb_serial_port *port = tty->driver_data; |
320 | int retval = -ENODEV; | ||
321 | |||
322 | if (!port) | ||
323 | goto exit; | ||
324 | |||
325 | dbg("%s - port %d", __func__, port->number); | 318 | dbg("%s - port %d", __func__, port->number); |
326 | 319 | WARN_ON(!port->open_count); | |
327 | if (!port->open_count) { | ||
328 | dbg("%s - port not open", __func__); | ||
329 | goto exit; | ||
330 | } | ||
331 | |||
332 | /* pass on to the driver specific version of this function */ | 320 | /* pass on to the driver specific version of this function */ |
333 | retval = port->serial->type->write_room(port); | 321 | return port->serial->type->write_room(port); |
334 | |||
335 | exit: | ||
336 | return retval; | ||
337 | } | 322 | } |
338 | 323 | ||
339 | static int serial_chars_in_buffer (struct tty_struct *tty) | 324 | static int serial_chars_in_buffer (struct tty_struct *tty) |
340 | { | 325 | { |
341 | struct usb_serial_port *port = tty->driver_data; | 326 | struct usb_serial_port *port = tty->driver_data; |
342 | int retval = -ENODEV; | ||
343 | |||
344 | if (!port) | ||
345 | goto exit; | ||
346 | |||
347 | dbg("%s = port %d", __func__, port->number); | 327 | dbg("%s = port %d", __func__, port->number); |
348 | 328 | ||
349 | if (!port->open_count) { | 329 | WARN_ON(!port->open_count); |
350 | dbg("%s - port not open", __func__); | ||
351 | goto exit; | ||
352 | } | ||
353 | |||
354 | /* pass on to the driver specific version of this function */ | 330 | /* pass on to the driver specific version of this function */ |
355 | retval = port->serial->type->chars_in_buffer(port); | 331 | return port->serial->type->chars_in_buffer(port); |
356 | |||
357 | exit: | ||
358 | return retval; | ||
359 | } | 332 | } |
360 | 333 | ||
361 | static void serial_throttle (struct tty_struct * tty) | 334 | static void serial_throttle (struct tty_struct * tty) |
362 | { | 335 | { |
363 | struct usb_serial_port *port = tty->driver_data; | 336 | struct usb_serial_port *port = tty->driver_data; |
364 | |||
365 | if (!port) | ||
366 | return; | ||
367 | |||
368 | dbg("%s - port %d", __func__, port->number); | 337 | dbg("%s - port %d", __func__, port->number); |
369 | 338 | ||
370 | if (!port->open_count) { | 339 | WARN_ON(!port->open_count); |
371 | dbg ("%s - port not open", __func__); | ||
372 | return; | ||
373 | } | ||
374 | |||
375 | /* pass on to the driver specific version of this function */ | 340 | /* pass on to the driver specific version of this function */ |
376 | if (port->serial->type->throttle) | 341 | if (port->serial->type->throttle) |
377 | port->serial->type->throttle(port); | 342 | port->serial->type->throttle(port); |
@@ -380,17 +345,9 @@ static void serial_throttle (struct tty_struct * tty) | |||
380 | static void serial_unthrottle (struct tty_struct * tty) | 345 | static void serial_unthrottle (struct tty_struct * tty) |
381 | { | 346 | { |
382 | struct usb_serial_port *port = tty->driver_data; | 347 | struct usb_serial_port *port = tty->driver_data; |
383 | |||
384 | if (!port) | ||
385 | return; | ||
386 | |||
387 | dbg("%s - port %d", __func__, port->number); | 348 | dbg("%s - port %d", __func__, port->number); |
388 | 349 | ||
389 | if (!port->open_count) { | 350 | WARN_ON(!port->open_count); |
390 | dbg("%s - port not open", __func__); | ||
391 | return; | ||
392 | } | ||
393 | |||
394 | /* pass on to the driver specific version of this function */ | 351 | /* pass on to the driver specific version of this function */ |
395 | if (port->serial->type->unthrottle) | 352 | if (port->serial->type->unthrottle) |
396 | port->serial->type->unthrottle(port); | 353 | port->serial->type->unthrottle(port); |
@@ -401,42 +358,27 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in | |||
401 | struct usb_serial_port *port = tty->driver_data; | 358 | struct usb_serial_port *port = tty->driver_data; |
402 | int retval = -ENODEV; | 359 | int retval = -ENODEV; |
403 | 360 | ||
404 | lock_kernel(); | ||
405 | if (!port) | ||
406 | goto exit; | ||
407 | |||
408 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); | 361 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); |
409 | 362 | ||
410 | /* Caution - port->open_count is BKL protected */ | 363 | WARN_ON(!port->open_count); |
411 | if (!port->open_count) { | ||
412 | dbg ("%s - port not open", __func__); | ||
413 | goto exit; | ||
414 | } | ||
415 | 364 | ||
416 | /* pass on to the driver specific version of this function if it is available */ | 365 | /* pass on to the driver specific version of this function if it is available */ |
417 | if (port->serial->type->ioctl) | 366 | if (port->serial->type->ioctl) { |
367 | lock_kernel(); | ||
418 | retval = port->serial->type->ioctl(port, file, cmd, arg); | 368 | retval = port->serial->type->ioctl(port, file, cmd, arg); |
369 | unlock_kernel(); | ||
370 | } | ||
419 | else | 371 | else |
420 | retval = -ENOIOCTLCMD; | 372 | retval = -ENOIOCTLCMD; |
421 | exit: | ||
422 | unlock_kernel(); | ||
423 | return retval; | 373 | return retval; |
424 | } | 374 | } |
425 | 375 | ||
426 | static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) | 376 | static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) |
427 | { | 377 | { |
428 | struct usb_serial_port *port = tty->driver_data; | 378 | struct usb_serial_port *port = tty->driver_data; |
429 | |||
430 | if (!port) | ||
431 | return; | ||
432 | |||
433 | dbg("%s - port %d", __func__, port->number); | 379 | dbg("%s - port %d", __func__, port->number); |
434 | 380 | ||
435 | if (!port->open_count) { | 381 | WARN_ON(!port->open_count); |
436 | dbg("%s - port not open", __func__); | ||
437 | return; | ||
438 | } | ||
439 | |||
440 | /* pass on to the driver specific version of this function if it is available */ | 382 | /* pass on to the driver specific version of this function if it is available */ |
441 | if (port->serial->type->set_termios) | 383 | if (port->serial->type->set_termios) |
442 | port->serial->type->set_termios(port, old); | 384 | port->serial->type->set_termios(port, old); |
@@ -448,24 +390,15 @@ static void serial_break (struct tty_struct *tty, int break_state) | |||
448 | { | 390 | { |
449 | struct usb_serial_port *port = tty->driver_data; | 391 | struct usb_serial_port *port = tty->driver_data; |
450 | 392 | ||
451 | lock_kernel(); | ||
452 | if (!port) { | ||
453 | unlock_kernel(); | ||
454 | return; | ||
455 | } | ||
456 | |||
457 | dbg("%s - port %d", __func__, port->number); | 393 | dbg("%s - port %d", __func__, port->number); |
458 | 394 | ||
459 | if (!port->open_count) { | 395 | WARN_ON(!port->open_count); |
460 | dbg("%s - port not open", __func__); | ||
461 | unlock_kernel(); | ||
462 | return; | ||
463 | } | ||
464 | |||
465 | /* pass on to the driver specific version of this function if it is available */ | 396 | /* pass on to the driver specific version of this function if it is available */ |
466 | if (port->serial->type->break_ctl) | 397 | if (port->serial->type->break_ctl) { |
398 | lock_kernel(); | ||
467 | port->serial->type->break_ctl(port, break_state); | 399 | port->serial->type->break_ctl(port, break_state); |
468 | unlock_kernel(); | 400 | unlock_kernel(); |
401 | } | ||
469 | } | 402 | } |
470 | 403 | ||
471 | static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) | 404 | static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) |
@@ -519,19 +452,11 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) | |||
519 | { | 452 | { |
520 | struct usb_serial_port *port = tty->driver_data; | 453 | struct usb_serial_port *port = tty->driver_data; |
521 | 454 | ||
522 | if (!port) | ||
523 | return -ENODEV; | ||
524 | |||
525 | dbg("%s - port %d", __func__, port->number); | 455 | dbg("%s - port %d", __func__, port->number); |
526 | 456 | ||
527 | if (!port->open_count) { | 457 | WARN_ON(!port->open_count); |
528 | dbg("%s - port not open", __func__); | ||
529 | return -ENODEV; | ||
530 | } | ||
531 | |||
532 | if (port->serial->type->tiocmget) | 458 | if (port->serial->type->tiocmget) |
533 | return port->serial->type->tiocmget(port, file); | 459 | return port->serial->type->tiocmget(port, file); |
534 | |||
535 | return -EINVAL; | 460 | return -EINVAL; |
536 | } | 461 | } |
537 | 462 | ||
@@ -540,19 +465,11 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, | |||
540 | { | 465 | { |
541 | struct usb_serial_port *port = tty->driver_data; | 466 | struct usb_serial_port *port = tty->driver_data; |
542 | 467 | ||
543 | if (!port) | ||
544 | return -ENODEV; | ||
545 | |||
546 | dbg("%s - port %d", __func__, port->number); | 468 | dbg("%s - port %d", __func__, port->number); |
547 | 469 | ||
548 | if (!port->open_count) { | 470 | WARN_ON(!port->open_count); |
549 | dbg("%s - port not open", __func__); | ||
550 | return -ENODEV; | ||
551 | } | ||
552 | |||
553 | if (port->serial->type->tiocmset) | 471 | if (port->serial->type->tiocmset) |
554 | return port->serial->type->tiocmset(port, file, set, clear); | 472 | return port->serial->type->tiocmset(port, file, set, clear); |
555 | |||
556 | return -EINVAL; | 473 | return -EINVAL; |
557 | } | 474 | } |
558 | 475 | ||
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index e96bf8663ffc..f07e8a4c1f3d 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -673,15 +673,13 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) | |||
673 | } | 673 | } |
674 | */ | 674 | */ |
675 | 675 | ||
676 | if (port->tty->driver->flush_buffer) | 676 | tty_driver_flush_buffer(port->tty); |
677 | port->tty->driver->flush_buffer(port->tty); | ||
678 | tty_ldisc_flush(port->tty); | 677 | tty_ldisc_flush(port->tty); |
679 | 678 | ||
680 | firm_report_tx_done(port); | 679 | firm_report_tx_done(port); |
681 | 680 | ||
682 | firm_close(port); | 681 | firm_close(port); |
683 | 682 | ||
684 | printk(KERN_ERR"Before processing rx_urbs_submitted.\n"); | ||
685 | /* shutdown our bulk reads and writes */ | 683 | /* shutdown our bulk reads and writes */ |
686 | mutex_lock(&info->deathwarrant); | 684 | mutex_lock(&info->deathwarrant); |
687 | spin_lock_irq(&info->lock); | 685 | spin_lock_irq(&info->lock); |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 9663e8776724..97dba0d92348 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -1053,7 +1053,7 @@ static int vt_check(struct file *file) | |||
1053 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | 1053 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) |
1054 | return -EINVAL; | 1054 | return -EINVAL; |
1055 | 1055 | ||
1056 | if (tty->driver->ioctl != vt_ioctl) | 1056 | if (tty->ops->ioctl != vt_ioctl) |
1057 | return -EINVAL; | 1057 | return -EINVAL; |
1058 | 1058 | ||
1059 | vc = (struct vc_data *)tty->driver_data; | 1059 | vc = (struct vc_data *)tty->driver_data; |
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c index ac26ccc25f42..21f490f5d65c 100644 --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c | |||
@@ -192,16 +192,14 @@ void proc_tty_register_driver(struct tty_driver *driver) | |||
192 | { | 192 | { |
193 | struct proc_dir_entry *ent; | 193 | struct proc_dir_entry *ent; |
194 | 194 | ||
195 | if ((!driver->read_proc && !driver->write_proc) || | 195 | if (!driver->ops->read_proc || !driver->driver_name || |
196 | !driver->driver_name || | ||
197 | driver->proc_entry) | 196 | driver->proc_entry) |
198 | return; | 197 | return; |
199 | 198 | ||
200 | ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); | 199 | ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); |
201 | if (!ent) | 200 | if (!ent) |
202 | return; | 201 | return; |
203 | ent->read_proc = driver->read_proc; | 202 | ent->read_proc = driver->ops->read_proc; |
204 | ent->write_proc = driver->write_proc; | ||
205 | ent->owner = driver->owner; | 203 | ent->owner = driver->owner; |
206 | ent->data = driver; | 204 | ent->data = driver; |
207 | 205 | ||
diff --git a/include/linux/tty.h b/include/linux/tty.h index 2699298b00ef..c36a76da2ae2 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -177,9 +177,13 @@ struct signal_struct; | |||
177 | * size each time the window is created or resized anyway. | 177 | * size each time the window is created or resized anyway. |
178 | * - TYT, 9/14/92 | 178 | * - TYT, 9/14/92 |
179 | */ | 179 | */ |
180 | |||
181 | struct tty_operations; | ||
182 | |||
180 | struct tty_struct { | 183 | struct tty_struct { |
181 | int magic; | 184 | int magic; |
182 | struct tty_driver *driver; | 185 | struct tty_driver *driver; |
186 | const struct tty_operations *ops; | ||
183 | int index; | 187 | int index; |
184 | struct tty_ldisc ldisc; | 188 | struct tty_ldisc ldisc; |
185 | struct mutex termios_mutex; | 189 | struct mutex termios_mutex; |
@@ -295,6 +299,10 @@ extern void tty_unregister_device(struct tty_driver *driver, unsigned index); | |||
295 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, | 299 | extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, |
296 | int buflen); | 300 | int buflen); |
297 | extern void tty_write_message(struct tty_struct *tty, char *msg); | 301 | extern void tty_write_message(struct tty_struct *tty, char *msg); |
302 | extern int tty_put_char(struct tty_struct *tty, unsigned char c); | ||
303 | extern int tty_chars_in_buffer(struct tty_struct *tty); | ||
304 | extern int tty_write_room(struct tty_struct *tty); | ||
305 | extern void tty_driver_flush_buffer(struct tty_struct *tty); | ||
298 | 306 | ||
299 | extern int is_current_pgrp_orphaned(void); | 307 | extern int is_current_pgrp_orphaned(void); |
300 | extern struct pid *tty_get_pgrp(struct tty_struct *tty); | 308 | extern struct pid *tty_get_pgrp(struct tty_struct *tty); |
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 21f69aca4505..f80d73b690f6 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
@@ -12,11 +12,15 @@ | |||
12 | * This routine is called when a particular tty device is opened. | 12 | * This routine is called when a particular tty device is opened. |
13 | * This routine is mandatory; if this routine is not filled in, | 13 | * This routine is mandatory; if this routine is not filled in, |
14 | * the attempted open will fail with ENODEV. | 14 | * the attempted open will fail with ENODEV. |
15 | * | ||
16 | * Required method. | ||
15 | * | 17 | * |
16 | * void (*close)(struct tty_struct * tty, struct file * filp); | 18 | * void (*close)(struct tty_struct * tty, struct file * filp); |
17 | * | 19 | * |
18 | * This routine is called when a particular tty device is closed. | 20 | * This routine is called when a particular tty device is closed. |
19 | * | 21 | * |
22 | * Required method. | ||
23 | * | ||
20 | * int (*write)(struct tty_struct * tty, | 24 | * int (*write)(struct tty_struct * tty, |
21 | * const unsigned char *buf, int count); | 25 | * const unsigned char *buf, int count); |
22 | * | 26 | * |
@@ -26,7 +30,9 @@ | |||
26 | * number of characters actually accepted for writing. This | 30 | * number of characters actually accepted for writing. This |
27 | * routine is mandatory. | 31 | * routine is mandatory. |
28 | * | 32 | * |
29 | * void (*put_char)(struct tty_struct *tty, unsigned char ch); | 33 | * Optional: Required for writable devices. |
34 | * | ||
35 | * int (*put_char)(struct tty_struct *tty, unsigned char ch); | ||
30 | * | 36 | * |
31 | * This routine is called by the kernel to write a single | 37 | * This routine is called by the kernel to write a single |
32 | * character to the tty device. If the kernel uses this routine, | 38 | * character to the tty device. If the kernel uses this routine, |
@@ -34,10 +40,18 @@ | |||
34 | * done stuffing characters into the driver. If there is no room | 40 | * done stuffing characters into the driver. If there is no room |
35 | * in the queue, the character is ignored. | 41 | * in the queue, the character is ignored. |
36 | * | 42 | * |
43 | * Optional: Kernel will use the write method if not provided. | ||
44 | * | ||
45 | * Note: Do not call this function directly, call tty_put_char | ||
46 | * | ||
37 | * void (*flush_chars)(struct tty_struct *tty); | 47 | * void (*flush_chars)(struct tty_struct *tty); |
38 | * | 48 | * |
39 | * This routine is called by the kernel after it has written a | 49 | * This routine is called by the kernel after it has written a |
40 | * series of characters to the tty device using put_char(). | 50 | * series of characters to the tty device using put_char(). |
51 | * | ||
52 | * Optional: | ||
53 | * | ||
54 | * Note: Do not call this function directly, call tty_driver_flush_chars | ||
41 | * | 55 | * |
42 | * int (*write_room)(struct tty_struct *tty); | 56 | * int (*write_room)(struct tty_struct *tty); |
43 | * | 57 | * |
@@ -45,6 +59,10 @@ | |||
45 | * will accept for queuing to be written. This number is subject | 59 | * will accept for queuing to be written. This number is subject |
46 | * to change as output buffers get emptied, or if the output flow | 60 | * to change as output buffers get emptied, or if the output flow |
47 | * control is acted. | 61 | * control is acted. |
62 | * | ||
63 | * Required if write method is provided else not needed. | ||
64 | * | ||
65 | * Note: Do not call this function directly, call tty_write_room | ||
48 | * | 66 | * |
49 | * int (*ioctl)(struct tty_struct *tty, struct file * file, | 67 | * int (*ioctl)(struct tty_struct *tty, struct file * file, |
50 | * unsigned int cmd, unsigned long arg); | 68 | * unsigned int cmd, unsigned long arg); |
@@ -53,22 +71,29 @@ | |||
53 | * device-specific ioctl's. If the ioctl number passed in cmd | 71 | * device-specific ioctl's. If the ioctl number passed in cmd |
54 | * is not recognized by the driver, it should return ENOIOCTLCMD. | 72 | * is not recognized by the driver, it should return ENOIOCTLCMD. |
55 | * | 73 | * |
74 | * Optional | ||
75 | * | ||
56 | * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, | 76 | * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, |
57 | * unsigned int cmd, unsigned long arg); | 77 | * unsigned int cmd, unsigned long arg); |
58 | * | 78 | * |
59 | * implement ioctl processing for 32 bit process on 64 bit system | 79 | * implement ioctl processing for 32 bit process on 64 bit system |
80 | * | ||
81 | * Optional | ||
60 | * | 82 | * |
61 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | 83 | * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); |
62 | * | 84 | * |
63 | * This routine allows the tty driver to be notified when | 85 | * This routine allows the tty driver to be notified when |
64 | * device's termios settings have changed. Note that a | 86 | * device's termios settings have changed. |
65 | * well-designed tty driver should be prepared to accept the case | 87 | * |
66 | * where old == NULL, and try to do something rational. | 88 | * Optional: Called under the termios lock |
89 | * | ||
67 | * | 90 | * |
68 | * void (*set_ldisc)(struct tty_struct *tty); | 91 | * void (*set_ldisc)(struct tty_struct *tty); |
69 | * | 92 | * |
70 | * This routine allows the tty driver to be notified when the | 93 | * This routine allows the tty driver to be notified when the |
71 | * device's termios settings have changed. | 94 | * device's termios settings have changed. |
95 | * | ||
96 | * Optional: Called under BKL (currently) | ||
72 | * | 97 | * |
73 | * void (*throttle)(struct tty_struct * tty); | 98 | * void (*throttle)(struct tty_struct * tty); |
74 | * | 99 | * |
@@ -86,17 +111,27 @@ | |||
86 | * | 111 | * |
87 | * This routine notifies the tty driver that it should stop | 112 | * This routine notifies the tty driver that it should stop |
88 | * outputting characters to the tty device. | 113 | * outputting characters to the tty device. |
114 | * | ||
115 | * Optional: | ||
116 | * | ||
117 | * Note: Call stop_tty not this method. | ||
89 | * | 118 | * |
90 | * void (*start)(struct tty_struct *tty); | 119 | * void (*start)(struct tty_struct *tty); |
91 | * | 120 | * |
92 | * This routine notifies the tty driver that it resume sending | 121 | * This routine notifies the tty driver that it resume sending |
93 | * characters to the tty device. | 122 | * characters to the tty device. |
123 | * | ||
124 | * Optional: | ||
125 | * | ||
126 | * Note: Call start_tty not this method. | ||
94 | * | 127 | * |
95 | * void (*hangup)(struct tty_struct *tty); | 128 | * void (*hangup)(struct tty_struct *tty); |
96 | * | 129 | * |
97 | * This routine notifies the tty driver that it should hangup the | 130 | * This routine notifies the tty driver that it should hangup the |
98 | * tty device. | 131 | * tty device. |
99 | * | 132 | * |
133 | * Required: | ||
134 | * | ||
100 | * void (*break_ctl)(struct tty_stuct *tty, int state); | 135 | * void (*break_ctl)(struct tty_stuct *tty, int state); |
101 | * | 136 | * |
102 | * This optional routine requests the tty driver to turn on or | 137 | * This optional routine requests the tty driver to turn on or |
@@ -106,18 +141,26 @@ | |||
106 | * | 141 | * |
107 | * If this routine is implemented, the high-level tty driver will | 142 | * If this routine is implemented, the high-level tty driver will |
108 | * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, | 143 | * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, |
109 | * TIOCCBRK. Otherwise, these ioctls will be passed down to the | 144 | * TIOCCBRK. |
110 | * driver to handle. | 145 | * |
146 | * Optional: Required for TCSBRK/BRKP/etc handling. | ||
111 | * | 147 | * |
112 | * void (*wait_until_sent)(struct tty_struct *tty, int timeout); | 148 | * void (*wait_until_sent)(struct tty_struct *tty, int timeout); |
113 | * | 149 | * |
114 | * This routine waits until the device has written out all of the | 150 | * This routine waits until the device has written out all of the |
115 | * characters in its transmitter FIFO. | 151 | * characters in its transmitter FIFO. |
116 | * | 152 | * |
153 | * Optional: If not provided the device is assumed to have no FIFO | ||
154 | * | ||
155 | * Note: Usually correct to call tty_wait_until_sent | ||
156 | * | ||
117 | * void (*send_xchar)(struct tty_struct *tty, char ch); | 157 | * void (*send_xchar)(struct tty_struct *tty, char ch); |
118 | * | 158 | * |
119 | * This routine is used to send a high-priority XON/XOFF | 159 | * This routine is used to send a high-priority XON/XOFF |
120 | * character to the device. | 160 | * character to the device. |
161 | * | ||
162 | * Optional: If not provided then the write method is called under | ||
163 | * the atomic write lock to keep it serialized with the ldisc. | ||
121 | */ | 164 | */ |
122 | 165 | ||
123 | #include <linux/fs.h> | 166 | #include <linux/fs.h> |
@@ -132,7 +175,7 @@ struct tty_operations { | |||
132 | void (*close)(struct tty_struct * tty, struct file * filp); | 175 | void (*close)(struct tty_struct * tty, struct file * filp); |
133 | int (*write)(struct tty_struct * tty, | 176 | int (*write)(struct tty_struct * tty, |
134 | const unsigned char *buf, int count); | 177 | const unsigned char *buf, int count); |
135 | void (*put_char)(struct tty_struct *tty, unsigned char ch); | 178 | int (*put_char)(struct tty_struct *tty, unsigned char ch); |
136 | void (*flush_chars)(struct tty_struct *tty); | 179 | void (*flush_chars)(struct tty_struct *tty); |
137 | int (*write_room)(struct tty_struct *tty); | 180 | int (*write_room)(struct tty_struct *tty); |
138 | int (*chars_in_buffer)(struct tty_struct *tty); | 181 | int (*chars_in_buffer)(struct tty_struct *tty); |
@@ -153,8 +196,6 @@ struct tty_operations { | |||
153 | void (*send_xchar)(struct tty_struct *tty, char ch); | 196 | void (*send_xchar)(struct tty_struct *tty, char ch); |
154 | int (*read_proc)(char *page, char **start, off_t off, | 197 | int (*read_proc)(char *page, char **start, off_t off, |
155 | int count, int *eof, void *data); | 198 | int count, int *eof, void *data); |
156 | int (*write_proc)(struct file *file, const char __user *buffer, | ||
157 | unsigned long count, void *data); | ||
158 | int (*tiocmget)(struct tty_struct *tty, struct file *file); | 199 | int (*tiocmget)(struct tty_struct *tty, struct file *file); |
159 | int (*tiocmset)(struct tty_struct *tty, struct file *file, | 200 | int (*tiocmset)(struct tty_struct *tty, struct file *file, |
160 | unsigned int set, unsigned int clear); | 201 | unsigned int set, unsigned int clear); |
@@ -190,48 +231,13 @@ struct tty_driver { | |||
190 | struct tty_struct **ttys; | 231 | struct tty_struct **ttys; |
191 | struct ktermios **termios; | 232 | struct ktermios **termios; |
192 | struct ktermios **termios_locked; | 233 | struct ktermios **termios_locked; |
193 | void *driver_state; /* only used for the PTY driver */ | 234 | void *driver_state; |
194 | 235 | ||
195 | /* | 236 | /* |
196 | * Interface routines from the upper tty layer to the tty | 237 | * Driver methods |
197 | * driver. Will be replaced with struct tty_operations. | ||
198 | */ | 238 | */ |
199 | int (*open)(struct tty_struct * tty, struct file * filp); | ||
200 | void (*close)(struct tty_struct * tty, struct file * filp); | ||
201 | int (*write)(struct tty_struct * tty, | ||
202 | const unsigned char *buf, int count); | ||
203 | void (*put_char)(struct tty_struct *tty, unsigned char ch); | ||
204 | void (*flush_chars)(struct tty_struct *tty); | ||
205 | int (*write_room)(struct tty_struct *tty); | ||
206 | int (*chars_in_buffer)(struct tty_struct *tty); | ||
207 | int (*ioctl)(struct tty_struct *tty, struct file * file, | ||
208 | unsigned int cmd, unsigned long arg); | ||
209 | long (*compat_ioctl)(struct tty_struct *tty, struct file * file, | ||
210 | unsigned int cmd, unsigned long arg); | ||
211 | void (*set_termios)(struct tty_struct *tty, struct ktermios * old); | ||
212 | void (*throttle)(struct tty_struct * tty); | ||
213 | void (*unthrottle)(struct tty_struct * tty); | ||
214 | void (*stop)(struct tty_struct *tty); | ||
215 | void (*start)(struct tty_struct *tty); | ||
216 | void (*hangup)(struct tty_struct *tty); | ||
217 | void (*break_ctl)(struct tty_struct *tty, int state); | ||
218 | void (*flush_buffer)(struct tty_struct *tty); | ||
219 | void (*set_ldisc)(struct tty_struct *tty); | ||
220 | void (*wait_until_sent)(struct tty_struct *tty, int timeout); | ||
221 | void (*send_xchar)(struct tty_struct *tty, char ch); | ||
222 | int (*read_proc)(char *page, char **start, off_t off, | ||
223 | int count, int *eof, void *data); | ||
224 | int (*write_proc)(struct file *file, const char __user *buffer, | ||
225 | unsigned long count, void *data); | ||
226 | int (*tiocmget)(struct tty_struct *tty, struct file *file); | ||
227 | int (*tiocmset)(struct tty_struct *tty, struct file *file, | ||
228 | unsigned int set, unsigned int clear); | ||
229 | #ifdef CONFIG_CONSOLE_POLL | ||
230 | int (*poll_init)(struct tty_driver *driver, int line, char *options); | ||
231 | int (*poll_get_char)(struct tty_driver *driver, int line); | ||
232 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); | ||
233 | #endif | ||
234 | 239 | ||
240 | const struct tty_operations *ops; | ||
235 | struct list_head tty_drivers; | 241 | struct list_head tty_drivers; |
236 | }; | 242 | }; |
237 | 243 | ||
diff --git a/kernel/printk.c b/kernel/printk.c index d3f9c0f788bf..0d232589a923 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -1272,8 +1272,8 @@ late_initcall(disable_boot_consoles); | |||
1272 | */ | 1272 | */ |
1273 | void tty_write_message(struct tty_struct *tty, char *msg) | 1273 | void tty_write_message(struct tty_struct *tty, char *msg) |
1274 | { | 1274 | { |
1275 | if (tty && tty->driver->write) | 1275 | if (tty && tty->ops->write) |
1276 | tty->driver->write(tty, msg, strlen(msg)); | 1276 | tty->ops->write(tty, msg, strlen(msg)); |
1277 | return; | 1277 | return; |
1278 | } | 1278 | } |
1279 | 1279 | ||
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index d2620410cb0a..76c3057d0179 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -555,10 +555,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) | |||
555 | 555 | ||
556 | ircomm_tty_shutdown(self); | 556 | ircomm_tty_shutdown(self); |
557 | 557 | ||
558 | if (tty->driver->flush_buffer) | 558 | tty_driver_flush_buffer(tty); |
559 | tty->driver->flush_buffer(tty); | 559 | tty_ldisc_flush(tty); |
560 | if (tty->ldisc.flush_buffer) | ||
561 | tty->ldisc.flush_buffer(tty); | ||
562 | 560 | ||
563 | tty->closing = 0; | 561 | tty->closing = 0; |
564 | self->tty = NULL; | 562 | self->tty = NULL; |