X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fppp_synctty.c;h=b6f0e9a25e26dada081eba2e45432b649da9f08f;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=a8f8908587a4cdaa7a55ae5faa8e7f5bf1c76746;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c index a8f890858..b6f0e9a25 100644 --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c @@ -6,7 +6,7 @@ * * Complete PPP frames without encoding/decoding are exchanged between * the channel driver and the device driver. - * + * * The async map IOCTL codes are implemented to keep the user mode * applications happy if they call them. Synchronous PPP does not use * the async maps. @@ -108,7 +108,7 @@ static void ppp_print_hex (register __u8 * out, const __u8 * in, int count) { register __u8 next_ch; - static char hex[] = "0123456789ABCDEF"; + static const char hex[] = "0123456789ABCDEF"; while (count-- > 0) { next_ch = *in++; @@ -175,8 +175,10 @@ ppp_print_buffer (const char *name, const __u8 *buf, int count) * frees the memory that ppp_synctty_receive is using. The best * way to fix this is to use a rwlock in the tty struct, but for now * we use a single global rwlock for all ttys in ppp line discipline. + * + * FIXME: Fixed in tty_io nowdays. */ -static rwlock_t disc_data_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(disc_data_lock); static struct syncppp *sp_get(struct tty_struct *tty) { @@ -235,7 +237,7 @@ ppp_sync_open(struct tty_struct *tty) goto out_free; tty->disc_data = ap; - + tty->receive_room = 65536; return 0; out_free: @@ -282,6 +284,18 @@ ppp_sync_close(struct tty_struct *tty) kfree(ap); } +/* + * Called on tty hangup in process context. + * + * Wait for I/O to driver to complete and unregister PPP channel. + * This is already done by the close routine, so just call that. + */ +static int ppp_sync_hangup(struct tty_struct *tty) +{ + ppp_sync_close(tty); + return 0; +} + /* * Read does nothing - no data is ever available this way. * Pppd reads and writes packets via /dev/ppp instead. @@ -299,7 +313,7 @@ ppp_sync_read(struct tty_struct *tty, struct file *file, */ static ssize_t ppp_sync_write(struct tty_struct *tty, struct file *file, - const unsigned char __user *buf, size_t count) + const unsigned char *buf, size_t count) { return -EAGAIN; } @@ -370,12 +384,6 @@ ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait) return 0; } -static int -ppp_sync_room(struct tty_struct *tty) -{ - return 65535; -} - /* * This can now be called from hard interrupt level as well * as soft interrupt level or mainline. @@ -392,7 +400,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, spin_lock_irqsave(&ap->recv_lock, flags); ppp_sync_input(ap, buf, cflags, count); spin_unlock_irqrestore(&ap->recv_lock, flags); - if (skb_queue_len(&ap->rqueue)) + if (!skb_queue_empty(&ap->rqueue)) tasklet_schedule(&ap->tsk); sp_put(ap); if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) @@ -420,11 +428,11 @@ static struct tty_ldisc ppp_sync_ldisc = { .name = "pppsync", .open = ppp_sync_open, .close = ppp_sync_close, + .hangup = ppp_sync_hangup, .read = ppp_sync_read, .write = ppp_sync_write, .ioctl = ppp_synctty_ioctl, .poll = ppp_sync_poll, - .receive_room = ppp_sync_room, .receive_buf = ppp_sync_receive, .write_wakeup = ppp_sync_wakeup, }; @@ -649,7 +657,7 @@ ppp_sync_push(struct syncppp *ap) tty_stuffed = 0; if (!tty_stuffed && ap->tpkt != 0) { set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); - sent = tty->driver->write(tty, 0, ap->tpkt->data, ap->tpkt->len); + sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); if (sent < 0) goto flush; /* error, e.g. loss of CD */ if (sent < ap->tpkt->len) { @@ -778,7 +786,7 @@ err: static void __exit ppp_sync_cleanup(void) { - if (tty_register_ldisc(N_SYNC_PPP, NULL) != 0) + if (tty_unregister_ldisc(N_SYNC_PPP) != 0) printk(KERN_ERR "failed to unregister Sync PPP line discipline\n"); }