From: Hans Grobler (ndlejh.gdzwdfdw@rele.tunk.net)
Date: Fri Dec 08 2000 - 06:17:30 EET
patch version 3:
- 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.
patch version 2:
- scc_net_header: Removed unnecessary function. Use ax25_encapsulate
directly as is done for ax25_rebuild_header.
- scc_cli,scc_sti: Remove unused functions.
patch version 1:
- 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-pre7.orig/drivers/net/hamradio/scc.c linux-2.4.0-test12-pre7/drivers/net/hamradio/scc.c
--- linux-2.4.0-test12-pre7.orig/drivers/net/hamradio/scc.c Thu Oct 12 23:05:34 2000
+++ linux-2.4.0-test12-pre7/drivers/net/hamradio/scc.c Thu Dec 7 15:45:53 2000
@@ -142,8 +142,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,13 +185,6 @@
#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 void t_dwait(unsigned long);
static void t_txdelay(unsigned long);
static void t_tail(unsigned long);
@@ -220,7 +211,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";
@@ -298,18 +288,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 * */
/* ******************************************************************** */
@@ -1604,7 +1582,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 +1782,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 +1983,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)
@@ -2148,7 +2122,7 @@
static int __init scc_init_driver (void)
{
- int chip, chan, k, result;
+ int chip, k, result;
char devname[10];
printk(KERN_INFO BANNER);
@@ -2161,9 +2135,6 @@
{
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;
@@ -2193,7 +2164,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,21 +2180,24 @@
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();
-
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 : Fri Dec 08 2000 - 06:18:29 EET