X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fwan%2Fx25_asy.c;h=1c9edd97accd679a816a66aa6e2a8cbb422c6d30;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=4243fea5354d880986536807146e7639a44b99c0;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 4243fea53..1c9edd97a 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -34,10 +34,12 @@ #include #include "x25_asy.h" +#include + static struct net_device **x25_asy_devs; static int x25_asy_maxdev = SL_NRUNIT; -MODULE_PARM(x25_asy_maxdev, "i"); +module_param(x25_asy_maxdev, int, 0); MODULE_LICENSE("GPL"); static int x25_asy_esc(unsigned char *p, unsigned char *d, int len); @@ -105,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void) static void x25_asy_free(struct x25_asy *sl) { /* Free all X.25 frame buffers. */ - if (sl->rbuff) { - kfree(sl->rbuff); - } + kfree(sl->rbuff); sl->rbuff = NULL; - if (sl->xbuff) { - kfree(sl->xbuff); - } + kfree(sl->xbuff); sl->xbuff = NULL; if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { @@ -125,17 +123,15 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) unsigned char *xbuff, *rbuff; int len = 2* newmtu; - xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); - rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); + xbuff = kmalloc(len + 4, GFP_ATOMIC); + rbuff = kmalloc(len + 4, GFP_ATOMIC); if (xbuff == NULL || rbuff == NULL) { printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", dev->name); - if (xbuff != NULL) - kfree(xbuff); - if (rbuff != NULL) - kfree(rbuff); + kfree(xbuff); + kfree(rbuff); return -ENOMEM; } @@ -167,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) spin_unlock_bh(&sl->lock); - if (xbuff != NULL) - kfree(xbuff); - if (rbuff != NULL) - kfree(rbuff); + kfree(xbuff); + kfree(rbuff); return 0; } @@ -209,10 +203,8 @@ static void x25_asy_bump(struct x25_asy *sl) return; } skb_push(skb,1); /* LAPB internal control */ - skb->dev = sl->dev; memcpy(skb_put(skb,count), sl->rbuff, count); - skb->mac.raw=skb->data; - skb->protocol=htons(ETH_P_X25); + skb->protocol = x25_type_trans(skb, sl->dev); if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK) { kfree_skb(skb); @@ -253,7 +245,7 @@ static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len) * 14 Oct 1994 Dmitry Gorodchanin. */ sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); - actual = sl->tty->driver->write(sl->tty, 0, sl->xbuff, count); + actual = sl->tty->driver->write(sl->tty, sl->xbuff, count); sl->xleft = count - actual; sl->xhead = sl->xbuff + actual; /* VSV */ @@ -283,7 +275,7 @@ static void x25_asy_write_wakeup(struct tty_struct *tty) return; } - actual = tty->driver->write(tty, 0, sl->xhead, sl->xleft); + actual = tty->driver->write(tty, sl->xhead, sl->xleft); sl->xleft -= actual; sl->xhead += actual; } @@ -419,11 +411,7 @@ static void x25_asy_connected(struct net_device *dev, int reason) ptr = skb_put(skb, 1); *ptr = 0x01; - skb->dev = sl->dev; - skb->protocol = htons(ETH_P_X25); - skb->mac.raw = skb->data; - skb->pkt_type = PACKET_HOST; - + skb->protocol = x25_type_trans(skb, sl->dev); netif_rx(skb); sl->dev->last_rx = jiffies; } @@ -442,11 +430,7 @@ static void x25_asy_disconnected(struct net_device *dev, int reason) ptr = skb_put(skb, 1); *ptr = 0x02; - skb->dev = sl->dev; - skb->protocol = htons(ETH_P_X25); - skb->mac.raw = skb->data; - skb->pkt_type = PACKET_HOST; - + skb->protocol = x25_type_trans(skb, sl->dev); netif_rx(skb); sl->dev->last_rx = jiffies; } @@ -481,11 +465,11 @@ static int x25_asy_open(struct net_device *dev) len = dev->mtu * 2; - sl->rbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); + sl->rbuff = kmalloc(len + 4, GFP_KERNEL); if (sl->rbuff == NULL) { goto norbuff; } - sl->xbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); + sl->xbuff = kmalloc(len + 4, GFP_KERNEL); if (sl->xbuff == NULL) { goto noxbuff; } @@ -531,11 +515,6 @@ static int x25_asy_close(struct net_device *dev) return 0; } -static int x25_asy_receive_room(struct tty_struct *tty) -{ - return 65536; /* We can handle an infinite amount of data. :-) */ -} - /* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when @@ -589,6 +568,7 @@ static int x25_asy_open_tty(struct tty_struct *tty) sl->tty = tty; tty->disc_data = sl; + tty->receive_room = 65536; if (tty->driver->flush_buffer) { tty->driver->flush_buffer(tty); } @@ -627,7 +607,7 @@ static void x25_asy_close_tty(struct tty_struct *tty) (void) dev_close(sl->dev); } - tty->disc_data = 0; + tty->disc_data = NULL; sl->tty = NULL; x25_asy_free(sl); } @@ -733,7 +713,7 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, switch(cmd) { case SIOCGIFNAME: - if (copy_to_user((void *)arg, sl->dev->name, + if (copy_to_user((void __user *)arg, sl->dev->name, strlen(sl->dev->name) + 1)) return -EFAULT; return 0; @@ -795,7 +775,6 @@ static struct tty_ldisc x25_ldisc = { .close = x25_asy_close_tty, .ioctl = x25_asy_ioctl, .receive_buf = x25_asy_receive_buf, - .receive_room = x25_asy_receive_room, .write_wakeup = x25_asy_write_wakeup, }; @@ -845,7 +824,7 @@ static void __exit exit_x25_asy(void) } kfree(x25_asy_devs); - tty_register_ldisc(N_X25, NULL); + tty_unregister_ldisc(N_X25); } module_init(init_x25_asy);