Commit 9ce6cf25538de8036793a7e517674ede86e41f00

Authored by Alan Cox
Committed by David S. Miller
1 parent a35f5de776

slip: Drag kicking and screaming into coding style compliance

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

Showing 1 changed file with 178 additions and 189 deletions Side-by-side Diff

... ... @@ -11,9 +11,11 @@
11 11 * Fixes:
12 12 * Alan Cox : Sanity checks and avoid tx overruns.
13 13 * Has a new sl->mtu field.
14   - * Alan Cox : Found cause of overrun. ifconfig sl0 mtu upwards.
15   - * Driver now spots this and grows/shrinks its buffers(hack!).
16   - * Memory leak if you run out of memory setting up a slip driver fixed.
  14 + * Alan Cox : Found cause of overrun. ifconfig sl0
  15 + * mtu upwards. Driver now spots this
  16 + * and grows/shrinks its buffers(hack!).
  17 + * Memory leak if you run out of memory
  18 + * setting up a slip driver fixed.
17 19 * Matt Dillon : Printable slip (borrowed from NET2E)
18 20 * Pauline Middelink : Slip driver fixes.
19 21 * Alan Cox : Honours the old SL_COMPRESSED flag
... ... @@ -29,7 +31,8 @@
29 31 * buffering from 4096 to 256 bytes.
30 32 * Improving SLIP response time.
31 33 * CONFIG_SLIP_MODE_SLIP6.
32   - * ifconfig sl? up & down now works correctly.
  34 + * ifconfig sl? up & down now works
  35 + * correctly.
33 36 * Modularization.
34 37 * Alan Cox : Oops - fix AX.25 buffer lengths
35 38 * Dmitry Gorodchanin : Even more cleanups. Preserve CSLIP
36 39  
... ... @@ -43,15 +46,18 @@
43 46 * device entries, just reg./unreg. them
44 47 * as they are needed. We kfree() them
45 48 * at module cleanup.
46   - * With MODULE-loading ``insmod'', user can
47   - * issue parameter: slip_maxdev=1024
48   - * (Or how much he/she wants.. Default is 256)
49   - * * Stanislav Voronyi : Slip line checking, with ideas taken
50   - * from multislip BSDI driver which was written
51   - * by Igor Chechik, RELCOM Corp. Only algorithms
52   - * have been ported to Linux SLIP driver.
  49 + * With MODULE-loading ``insmod'', user
  50 + * can issue parameter: slip_maxdev=1024
  51 + * (Or how much he/she wants.. Default
  52 + * is 256)
  53 + * Stanislav Voronyi : Slip line checking, with ideas taken
  54 + * from multislip BSDI driver which was
  55 + * written by Igor Chechik, RELCOM Corp.
  56 + * Only algorithms have been ported to
  57 + * Linux SLIP driver.
53 58 * Vitaly E. Lavrov : Sane behaviour on tty hangup.
54   - * Alexey Kuznetsov : Cleanup interfaces to tty&netdevice modules.
  59 + * Alexey Kuznetsov : Cleanup interfaces to tty & netdevice
  60 + * modules.
55 61 */
56 62  
57 63 #define SL_CHECK_TRANSMIT
... ... @@ -99,7 +105,7 @@
99 105 #ifdef CONFIG_SLIP_SMART
100 106 static void sl_keepalive(unsigned long sls);
101 107 static void sl_outfill(unsigned long sls);
102   -static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd);
  108 +static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
103 109 #endif
104 110  
105 111 /********************************
106 112  
107 113  
... ... @@ -117,15 +123,14 @@
117 123 Allocate channel buffers.
118 124 */
119 125  
120   -static int
121   -sl_alloc_bufs(struct slip *sl, int mtu)
  126 +static int sl_alloc_bufs(struct slip *sl, int mtu)
122 127 {
123 128 int err = -ENOBUFS;
124 129 unsigned long len;
125   - char * rbuff = NULL;
126   - char * xbuff = NULL;
  130 + char *rbuff = NULL;
  131 + char *xbuff = NULL;
127 132 #ifdef SL_INCLUDE_CSLIP
128   - char * cbuff = NULL;
  133 + char *cbuff = NULL;
129 134 struct slcompress *slcomp = NULL;
130 135 #endif
131 136  
... ... @@ -195,8 +200,7 @@
195 200 }
196 201  
197 202 /* Free a SLIP channel buffers. */
198   -static void
199   -sl_free_bufs(struct slip *sl)
  203 +static void sl_free_bufs(struct slip *sl)
