patch-2.3.46 linux/drivers/net/hamradio/scc.c
Next file: linux/drivers/net/ltpc.c
Previous file: linux/drivers/net/hamradio/hdlcdrv.c
Back to the patch index
Back to the overall index
- Lines: 387
- Date:
Tue Feb 15 17:19:07 2000
- Orig file:
v2.3.45/linux/drivers/net/hamradio/scc.c
- Orig date:
Sun Feb 13 19:29:04 2000
diff -u --recursive --new-file v2.3.45/linux/drivers/net/hamradio/scc.c linux/drivers/net/hamradio/scc.c
@@ -1,7 +1,7 @@
#define RCS_ID "$Id: scc.c,v 1.75 1998/11/04 15:15:01 jreuter Exp jreuter $"
#define VERSION "3.0"
-#define BANNER "Z8530 SCC driver version "VERSION".dl1bke (experimental) by DL1BKE\n"
+#define BANNER "AX.25: Z8530 SCC driver version "VERSION".dl1bke\n"
/*
* Please use z8530drv-utils-3.0 with this version.
@@ -19,7 +19,7 @@
********************************************************************
- Copyright (c) 1993, 1998 Joerg Reuter DL1BKE
+ Copyright (c) 1993, 2000 Joerg Reuter DL1BKE
portions (c) 1993 Guido ten Dolle PE1NNZ
@@ -104,6 +104,9 @@
flags that aren't... Restarting the DPLL does not help
either, it resynchronizes too slow and the first received
frame gets lost.
+ 2000-02-13 Fixed for new network driver interface changes, still
+ does TX timeouts itself since it uses its own queue
+ scheme.
Thanks to all who contributed to this driver with ideas and bug
reports!
@@ -236,9 +239,6 @@
static int Nchips = 0;
static io_port Vector_Latch = 0;
-MODULE_AUTHOR("Joerg Reuter <jreuter@poboxes.com>");
-MODULE_DESCRIPTION("Network Device Driver for Z8530 based HDLC cards for Amateur Packet Radio");
-MODULE_SUPPORTED_DEVICE("scc");
/* ******************************************************************** */
/* * Port Access Functions * */
@@ -314,17 +314,6 @@
/* * Some useful macros * */
/* ******************************************************************** */
-
-static inline void scc_lock_dev(struct scc_channel *scc)
-{
- netif_stop_queue(scc->dev);
-}
-
-static inline void scc_unlock_dev(struct scc_channel *scc)
-{
- netif_wake_queue(scc->dev);
-}
-
static inline void scc_discard_buffers(struct scc_channel *scc)
{
unsigned long flags;
@@ -382,7 +371,7 @@
if(scc->rx_buff != NULL) /* did we receive something? */
{
scc->stat.rxerrs++; /* then count it as an error */
- kfree_skb(scc->rx_buff);
+ dev_kfree_skb_irq(scc->rx_buff);
scc->rx_buff = NULL;
}
}
@@ -411,7 +400,7 @@
{
skb = skb_dequeue(&scc->tx_queue);
scc->tx_buff = skb;
- scc_unlock_dev(scc);
+ netif_wake_queue(scc->dev);
if (skb == NULL)
{
@@ -422,7 +411,7 @@
if (skb->len == 0) /* Paranoia... */
{
- dev_kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
scc->tx_buff = NULL;
scc_tx_done(scc);
Outb(scc->ctrl, RES_Tx_P);
@@ -448,7 +437,7 @@
{
Outb(scc->ctrl, RES_Tx_P); /* reset pending int */
cl(scc, R10, ABUNDER); /* send CRC */
- dev_kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
scc->tx_buff = NULL;
scc->stat.tx_state = TXS_NEWFRAME; /* next frame... */
return;
@@ -533,7 +522,7 @@
if (scc->tx_buff != NULL)
{
- dev_kfree_skb(scc->tx_buff);
+ dev_kfree_skb_irq(scc->tx_buff);
scc->tx_buff = NULL;
}
@@ -583,7 +572,7 @@
#ifdef notdef
printk(KERN_DEBUG "z8530drv: oops, scc_rxint() received huge frame...\n");
#endif
- kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
scc->rx_buff = NULL;
Inb(scc->data);
or(scc, R3, ENT_HM);
@@ -613,7 +602,7 @@
or(scc,R3,ENT_HM); /* enter hunt mode for next flag */
if (skb != NULL)
- kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
scc->rx_buff = NULL;
}
@@ -629,7 +618,7 @@
scc->rx_buff = NULL;
scc->stat.rxframes++;
} else { /* a bad frame */
- kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
scc->rx_buff = NULL;
scc->stat.rxerrs++;
}
@@ -1112,7 +1101,7 @@
scc_start_tx_timer(scc, t_tail, scc->kiss.tailtime);
}
- scc_unlock_dev(scc);
+ netif_wake_queue(scc->dev);
}
@@ -1163,7 +1152,7 @@
if (skb_queue_len(&scc->tx_queue) == 0) /* nothing to send */
{
scc->stat.tx_state = TXS_IDLE;
- scc_unlock_dev(scc); /* t_maxkeyup locked it. */
+ netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
return;
}
@@ -1243,7 +1232,7 @@
}
scc->stat.tx_state = TXS_IDLE;
- scc_unlock_dev(scc);
+ netif_wake_queue(scc->dev);
}
@@ -1257,14 +1246,13 @@
struct scc_channel *scc = (struct scc_channel *) channel;
del_timer(&scc->tx_t);
- scc_lock_dev(scc);
+ netif_stop_queue(scc->dev); /* don't pile on the wabbit! */
scc_discard_buffers(scc);
-
scc->stat.txerrs++;
scc->stat.tx_state = TXS_IDLE;
-
- scc_unlock_dev(scc);
+
+ netif_wake_queue(scc->dev);
}
/* MAXKEYUP timeout
@@ -1285,7 +1273,7 @@
* accept new data.
*/
- scc_lock_dev(scc);
+ netif_stop_queue(scc->dev);
scc_discard_buffers(scc);
del_timer(&scc->tx_t);
@@ -1460,8 +1448,7 @@
Outb(scc->ctrl,RES_EXT_INT); /* reset ext/status interrupts */
Outb(scc->ctrl,RES_EXT_INT);
- scc_unlock_dev(scc);
-
+ netif_wake_queue(scc->dev);
restore_flags(flags);
}
@@ -1474,7 +1461,7 @@
save_flags(flags);
cli();
- scc_lock_dev(scc);
+ netif_stop_queue(scc->dev);
scc_discard_buffers(scc);
del_timer(&scc->tx_wdog);
@@ -1497,7 +1484,6 @@
Outb(scc->ctrl,RES_EXT_INT);
scc_key_trx(scc, TX_ON);
-
restore_flags(flags);
}
@@ -1583,7 +1569,9 @@
dev = scc->dev;
memset(dev, 0, sizeof(struct net_device));
- buf = (unsigned char *) kmalloc(10, GFP_KERNEL);
+ if ((buf = (unsigned char *) kmalloc(10, GFP_KERNEL)) == NULL)
+ return -ENOMEM;
+
strcpy(buf, name);
dev->priv = (void *) scc;
@@ -1627,6 +1615,7 @@
dev->set_mac_address = scc_net_set_mac_address;
dev->get_stats = scc_net_get_stats;
dev->do_ioctl = scc_net_ioctl;
+ dev->tx_timeout = NULL;
memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, ax25_nocall, AX25_ADDR_LEN);
@@ -1647,14 +1636,11 @@
{
struct scc_channel *scc = (struct scc_channel *) dev->priv;
- if (scc == NULL || scc->magic != SCC_MAGIC)
- return -ENODEV;
-
if (!scc->init)
return -EINVAL;
MOD_INC_USE_COUNT;
-
+
scc->tx_buff = NULL;
skb_queue_head_init(&scc->tx_queue);
@@ -1671,10 +1657,7 @@
struct scc_channel *scc = (struct scc_channel *) dev->priv;
unsigned long flags;
- if (scc == NULL || scc->magic != SCC_MAGIC)
- return -ENODEV;
-
- MOD_DEC_USE_COUNT;
+ netif_stop_queue(dev);
save_flags(flags);
cli();
@@ -1690,7 +1673,7 @@
scc_discard_buffers(scc);
- netif_stop_queue(dev);
+ MOD_DEC_USE_COUNT;
return 0;
}
@@ -1700,7 +1683,7 @@
{
if (skb->len == 0)
{
- kfree_skb(skb);
+ dev_kfree_skb_irq(skb);
return;
}
@@ -1722,12 +1705,6 @@
struct scc_channel *scc = (struct scc_channel *) dev->priv;
unsigned long flags;
char kisscmd;
-
- if (scc == NULL || scc->magic != SCC_MAGIC)
- {
- dev_kfree_skb(skb);
- return 0;
- }
if (skb->len > scc->stat.bufsize || skb->len < 2)
{
@@ -1749,18 +1726,18 @@
return 0;
}
- save_flags(flags);
+ save_flags(flags);
cli();
if (skb_queue_len(&scc->tx_queue) > scc->dev->tx_queue_len)
{
struct sk_buff *skb_del;
- skb_del = __skb_dequeue(&scc->tx_queue);
+ skb_del = skb_dequeue(&scc->tx_queue);
dev_kfree_skb(skb_del);
}
- __skb_queue_tail(&scc->tx_queue, skb);
-
+ skb_queue_tail(&scc->tx_queue, skb);
dev->trans_start = jiffies;
+
/*
* Start transmission if the trx state is idle or
@@ -1777,8 +1754,7 @@
scc_start_tx_timer(scc, t_dwait, 0);
}
- restore_flags(flags);
-
+ restore_flags(flags);
return 0;
}
@@ -1807,9 +1783,6 @@
struct scc_channel *scc;
scc = (struct scc_channel *) dev->priv;
- if (scc == NULL || scc->magic != SCC_MAGIC)
- return -EINVAL;
-
arg = (void *) ifr->ifr_data;
if (!Driver_Initialized)
@@ -2048,9 +2021,6 @@
{
struct scc_channel *scc = (struct scc_channel *) dev->priv;
- if (scc == NULL || scc->magic != SCC_MAGIC)
- return NULL;
-
scc->dev_stat.rx_errors = scc->stat.rxerrs + scc->stat.rx_over;
scc->dev_stat.tx_errors = scc->stat.txerrs + scc->stat.tx_under;
scc->dev_stat.rx_fifo_errors = scc->stat.rx_over;
@@ -2182,7 +2152,7 @@
/* * Init SCC driver * */
/* ******************************************************************** */
-int __init scc_init (void)
+static int __init scc_init_driver (void)
{
int chip, chan, k, result;
char devname[10];
@@ -2218,25 +2188,7 @@
return 0;
}
-/* ******************************************************************** */
-/* * Module support * */
-/* ******************************************************************** */
-
-
-#ifdef MODULE
-int init_module(void)
-{
- int result = 0;
-
- result = scc_init();
-
- if (result == 0)
- printk(KERN_INFO "Copyright 1993,1998 Joerg Reuter DL1BKE (jreuter@poboxes.com)\n");
-
- return result;
-}
-
-void cleanup_module(void)
+static void __exit scc_cleanup_driver(void)
{
long flags;
io_port ctrl;
@@ -2279,4 +2231,9 @@
scc_net_procfs_remove();
}
-#endif
+
+MODULE_AUTHOR("Joerg Reuter <jreuter@poboxes.com>");
+MODULE_DESCRIPTION("AX.25 Device Driver for Z8530 based HDLC cards");
+MODULE_SUPPORTED_DEVICE("scc");
+module_init(scc_init_driver);
+module_exit(scc_cleanup_driver);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)