6pack.c-2.4.0-test12-pre8-patch-v1

From: Hans Grobler (rtpi@rele.tunk.net)
Date: Mon Dec 11 2000 - 16:15:18 EET

  • Next message: Bill Vodall: "Re: Questions re pseudo-ports"

    6pack.c-2.4.0-test12-pre8-patch-v1:
      - commented out userspace includes: removed... was for early testing?
      - banner,sixpack_init_ctrl_dev: converted initialization message to
          form suitable for __initdata tagging. will now be ejected by kernel
          after use.
      - sixpack_ctrls,sixpack_init_ctrl_dev: removed explicit clearing of
          variables as per linux2.4
      - sp_xmit: kernel network layer will never pass NULL skb, check
          unnecessary
      - removed stray endif comment
      - sixpack_maxdev: added missing support for module parameter

    6pack.c-2.4.0-test12-pre7-patch-v1:
      - sp_open: removed comment about cbuf (accidently copied from slip.c)
      - sp_set_mac_address,sixpack_ioctl: converted to linux2.4 to/from
          userspace functions
      - sp_set_mac_address,sixpack_init,sixpack_decode,decode_std_command,
          decode_data: made static functions

    diff -u3Nr -X dontdiff linux-2.4.0-test12-pre8.orig/drivers/net/hamradio/6pack.c linux-2.4.0-test12-pre8/drivers/net/hamradio/6pack.c
    --- linux-2.4.0-test12-pre8.orig/drivers/net/hamradio/6pack.c Thu May 4 20:31:21 2000
    +++ linux-2.4.0-test12-pre8/drivers/net/hamradio/6pack.c Mon Dec 11 11:40:21 2000
    @@ -37,16 +37,11 @@
     #include <linux/init.h>
     #include <linux/ip.h>
     #include <linux/tcp.h>
    -/*
    -#include <sys/types.h>
    -#include <sys/stat.h>
    -#include <fcntl.h>
    -#include <stdio.h>
    -#include <unistd.h>
    -*/

     #include "6pack.h"

    +static const char banner[] __initdata = KERN_INFO "AX.25: 6pack driver, " SIXPACK_VERSION " (dynamic channels, max=%d)\n";
    +
     typedef unsigned char byte;

    @@ -54,7 +49,7 @@
             struct sixpack ctrl; /* 6pack things */
             struct net_device dev; /* the device */
     } sixpack_ctrl_t;
    -static sixpack_ctrl_t **sixpack_ctrls = NULL;
    +static sixpack_ctrl_t **sixpack_ctrls;
     int sixpack_maxdev = SIXP_NRUNIT; /* Can be overridden with insmod! */

     static struct tty_ldisc sp_ldisc;
    @@ -62,12 +57,12 @@
     static void sp_start_tx_timer(struct sixpack *);
     static void sp_xmit_on_air(unsigned long);
     static void resync_tnc(unsigned long);
    -void sixpack_decode(struct sixpack *, unsigned char[], int);
    -int encode_sixpack(unsigned char *, unsigned char *, int, unsigned char);
    +static void sixpack_decode(struct sixpack *, unsigned char[], int);
    +static int encode_sixpack(unsigned char *, unsigned char *, int, unsigned char);

    -void decode_prio_command(byte, struct sixpack *);
    -void decode_std_command(byte, struct sixpack *);
    -void decode_data(byte, struct sixpack *);
    +static void decode_prio_command(byte, struct sixpack *);
    +static void decode_std_command(byte, struct sixpack *);
    +static void decode_data(byte, struct sixpack *);

     static int tnc_init(struct sixpack *);

    @@ -313,15 +308,12 @@
             struct sixpack *sp = (struct sixpack*)(dev->priv);

             /* We were not busy, so we are now... :-) */
    - if (skb != NULL) {
    - netif_stop_queue(dev);
    - sp->tx_bytes+=skb->len; /*---2.1.x---*/
    - sp_encaps(sp, skb->data, skb->len);
    - dev_kfree_skb(skb);
    - }
    + netif_stop_queue(dev);
    + sp->tx_bytes+=skb->len;
    + sp_encaps(sp, skb->data, skb->len);
    + dev_kfree_skb(skb);
             return 0;
     }
    -/* #endif */

     /* perform the persistence/slottime algorithm for CSMA access. If the persistence
    @@ -391,7 +383,6 @@
              *
              * rbuff Receive buffer.
              * xbuff Transmit buffer.
    - * cbuff Temporary compression buffer.
              */

             /* !!! length of the buffers. MTU is IP MTU, not PACLEN!
    @@ -603,19 +594,10 @@
     }

    -int
    +static int
     sp_set_mac_address(struct net_device *dev, void *addr)
     {
    - int err;
    -
    - err = verify_area(VERIFY_READ, addr, AX25_ADDR_LEN);
    - if (err) {
    - return err;
    - }
    -
    - copy_from_user(dev->dev_addr, addr, AX25_ADDR_LEN); /* addr is an AX.25 shifted ASCII mac address */
    -
    - return 0;
    + return copy_from_user(dev->dev_addr, addr, AX25_ADDR_LEN) ? -EFAULT : 0;
     }

     static int
    @@ -632,7 +614,6 @@
     sixpack_ioctl(struct tty_struct *tty, void *file, int cmd, void *arg)
     {
             struct sixpack *sp = (struct sixpack *) tty->disc_data;
    - int err;
             unsigned int tmp;

             /* First make sure we're connected. */
    @@ -642,29 +623,16 @@

             switch(cmd) {
              case SIOCGIFNAME:
    - err = verify_area(VERIFY_WRITE, arg, strlen(sp->dev->name) + 1);
    - if (err) {
    - return err;
    - }
    - copy_to_user(arg, sp->dev->name, strlen(sp->dev->name) + 1);
    - return 0;
    + return copy_to_user(arg, sp->dev->name, strlen(sp->dev->name) + 1) ? -EFAULT : 0;

             case SIOCGIFENCAP:
    - err = verify_area(VERIFY_WRITE, arg, sizeof(int));
    - if (err) {
    - return err;
    - }
    - put_user(0, (int *)arg);
    - return 0;
    + return put_user(0, (int *)arg);

             case SIOCSIFENCAP:
    - err = verify_area(VERIFY_READ, arg, sizeof(int));
    - if (err) {
    - return err;
    - }
    - get_user(tmp,(int *)arg);
    + if (get_user(tmp, (int *) arg))
    + return -EFAULT;

    - sp->mode = tmp;
    + sp->mode = tmp;
                     sp->dev->addr_len = AX25_ADDR_LEN; /* sizeof an AX.25 addr */
                     sp->dev->hard_header_len = AX25_KISS_HEADER_LEN + AX25_MAX_HEADER_LEN + 3;
                     sp->dev->type = ARPHRD_AX25;
    @@ -700,8 +668,7 @@

             if (sixpack_maxdev < 4) sixpack_maxdev = 4; /* Sanity */

    - printk(KERN_INFO "AX.25: 6pack driver, %s (dynamic channels, max=%d)\n",
    - SIXPACK_VERSION, sixpack_maxdev);
    + printk(banner, sixpack_maxdev);

             sixpack_ctrls = (sixpack_ctrl_t **) kmalloc(sizeof(void*)*sixpack_maxdev, GFP_KERNEL);
             if (sixpack_ctrls == NULL)
    @@ -715,7 +682,6 @@

             /* Fill in our line protocol discipline, and register it */
    - memset(&sp_ldisc, 0, sizeof(sp_ldisc));
             sp_ldisc.magic = TTY_LDISC_MAGIC;
             sp_ldisc.name = "6pack";
             sp_ldisc.flags = 0;
    @@ -768,7 +734,7 @@

     /* Initialize the 6pack driver. Called by DDI. */
    -int
    +static int
     sixpack_init(struct net_device *dev)
     {
             struct sixpack *sp = (struct sixpack*)(dev->priv);
    @@ -832,7 +798,7 @@

     /* encode an AX.25 packet into 6pack */

    -int encode_sixpack(byte *tx_buf, byte *tx_buf_raw, int length, byte tx_delay)
    +static int encode_sixpack(byte *tx_buf, byte *tx_buf_raw, int length, byte tx_delay)
     {
             int count = 0;
             byte checksum = 0, buf[400];
    @@ -873,7 +839,7 @@

     /* decode a 6pack packet */

    -void
    +static void
     sixpack_decode(struct sixpack *sp, unsigned char pre_rbuff[], int count)
     {
             byte inbyte;
    @@ -917,7 +883,7 @@

     /* identify and execute a 6pack priority command byte */

    -void decode_prio_command(byte cmd, struct sixpack *sp)
    +static void decode_prio_command(byte cmd, struct sixpack *sp)
     {
             byte channel;
             int actual;
    @@ -1016,7 +982,7 @@

     /* identify and execute a standard 6pack command byte */

    -void decode_std_command(byte cmd, struct sixpack *sp)
    +static void decode_std_command(byte cmd, struct sixpack *sp)
     {
             byte checksum = 0, rest = 0, channel;
             short i;
    @@ -1064,7 +1030,7 @@

     /* decode 4 sixpack-encoded bytes into 3 data bytes */

    -void decode_data(byte inbyte, struct sixpack *sp)
    +static void decode_data(byte inbyte, struct sixpack *sp)
     {

             unsigned char *buf;
    @@ -1086,5 +1052,9 @@

     MODULE_AUTHOR("Andreas Könsgen <ztnl.jikxm@eurotel.sk>");
     MODULE_DESCRIPTION("6pack driver for AX.25");
    +
    +MODULE_PARM(sixpack_maxdev, "i");
    +MODULE_PARM_DESC(sixpack_maxdev, "number of 6PACK devices");
    +
     module_init(sixpack_init_ctrl_dev);
     module_exit(sixpack_cleanup_driver);

    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to bmsm@asm.md



    This archive was generated by hypermail 2b30 : Mon Dec 11 2000 - 16:16:20 EET