200 204 {
201 205 /* Free all SLIP frame buffers. */
202 206 kfree(xchg(&sl->rbuff, NULL));
... ... @@ -248,7 +252,6 @@
248 252 }
249 253 goto done;
250 254 }
251   -
252 255 spin_lock_bh(&sl->lock);
253 256  
254 257 err = -ENODEV;
255 258  
256 259  
... ... @@ -298,23 +301,20 @@
298 301  
299 302  
300 303 /* Set the "sending" flag. This must be atomic hence the set_bit. */
301   -static inline void
302   -sl_lock(struct slip *sl)
  304 +static inline void sl_lock(struct slip *sl)
303 305 {
304 306 netif_stop_queue(sl->dev);
305 307 }
306 308  
307 309  
308 310 /* Clear the "sending" flag. This must be atomic, hence the ASM. */
309   -static inline void
310   -sl_unlock(struct slip *sl)
  311 +static inline void sl_unlock(struct slip *sl)
311 312 {
312 313 netif_wake_queue(sl->dev);
313 314 }
314 315  
315 316 /* Send one completely decapsulated IP datagram to the IP layer. */
316   -static void
317   -sl_bump(struct slip *sl)
  317 +static void sl_bump(struct slip *sl)
318 318 {
319 319 struct sk_buff *skb;
320 320 int count;
321 321  
322 322  
323 323  
... ... @@ -322,22 +322,22 @@
322 322 count = sl->rcount;
323 323 #ifdef SL_INCLUDE_CSLIP
324 324 if (sl->mode & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
325   - unsigned char c;
326   - if ((c = sl->rbuff[0]) & SL_TYPE_COMPRESSED_TCP) {
  325 + unsigned char c = sl->rbuff[0];
  326 + if (c & SL_TYPE_COMPRESSED_TCP) {
327 327 /* ignore compressed packets when CSLIP is off */
328 328 if (!(sl->mode & SL_MODE_CSLIP)) {
329 329 printk(KERN_WARNING "%s: compressed packet ignored\n", sl->dev->name);
330 330 return;
331 331 }
332   - /* make sure we've reserved enough space for uncompress to use */
  332 + /* make sure we've reserved enough space for uncompress
  333 + to use */
333 334 if (count + 80 > sl->buffsize) {
334 335 sl->rx_over_errors++;
335 336 return;
336 337 }
337 338 count = slhc_uncompress(sl->slcomp, sl->rbuff, count);
338   - if (count <= 0) {
  339 + if (count <= 0)
339 340 return;
340   - }
341 341 } else if (c >= SL_TYPE_UNCOMPRESSED_TCP) {
342 342 if (!(sl->mode & SL_MODE_CSLIP)) {
343 343 /* turn on header compression */
344 344  
345 345  
346 346  
347 347  
348 348  
349 349  
... ... @@ -346,33 +346,31 @@
346 346 printk(KERN_INFO "%s: header compression turned on\n", sl->dev->name);
347 347 }
348 348 sl->rbuff[0] &= 0x4f;
349   - if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0) {
  349 + if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0)
350 350 return;
351   - }
352 351 }
353 352 }
354 353 #endif /* SL_INCLUDE_CSLIP */
355 354  
356   - sl->rx_bytes+=count;
  355 + sl->rx_bytes += count;
357 356  
358 357 skb = dev_alloc_skb(count);
359   - if (skb == NULL) {
  358 + if (skb == NULL) {
360 359 printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", sl->dev->name);
361 360 sl->rx_dropped++;
362 361 return;
363 362 }
364 363 skb->dev = sl->dev;
365   - memcpy(skb_put(skb,count), sl->rbuff, count);
  364 + memcpy(skb_put(skb, count), sl->rbuff, count);
366 365 skb_reset_mac_header(skb);
367   - skb->protocol=htons(ETH_P_IP);
  366 + skb->protocol = htons(ETH_P_IP);
368 367 netif_rx(skb);
369 368 sl->dev->last_rx = jiffies;
370 369 sl->rx_packets++;
371 370 }
372 371  
373 372 /* Encapsulate one IP datagram and stuff into a TTY queue. */
374   -static void
375   -sl_encaps(struct slip *sl, unsigned char *icp, int len)
  373 +static void sl_encaps(struct slip *sl, unsigned char *icp, int len)
