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 /drivers/net/hamradio | |
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>
Diffstat (limited to 'drivers/net/hamradio')
-rw-r--r-- | drivers/net/hamradio/6pack.c | 36 | ||||
-rw-r--r-- | drivers/net/hamradio/mkiss.c | 15 |
2 files changed, 27 insertions, 24 deletions
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 | ||