scc.c-2.4.0-test12-patch-v1

From: Hans Grobler (chzn.fycadwzwp@fulltext.sk)
Date: Tue Dec 12 2000 - 09:55:30 EET

  • Next message: Hans Grobler: "baycom_epp.c-2.4.0-test12-patch-v1"

    scc.c-2.4.0-test12-patch-v1:
      - banner: converted banner macro into ejectable const string.
      - Driver_Initialized,Nchips,Vector_Latch,scc_init_driver: removed
          explict static variable initialization as per linux2.4.
      - SVAL: removed stray macro
      - scc_net_procfs_init,scc_net_procfs_remove: removed unnecessary macros.
          linux2.4 proc headers do the right thing when proc_fs is not
          configured.

    2.4.0-test12-pre7-patch-v3:
      - init_module,cleanup_module: Removed forward declarations that no
          longer exist.
      - scc_init: Removed unnecessary declaration (already in header).
      - scc_net_ioctl: Added missing request_region for Vector_Latch port.
      - scc_cleanup_driver: Added corresponding release_region for
          Vector_Latch port.

    2.4.0-test12-pre7-patch-v2:
      - scc_net_header: Removed unnecessary function. Use ax25_encapsulate
          directly as is done for ax25_rebuild_header.
      - scc_cli,scc_sti: Remove unused functions.

    2.4.0-test12-pre7-patch-v1:
      - scc_cleanup_driver: For the case when the driver is loaded and
          immediately unload, fix the memory leak of scc->dev.
      - scc_cleanup_driver: The NULL check during channel deregistering is not
          sufficient. The pointer 'scc' will never be NULL as it points to
          a static structure. To prevent invalid release_region calls, check
          to see if the ports where requested (i.e. ->ctrl != 0).

    diff -u3Nr -X dontdiff linux-2.4.0-test12.orig/drivers/net/hamradio/scc.c linux-2.4.0-test12/drivers/net/hamradio/scc.c
    --- linux-2.4.0-test12.orig/drivers/net/hamradio/scc.c Thu Oct 12 23:05:34 2000
    +++ linux-2.4.0-test12/drivers/net/hamradio/scc.c Tue Dec 12 09:15:12 2000
    @@ -1,7 +1,6 @@
     #define RCS_ID "$Id: scc.c,v 1.75 1998/11/04 15:15:01 jreuter Exp jreuter $"

     #define VERSION "3.0"
    -#define BANNER "AX.25: Z8530 SCC driver version "VERSION".dl1bke\n"

     /*
      * Please use z8530drv-utils-3.0 with this version.
    @@ -142,8 +141,6 @@

     #define SCC_MAXCHIPS 4 /* number of max. supported chips */
     #define SCC_BUFSIZE 384 /* must not exceed 4096 */
    -#undef SCC_DISABLE_ALL_INTS /* use cli()/sti() in ISR instead of */
    - /* enable_irq()/disable_irq() */
     #undef SCC_DEBUG

     #define SCC_DEFAULT_CLOCK 4915200
    @@ -187,12 +184,8 @@
     #include <linux/kernel.h>
     #include <linux/proc_fs.h>

    -#ifdef MODULE
    -int init_module(void);
    -void cleanup_module(void);
    -#endif
    -
    -int scc_init(void);
    +static const char banner[] __initdata = KERN_INFO
    + "AX.25: Z8530 SCC driver version "VERSION".dl1bke\n";

     static void t_dwait(unsigned long);
     static void t_txdelay(unsigned long);
    @@ -220,7 +213,6 @@
     static int scc_net_tx(struct sk_buff *skb, struct net_device *dev);
     static int scc_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
     static int scc_net_set_mac_address(struct net_device *dev, void *addr);
    -static int scc_net_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len);
     static struct net_device_stats * scc_net_get_stats(struct net_device *dev);

     static unsigned char *SCC_DriverName = "scc";
    @@ -235,9 +227,9 @@
             int irq;
     } SCC_ctrl[SCC_MAXCHIPS+1];

    -static unsigned char Driver_Initialized = 0;
    -static int Nchips = 0;
    -static io_port Vector_Latch = 0;
    +static unsigned char Driver_Initialized;
    +static int Nchips;
    +static io_port Vector_Latch;

     /* ******************************************************************** */
    @@ -298,18 +290,6 @@
             OutReg(scc->ctrl, reg, (scc->wreg[reg] &= ~val));
     }

    -#ifdef SCC_DISABLE_ALL_INTS
    -static inline void scc_cli(int irq)
    -{ cli(); }
    -static inline void scc_sti(int irq)
    -{ sti(); }
    -#else
    -static inline void scc_cli(int irq)
    -{ disable_irq(irq); }
    -static inline void scc_sti(int irq)
    -{ enable_irq(irq); }
    -#endif
    -
     /* ******************************************************************** */
     /* * Some useful macros * */
     /* ******************************************************************** */
    @@ -1427,7 +1407,6 @@
     }

     #undef CAST
    -#undef SVAL

     /* ******************************************************************* */
     /* * Send calibration pattern * */
    @@ -1604,7 +1583,7 @@
             dev->stop = scc_net_close;

             dev->hard_start_xmit = scc_net_tx;
    - dev->hard_header = scc_net_header;
    + dev->hard_header = ax25_encapsulate;
             dev->rebuild_header = ax25_rebuild_header;
             dev->set_mac_address = scc_net_set_mac_address;
             dev->get_stats = scc_net_get_stats;
    @@ -1804,8 +1783,12 @@
                                             Ivec[hwcfg.irq].used = 1;
                             }

    - if (hwcfg.vector_latch)
    - Vector_Latch = hwcfg.vector_latch;
    + if (hwcfg.vector_latch) {
    + if (!request_region(Vector_Latch, 1, "scc vector latch"))
    + printk(KERN_WARNING "z8530drv: warning, cannot reserve vector latch port 0x%x\n, disabled.", hwcfg.vector_latch);
    + else
    + Vector_Latch = hwcfg.vector_latch;
    + }

                             if (hwcfg.clock == 0)
                                     hwcfg.clock = SCC_DEFAULT_CLOCK;
    @@ -2001,14 +1984,6 @@
             return 0;
     }

    -/* ----> "hard" header <---- */
    -
    -static int scc_net_header(struct sk_buff *skb, struct net_device *dev,
    - unsigned short type, void *daddr, void *saddr, unsigned len)
    -{
    - return ax25_encapsulate(skb, dev, type, daddr, saddr, len);
    -}
    -
     /* ----> get statistics <---- */

     static struct net_device_stats *scc_net_get_stats(struct net_device *dev)
    @@ -2133,40 +2108,17 @@
             return len;
     }

    -#ifdef CONFIG_PROC_FS
    -#define scc_net_procfs_init() proc_net_create("z8530drv",0,scc_net_get_info)
    -#define scc_net_procfs_remove() proc_net_remove("z8530drv")
    -#else
    -#define scc_net_procfs_init()
    -#define scc_net_procfs_remove()
    -#endif

    -
     /* ******************************************************************** */
     /* * Init SCC driver * */
     /* ******************************************************************** */

     static int __init scc_init_driver (void)
     {
    - int chip, chan, k, result;
    + int result;
             char devname[10];
    -
    - printk(KERN_INFO BANNER);
    -
    - memset(&SCC_ctrl, 0, sizeof(SCC_ctrl));
    -
    - /* pre-init channel information */
    -
    - for (chip = 0; chip < SCC_MAXCHIPS; chip++)
    - {
    - memset((char *) &SCC_Info[2*chip ], 0, sizeof(struct scc_channel));
    - memset((char *) &SCC_Info[2*chip+1], 0, sizeof(struct scc_channel));
    -
    - for (chan = 0; chan < 2; chan++)
    - SCC_Info[2*chip+chan].magic = SCC_MAGIC;
    - }

    - for (k = 0; k < 16; k++) Ivec[k].used = 0;
    + printk(banner);

             sprintf(devname,"%s0", SCC_DriverName);

    @@ -2177,7 +2129,7 @@
                     return result;
             }

    - scc_net_procfs_init();
    + proc_net_create("z8530drv", 0, scc_net_get_info);

             return 0;
     }
    @@ -2193,7 +2145,10 @@
             cli();

             if (Nchips == 0)
    + {
                     unregister_netdev(SCC_Info[0].dev);
    + kfree(SCC_Info[0].dev);
    + }

             for (k = 0; k < Nchips; k++)
                     if ( (ctrl = SCC_ctrl[k].chan_A) )
    @@ -2206,24 +2161,27 @@
             for (k = 0; k < Nchips*2; k++)
             {
                     scc = &SCC_Info[k];
    - if (scc)
    + if (scc->ctrl)
                     {
                             release_region(scc->ctrl, 1);
                             release_region(scc->data, 1);
    - if (scc->dev)
    - {
    - unregister_netdev(scc->dev);
    - kfree(scc->dev);
    - }
    + }
    + if (scc->dev)
    + {
    + unregister_netdev(scc->dev);
    + kfree(scc->dev);
                     }
             }

             for (k=0; k < 16 ; k++)
                     if (Ivec[k].used) free_irq(k, NULL);
    -
    +
    + if (Vector_Latch)
    + release_region(Vector_Latch, 1);
    +
             restore_flags(flags);

    - scc_net_procfs_remove();
    + proc_net_remove("z8530drv");
     }

     MODULE_AUTHOR("Joerg Reuter <cyuw@thew00tingclan.com>");

    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to terhi.victor@logonet.com



    This archive was generated by hypermail 2b30 : Tue Dec 12 2000 - 09:56:41 EET