376 374 {
377 375 unsigned char *p;
378 376 int actual, count;
379 377  
380 378  
... ... @@ -386,12 +384,11 @@
386 384  
387 385 p = icp;
388 386 #ifdef SL_INCLUDE_CSLIP
389   - if (sl->mode & SL_MODE_CSLIP) {
  387 + if (sl->mode & SL_MODE_CSLIP)
390 388 len = slhc_compress(sl->slcomp, p, len, sl->cbuff, &p, 1);
391   - }
392 389 #endif
393 390 #ifdef CONFIG_SLIP_MODE_SLIP6
394   - if(sl->mode & SL_MODE_SLIP6)
  391 + if (sl->mode & SL_MODE_SLIP6)
395 392 count = slip_esc6(p, (unsigned char *) sl->xbuff, len);
396 393 else
397 394 #endif
398 395  
399 396  
... ... @@ -425,12 +422,12 @@
425 422 static void slip_write_wakeup(struct tty_struct *tty)
426 423 {
427 424 int actual;
428   - struct slip *sl = (struct slip *) tty->disc_data;
  425 + struct slip *sl = tty->disc_data;
429 426  
430 427 /* First make sure we're connected. */
431   - if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
  428 + if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
432 429 return;
433   - }
  430 +
434 431 if (sl->xleft <= 0) {
435 432 /* Now serial buffer is almost free & we can start
436 433 * transmission of another packet */
437 434  
... ... @@ -463,15 +460,15 @@
463 460 /* 20 sec timeout not reached */
464 461 goto out;
465 462 }
466   - printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
467   - (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
468   - "bad line quality" : "driver error");
  463 + printk(KERN_WARNING "%s: transmit timed out, %s?\n",
  464 + dev->name,
  465 + (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ?
  466 + "bad line quality" : "driver error");
469 467 sl->xleft = 0;
470 468 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
471 469 sl_unlock(sl);
472 470 #endif
473 471 }
474   -
475 472 out:
476 473 spin_unlock(&sl->lock);
477 474 }
... ... @@ -484,7 +481,7 @@
484 481 struct slip *sl = netdev_priv(dev);
485 482  
486 483 spin_lock(&sl->lock);
487   - if (!netif_running(dev)) {
  484 + if (!netif_running(dev)) {
488 485 spin_unlock(&sl->lock);
489 486 printk(KERN_WARNING "%s: xmit call when iface is down\n", dev->name);
490 487 dev_kfree_skb(skb);
... ... @@ -497,7 +494,7 @@
497 494 }
498 495  
499 496 sl_lock(sl);
500   - sl->tx_bytes+=skb->len;
  497 + sl->tx_bytes += skb->len;
501 498 sl_encaps(sl, skb->data, skb->len);
502 499 spin_unlock(&sl->lock);
503 500  
... ... @@ -536,7 +533,7 @@
536 533 {
537 534 struct slip *sl = netdev_priv(dev);
538 535  
539   - if (sl->tty==NULL)
  536 + if (sl->tty == NULL)
540 537 return -ENODEV;
541 538  
542 539 sl->flags &= (1 << SLF_INUSE);
543 540  
544 541  
545 542  
546 543  
... ... @@ -657,20 +654,19 @@
657 654 * in parallel
658 655 */
659 656  
660   -static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
  657 +static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
  658 + char *fp, int count)
661 659 {
662   - struct slip *sl = (struct slip *) tty->disc_data;
  660 + struct slip *sl = tty->disc_data;
663 661  
664   - if (!sl || sl->magic != SLIP_MAGIC ||
665   - !netif_running(sl->dev))
  662 + if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
666 663 return;
667 664  
668 665 /* Read the characters out of the buffer */
669 666 while (count--) {
670 667 if (fp && *fp++) {
671   - if (!test_and_set_bit(SLF_ERROR, &sl->flags)) {
  668 + if (!test_and_set_bit(SLF_ERROR, &sl->flags))
672 669 sl->rx_errors++;
673   - }
674 670 cp++;
675 671 continue;
676 672 }
... ... @@ -688,7 +684,6 @@
688 684 ************************************/
689 685  
690 686 /* Collect hanged up channels */
691   -
692 687 static void sl_sync(void)
693 688 {
694 689 int i;
695 690  
696 691  
... ... @@ -696,21 +691,21 @@
696 691 struct slip *sl;
697 692  
698 693 for (i = 0; i < slip_maxdev; i++) {
699   - if ((dev = slip_devs[i]) == NULL)
  694 + dev = slip_devs[i];
  695 + if (dev == NULL)
700 696 break;
701 697  
702 698 sl = netdev_priv(dev);
703 699 if (sl->tty || sl->leased)
704 700 continue;
705   - if (dev->flags&IFF_UP)
  701 + if (dev->flags & IFF_UP)
706 702 dev_close(dev);
707 703 }
708 704 }
709 705  
710 706  
711 707 /* Find a free SLIP channel, and link in this `tty' line. */
712   -static struct slip *
713   -sl_alloc(dev_t line)
  708 +static struct slip *sl_alloc(dev_t line)
714 709 {
715 710 int i;
716 711 int sel = -1;
717 712  
718 713  
... ... @@ -805,15 +800,15 @@
805 800 spin_lock_init(&sl->lock);
806 801 sl->mode = SL_MODE_DEFAULT;
807 802 #ifdef CONFIG_SLIP_SMART
808   - init_timer(&sl->keepalive_timer); /* initialize timer_list struct */
809   - sl->keepalive_timer.data=(unsigned long)sl;
810   - sl->keepalive_timer.function=sl_keepalive;
  803 + /* initialize timer_list struct */
  804 + init_timer(&sl->keepalive_timer);
  805 + sl->keepalive_timer.data = (unsigned long)sl;
  806 + sl->keepalive_timer.function = sl_keepalive;
811 807 init_timer(&sl->outfill_timer);
812   - sl->outfill_timer.data=(unsigned long)sl;
813   - sl->outfill_timer.function=sl_outfill;
  808 + sl->outfill_timer.data = (unsigned long)sl;
  809 + sl->outfill_timer.function = sl_outfill;
814 810 #endif
815 811 slip_devs[i] = dev;
816   -
817 812 return sl;
818 813 }
819 814  
... ... @@ -832,7 +827,7 @@
832 827 struct slip *sl;
833 828 int err;
834 829  
835   - if(!capable(CAP_NET_ADMIN))
  830 + if (!capable(CAP_NET_ADMIN))
836 831 return -EPERM;
837 832  
838 833 /* RTnetlink lock is misused here to serialize concurrent
... ... @@ -844,7 +839,7 @@
844 839 /* Collect hanged up channels. */
845 840 sl_sync();
846 841  
847   - sl = (struct slip *) tty->disc_data;
  842 + sl = tty->disc_data;
848 843  
849 844 err = -EEXIST;
850 845 /* First make sure we're not already connected. */
... ... @@ -853,7 +848,8 @@
853 848  
854 849 /* OK. Find a free SLIP channel to use. */
855 850 err = -ENFILE;
856   - if ((sl = sl_alloc(tty_devnum(tty))) == NULL)
  851 + sl = sl_alloc(tty_devnum(tty));
  852 + if (sl == NULL)
857 853 goto err_exit;
858 854  
859 855 sl->tty = tty;
860 856  
861 857  
862 858  
... ... @@ -863,23 +859,25 @@
863 859  
864 860 if (!test_bit(SLF_INUSE, &sl->flags)) {
865 861 /* Perform the low-level SLIP initialization. */
866   - if ((err = sl_alloc_bufs(sl, SL_MTU)) != 0)
  862 + err = sl_alloc_bufs(sl, SL_MTU);
  863 + if (err)
867 864 goto err_free_chan;
868 865  
869 866 set_bit(SLF_INUSE, &sl->flags);
870 867  
871   - if ((err = register_netdevice(sl->dev)))
  868 + err = register_netdevice(sl->dev);
  869 + if (err)
872 870 goto err_free_bufs;
873 871 }
874 872  
875 873 #ifdef CONFIG_SLIP_SMART
876 874 if (sl->keepalive) {
877   - sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
878   - add_timer (&sl->keepalive_timer);
  875 + sl->keepalive_timer.expires = jiffies + sl->keepalive * HZ;
  876 + add_timer(&sl->keepalive_timer);
879 877 }
880 878 if (sl->outfill) {
881   - sl->outfill_timer.expires=jiffies+sl->outfill*HZ;
882   - add_timer (&sl->outfill_timer);
  879 + sl->outfill_timer.expires = jiffies + sl->outfill * HZ;
  880 + add_timer(&sl->outfill_timer);
883 881 }
884 882 #endif
885 883  
886 884  
... ... @@ -928,10 +926,9 @@
928 926 * This means flushing out any pending queues, and then returning. This
929 927 * call is serialized against other ldisc functions.
930 928 */
931   -static void
932   -slip_close(struct tty_struct *tty)
  929 +static void slip_close(struct tty_struct *tty)
933 930 {
934   - struct slip *sl = (struct slip *) tty->disc_data;
  931 + struct slip *sl = tty->disc_data;
935 932  
936 933 /* First make sure we're connected. */
937 934 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty)
... ... @@ -955,8 +952,7 @@
955 952 * STANDARD SLIP ENCAPSULATION *
956 953 ************************************************************************/
957 954  
958   -static int
959   -slip_esc(unsigned char *s, unsigned char *d, int len)
  955 +static int slip_esc(unsigned char *s, unsigned char *d, int len)
960 956 {
961 957 unsigned char *ptr = d;
962 958 unsigned char c;
963 959  
964 960  
... ... @@ -975,16 +971,16 @@
975 971 */
976 972  
977 973 while (len-- > 0) {
978   - switch(c = *s++) {
979   - case END:
  974 + switch (c = *s++) {
  975 + case END:
980 976 *ptr++ = ESC;
981 977 *ptr++ = ESC_END;
982 978 break;
983   - case ESC:
  979 + case ESC:
984 980 *ptr++ = ESC;
985 981 *ptr++ = ESC_ESC;
986 982 break;
987   - default:
  983 + default:
988 984 *ptr++ = c;
989 985 break;
990 986 }
991 987  
992 988  
993 989  
994 990  
995 991  
996 992  
997 993  
... ... @@ -996,33 +992,31 @@
996 992 static void slip_unesc(struct slip *sl, unsigned char s)
997 993 {
998 994  
999   - switch(s) {
1000   - case END:
  995 + switch (s) {
  996 + case END:
1001 997 #ifdef CONFIG_SLIP_SMART
1002 998 /* drop keeptest bit = VSV */
1003 999 if (test_bit(SLF_KEEPTEST, &sl->flags))
1004 1000 clear_bit(SLF_KEEPTEST, &sl->flags);
1005 1001 #endif
1006 1002  
1007   - if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) {
  1003 + if (!test_and_clear_bit(SLF_ERROR, &sl->flags)
  1004 + && (sl->rcount > 2))
1008 1005 sl_bump(sl);
1009   - }
1010 1006 clear_bit(SLF_ESCAPE, &sl->flags);
1011 1007 sl->rcount = 0;
1012 1008 return;
1013 1009  
1014   - case ESC:
  1010 + case ESC:
1015 1011 set_bit(SLF_ESCAPE, &sl->flags);
1016 1012 return;
1017   - case ESC_ESC:
1018   - if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) {
  1013 + case ESC_ESC:
  1014 + if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
1019 1015 s = ESC;
1020   - }
1021 1016 break;
1022   - case ESC_END:
1023   - if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) {
  1017 + case ESC_END:
  1018 + if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
1024 1019 s = END;
1025   - }
1026 1020 break;
1027 1021 }
1028 1022 if (!test_bit(SLF_ERROR, &sl->flags)) {
... ... @@ -1041,8 +1035,7 @@
1041 1035 * 6 BIT SLIP ENCAPSULATION *
1042 1036 ************************************************************************/
1043 1037  
1044   -int
1045   -slip_esc6(unsigned char *s, unsigned char *d, int len)
  1038 +static int slip_esc6(unsigned char *s, unsigned char *d, int len)
1046 1039 {
1047 1040 unsigned char *ptr = d;
1048 1041 unsigned char c;
... ... @@ -1079,8 +1072,7 @@
1079 1072 return ptr - d;
1080 1073 }
1081 1074  
1082   -void
1083   -slip_unesc6(struct slip *sl, unsigned char s)
  1075 +static void slip_unesc6(struct slip *sl, unsigned char s)
1084 1076 {
1085 1077 unsigned char c;
1086 1078  
1087 1079  
1088 1080  
... ... @@ -1091,13 +1083,13 @@
1091 1083 clear_bit(SLF_KEEPTEST, &sl->flags);
1092 1084 #endif
1093 1085  
1094   - if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) {
  1086 + if (!test_and_clear_bit(SLF_ERROR, &sl->flags)
  1087 + && (sl->rcount > 2))
1095 1088 sl_bump(sl);
1096   - }
1097 1089 sl->rcount = 0;
1098 1090 sl->xbits = 0;
1099 1091 sl->xdata = 0;
1100   - } else if (s >= 0x30 && s < 0x70) {
  1092 + } else if (s >= 0x30 && s < 0x70) {
1101 1093 sl->xdata = (sl->xdata << 6) | ((s - 0x30) & 0x3F);
1102 1094 sl->xbits += 6;
1103 1095 if (sl->xbits >= 8) {
1104 1096  
1105 1097  
1106 1098  
1107 1099  
1108 1100  
... ... @@ -1112,24 +1104,24 @@
1112 1104 set_bit(SLF_ERROR, &sl->flags);
1113 1105 }
1114 1106 }
1115   - }
  1107 + }
1116 1108 }
1117 1109 #endif /* CONFIG_SLIP_MODE_SLIP6 */
1118 1110  
1119 1111 /* Perform I/O control on an active SLIP channel. */
1120   -static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
  1112 +static int slip_ioctl(struct tty_struct *tty, struct file *file,
  1113 + unsigned int cmd, unsigned long arg)
1121 1114 {
1122   - struct slip *sl = (struct slip *) tty->disc_data;
  1115 + struct slip *sl = tty->disc_data;
1123 1116 unsigned int tmp;
1124 1117 int __user *p = (int __user *)arg;
1125 1118  
1126 1119 /* First make sure we're connected. */
1127   - if (!sl || sl->magic != SLIP_MAGIC) {
  1120 + if (!sl || sl->magic != SLIP_MAGIC)
1128 1121 return -EINVAL;
1129   - }
1130 1122  
1131   - switch(cmd) {
1132   - case SIOCGIFNAME:
  1123 + switch (cmd) {
  1124 + case SIOCGIFNAME:
1133 1125 tmp = strlen(sl->dev->name) + 1;
1134 1126 if (copy_to_user((void __user *)arg, sl->dev->name, tmp))
1135 1127 return -EFAULT;
1136 1128  
1137 1129  
1138 1130  
1139 1131  
1140 1132  
1141 1133  
1142 1134  
1143 1135  
1144 1136  
... ... @@ -1144,34 +1136,31 @@
1144 1136 if (get_user(tmp, p))
1145 1137 return -EFAULT;
1146 1138 #ifndef SL_INCLUDE_CSLIP
1147   - if (tmp & (SL_MODE_CSLIP|SL_MODE_ADAPTIVE)) {
  1139 + if (tmp & (SL_MODE_CSLIP|SL_MODE_ADAPTIVE))
1148 1140 return -EINVAL;
1149   - }
1150 1141 #else
1151 1142 if ((tmp & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) ==
1152   - (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
  1143 + (SL_MODE_ADAPTIVE | SL_MODE_CSLIP))
1153 1144 /* return -EINVAL; */
1154 1145 tmp &= ~SL_MODE_ADAPTIVE;
1155   - }
1156 1146 #endif
1157 1147 #ifndef CONFIG_SLIP_MODE_SLIP6
1158   - if (tmp & SL_MODE_SLIP6) {
  1148 + if (tmp & SL_MODE_SLIP6)
1159 1149 return -EINVAL;
1160   - }
1161 1150 #endif
1162 1151 sl->mode = tmp;
1163   - sl->dev->type = ARPHRD_SLIP+sl->mode;
  1152 + sl->dev->type = ARPHRD_SLIP + sl->mode;
1164 1153 return 0;
1165 1154  
1166   - case SIOCSIFHWADDR:
  1155 + case SIOCSIFHWADDR:
1167 1156 return -EINVAL;
1168 1157  
1169 1158 #ifdef CONFIG_SLIP_SMART
1170 1159 /* VSV changes start here */
1171   - case SIOCSKEEPALIVE:
  1160 + case SIOCSKEEPALIVE:
1172 1161 if (get_user(tmp, p))
1173 1162 return -EFAULT;
1174   - if (tmp > 255) /* max for unchar */
  1163 + if (tmp > 255) /* max for unchar */
1175 1164 return -EINVAL;
1176 1165  
1177 1166 spin_lock_bh(&sl->lock);
1178 1167  
1179 1168  
1180 1169  
1181 1170  
1182 1171  
1183 1172  
1184 1173  
1185 1174  
... ... @@ -1179,40 +1168,42 @@
1179 1168 spin_unlock_bh(&sl->lock);
1180 1169 return -ENODEV;
1181 1170 }
1182   - if ((sl->keepalive = (unchar) tmp) != 0) {
1183   - mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
  1171 + sl->keepalive = (u8)tmp;
  1172 + if (sl->keepalive != 0) {
  1173 + mod_timer(&sl->keepalive_timer,
  1174 + jiffies + sl->keepalive * HZ);
1184 1175 set_bit(SLF_KEEPTEST, &sl->flags);
1185   - } else {
1186   - del_timer (&sl->keepalive_timer);
1187   - }
  1176 + } else
  1177 + del_timer(&sl->keepalive_timer);
1188 1178 spin_unlock_bh(&sl->lock);
1189 1179 return 0;
1190 1180  
1191   - case SIOCGKEEPALIVE:
  1181 + case SIOCGKEEPALIVE:
1192 1182 if (put_user(sl->keepalive, p))
1193 1183 return -EFAULT;
1194 1184 return 0;
1195 1185  
1196   - case SIOCSOUTFILL:
  1186 + case SIOCSOUTFILL:
1197 1187 if (get_user(tmp, p))
1198 1188 return -EFAULT;
1199   - if (tmp > 255) /* max for unchar */
  1189 + if (tmp > 255) /* max for unchar */
1200 1190 return -EINVAL;
1201 1191 spin_lock_bh(&sl->lock);
1202 1192 if (!sl->tty) {
1203 1193 spin_unlock_bh(&sl->lock);
1204 1194 return -ENODEV;
1205 1195 }
1206   - if ((sl->outfill = (unchar) tmp) != 0){
1207   - mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
  1196 + sl->outfill = (u8)tmp;
  1197 + if (sl->outfill != 0) {
  1198 + mod_timer(&sl->outfill_timer,
  1199 + jiffies + sl->outfill * HZ);
1208 1200 set_bit(SLF_OUTWAIT, &sl->flags);
1209   - } else {
1210   - del_timer (&sl->outfill_timer);
1211   - }
  1201 + } else
  1202 + del_timer(&sl->outfill_timer);
1212 1203 spin_unlock_bh(&sl->lock);
1213   - return 0;
  1204 + return 0;
1214 1205  
1215   - case SIOCGOUTFILL:
  1206 + case SIOCGOUTFILL:
1216 1207 if (put_user(sl->outfill, p))
1217 1208 return -EFAULT;
1218 1209 return 0;
... ... @@ -1229,7 +1220,7 @@
1229 1220 to allow get/set outfill/keepalive parameter
1230 1221 by ifconfig */
1231 1222  
1232   -static int sl_ioctl(struct net_device *dev,struct ifreq *rq,int cmd)
  1223 +static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1233 1224 {
1234 1225 struct slip *sl = netdev_priv(dev);
1235 1226 unsigned long *p = (unsigned long *)&rq->ifr_ifru;
1236 1227  
1237 1228  
1238 1229  
1239 1230  
1240 1231  
1241 1232  
1242 1233  
1243 1234  
1244 1235  
1245 1236  
1246 1237  
1247 1238  
1248 1239  
1249 1240  
... ... @@ -1244,58 +1235,61 @@
1244 1235 return -ENODEV;
1245 1236 }
1246 1237  
1247   - switch(cmd){
1248   - case SIOCSKEEPALIVE:
  1238 + switch (cmd) {
  1239 + case SIOCSKEEPALIVE:
1249 1240 /* max for unchar */
1250   - if ((unsigned)*p > 255) {
  1241 + if ((unsigned)*p > 255) {
1251 1242 spin_unlock_bh(&sl->lock);
1252 1243 return -EINVAL;
1253 1244 }
1254   - sl->keepalive = (unchar) *p;
  1245 + sl->keepalive = (u8)*p;
1255 1246 if (sl->keepalive != 0) {
1256   - sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
1257   - mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
  1247 + sl->keepalive_timer.expires =
  1248 + jiffies + sl->keepalive * HZ;
  1249 + mod_timer(&sl->keepalive_timer,
  1250 + jiffies + sl->keepalive * HZ);
1258 1251 set_bit(SLF_KEEPTEST, &sl->flags);
1259   - } else {
1260   - del_timer(&sl->keepalive_timer);
1261   - }
  1252 + } else
  1253 + del_timer(&sl->keepalive_timer);
1262 1254 break;
1263 1255  
1264   - case SIOCGKEEPALIVE:
  1256 + case SIOCGKEEPALIVE:
1265 1257 *p = sl->keepalive;
1266 1258 break;
1267 1259  
1268   - case SIOCSOUTFILL:
1269   - if ((unsigned)*p > 255) { /* max for unchar */
  1260 + case SIOCSOUTFILL:
  1261 + if ((unsigned)*p > 255) { /* max for unchar */
1270 1262 spin_unlock_bh(&sl->lock);
1271 1263 return -EINVAL;
1272 1264 }
1273   - if ((sl->outfill = (unchar)*p) != 0){
1274   - mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
  1265 + sl->outfill = (u8)*p;
  1266 + if (sl->outfill != 0) {
  1267 + mod_timer(&sl->outfill_timer,
  1268 + jiffies + sl->outfill * HZ);
1275 1269 set_bit(SLF_OUTWAIT, &sl->flags);
1276   - } else {
1277   - del_timer (&sl->outfill_timer);
1278   - }
1279   - break;
  1270 + } else
  1271 + del_timer(&sl->outfill_timer);
  1272 + break;
1280 1273  
1281   - case SIOCGOUTFILL:
  1274 + case SIOCGOUTFILL:
1282 1275 *p = sl->outfill;
1283 1276 break;
1284 1277  
1285   - case SIOCSLEASE:
  1278 + case SIOCSLEASE:
1286 1279 /* Resolve race condition, when ioctl'ing hanged up
1287 1280 and opened by another process device.
1288 1281 */
1289   - if (sl->tty != current->signal->tty && sl->pid != current->pid) {
  1282 + if (sl->tty != current->signal->tty &&
  1283 + sl->pid != current->pid) {
1290 1284 spin_unlock_bh(&sl->lock);
1291 1285 return -EPERM;
1292 1286 }
1293 1287 sl->leased = 0;
1294   - if (*p)
  1288 + if (*p)
1295 1289 sl->leased = 1;
1296   - break;
  1290 + break;
1297 1291  
1298   - case SIOCGLEASE:
  1292 + case SIOCGLEASE:
1299 1293 *p = sl->leased;
1300 1294 };
1301 1295 spin_unlock_bh(&sl->lock);
... ... @@ -1327,7 +1321,7 @@
1327 1321 " (6 bit encapsulation enabled)"
1328 1322 #endif
1329 1323 ".\n",
1330   - SLIP_VERSION, slip_maxdev );
  1324 + SLIP_VERSION, slip_maxdev);
1331 1325 #if defined(SL_INCLUDE_CSLIP)
1332 1326 printk(KERN_INFO "CSLIP: code copyright 1989 Regents of the University of California.\n");
1333 1327 #endif
1334 1328  
1335 1329  
... ... @@ -1335,14 +1329,16 @@
1335 1329 printk(KERN_INFO "SLIP linefill/keepalive option.\n");
1336 1330 #endif
1337 1331  
1338   - slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, GFP_KERNEL);
  1332 + slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev,
  1333 + GFP_KERNEL);
1339 1334 if (!slip_devs) {
1340   - printk(KERN_ERR "SLIP: Can't allocate slip devices array! Uaargh! (-> No SLIP available)\n");
  1335 + printk(KERN_ERR "SLIP: Can't allocate slip devices array.\n");
1341 1336 return -ENOMEM;
1342 1337 }
1343 1338  
1344 1339 /* Fill in our line protocol discipline, and register it */
1345   - if ((status = tty_register_ldisc(N_SLIP, &sl_ldisc)) != 0) {
  1340 + status = tty_register_ldisc(N_SLIP, &sl_ldisc);
  1341 + if (status != 0) {
1346 1342 printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status);
1347 1343 kfree(slip_devs);
1348 1344 }
1349 1345  
... ... @@ -1402,10 +1398,9 @@
1402 1398 kfree(slip_devs);
1403 1399 slip_devs = NULL;
1404 1400  
1405   - if ((i = tty_unregister_ldisc(N_SLIP)))
1406   - {
  1401 + i = tty_unregister_ldisc(N_SLIP);
  1402 + if (i != 0)
1407 1403 printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i);
1408   - }
1409 1404 }
1410 1405  
1411 1406 module_init(slip_init);
1412 1407  
... ... @@ -1419,17 +1414,15 @@
1419 1414  
1420 1415 static void sl_outfill(unsigned long sls)
1421 1416 {
1422   - struct slip *sl=(struct slip *)sls;
  1417 + struct slip *sl = (struct slip *)sls;
1423 1418  
1424 1419 spin_lock(&sl->lock);
1425 1420  
1426 1421 if (sl->tty == NULL)
1427 1422 goto out;
1428 1423  
1429   - if(sl->outfill)
1430   - {
1431   - if( test_bit(SLF_OUTWAIT, &sl->flags) )
1432   - {
  1424 + if (sl->outfill) {
  1425 + if (test_bit(SLF_OUTWAIT, &sl->flags)) {
1433 1426 /* no packets were transmitted, do outfill */
1434 1427 #ifdef CONFIG_SLIP_MODE_SLIP6
1435 1428 unsigned char s = (sl->mode & SL_MODE_SLIP6)?0x70:END;
1436 1429  
... ... @@ -1437,13 +1430,11 @@
1437 1430 unsigned char s = END;
1438 1431 #endif
1439 1432 /* put END into tty queue. Is it right ??? */
1440   - if (!netif_queue_stopped(sl->dev))
1441   - {
  1433 + if (!netif_queue_stopped(sl->dev)) {
1442 1434 /* if device busy no outfill */
1443 1435 sl->tty->driver->write(sl->tty, &s, 1);
1444 1436 }
1445   - }
1446   - else
  1437 + } else
1447 1438 set_bit(SLF_OUTWAIT, &sl->flags);
1448 1439  
1449 1440 mod_timer(&sl->outfill_timer, jiffies+sl->outfill*HZ);
1450 1441  
1451 1442  
1452 1443  
1453 1444  
1454 1445  
... ... @@ -1454,31 +1445,29 @@
1454 1445  
1455 1446 static void sl_keepalive(unsigned long sls)
1456 1447 {
1457   - struct slip *sl=(struct slip *)sls;
  1448 + struct slip *sl = (struct slip *)sls;
1458 1449  
1459 1450 spin_lock(&sl->lock);
1460 1451  
1461 1452 if (sl->tty == NULL)
1462 1453 goto out;
1463 1454  
1464   - if( sl->keepalive)
1465   - {
1466   - if(test_bit(SLF_KEEPTEST, &sl->flags))
1467   - {
  1455 + if (sl->keepalive) {
  1456 + if (test_bit(SLF_KEEPTEST, &sl->flags)) {
1468 1457 /* keepalive still high :(, we must hangup */
1469   - if( sl->outfill ) /* outfill timer must be deleted too */
  1458 + if (sl->outfill)
  1459 + /* outfill timer must be deleted too */
1470 1460 (void)del_timer(&sl->outfill_timer);
1471 1461 printk(KERN_DEBUG "%s: no packets received during keepalive timeout, hangup.\n", sl->dev->name);
1472   - tty_hangup(sl->tty); /* this must hangup tty & close slip */
  1462 + /* this must hangup tty & close slip */
  1463 + tty_hangup(sl->tty);
1473 1464 /* I think we need not something else */
1474 1465 goto out;
1475   - }
1476   - else
  1466 + } else
1477 1467 set_bit(SLF_KEEPTEST, &sl->flags);
1478 1468  
1479 1469 mod_timer(&sl->keepalive_timer, jiffies+sl->keepalive*HZ);
1480 1470 }
1481   -
1482 1471 out:
1483 1472 spin_unlock(&sl->lock);
1484 1473 }