#include <linux/atm_zatm.h>
#include <linux/capability.h>
#include <linux/bitops.h>
+#include <linux/wait.h>
#include <asm/byteorder.h>
#include <asm/system.h>
#include <asm/string.h>
* - OAM
*/
+#define ZATM_COPPER 1
+
#if 0
#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
#else
struct zatm_vcc *zatm_vcc;
unsigned long flags;
int chan;
-struct sk_buff *skb;
-int once = 1;
zatm_vcc = ZATM_VCC(vcc);
zatm_dev = ZATM_DEV(vcc->dev);
chan = zatm_vcc->tx_chan;
if (!chan) return;
DPRINTK("close_tx\n");
- while (skb_peek(&zatm_vcc->backlog)) {
-if (once) {
-printk("waiting for backlog to drain ...\n");
-event_dump();
-once = 0;
-}
- sleep_on(&zatm_vcc->tx_wait);
+ if (skb_peek(&zatm_vcc->backlog)) {
+ printk("waiting for backlog to drain ...\n");
+ event_dump();
+ wait_event(zatm_vcc->tx_wait, !skb_peek(&zatm_vcc->backlog));
}
-once = 1;
- while ((skb = skb_peek(&zatm_vcc->tx_queue))) {
-if (once) {
-printk("waiting for TX queue to drain ... %p\n",skb);
-event_dump();
-once = 0;
-}
- DPRINTK("waiting for TX queue to drain ... %p\n",skb);
- sleep_on(&zatm_vcc->tx_wait);
+ if (skb_peek(&zatm_vcc->tx_queue)) {
+ printk("waiting for TX queue to drain ...\n");
+ event_dump();
+ wait_event(zatm_vcc->tx_wait, !skb_peek(&zatm_vcc->tx_queue));
}
spin_lock_irqsave(&zatm_dev->lock, flags);
#if 0
.change_qos = zatm_change_qos,
};
-static int __init zatm_module_init(void)
+static int __devinit zatm_init_one(struct pci_dev *pci_dev,
+ const struct pci_device_id *ent)
{
struct atm_dev *dev;
struct zatm_dev *zatm_dev;
- int devs,type;
-
- zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct zatm_dev),
- GFP_KERNEL);
- if (!zatm_dev) return -ENOMEM;
- devs = 0;
- for (type = 0; type < 2; type++) {
- struct pci_dev *pci_dev;
-
- pci_dev = NULL;
- while ((pci_dev = pci_find_device(PCI_VENDOR_ID_ZEITNET,type ?
- PCI_DEVICE_ID_ZEITNET_1225 : PCI_DEVICE_ID_ZEITNET_1221,
- pci_dev))) {
- if (pci_enable_device(pci_dev)) break;
- dev = atm_dev_register(DEV_LABEL,&ops,-1,NULL);
- if (!dev) break;
- zatm_dev->pci_dev = pci_dev;
- dev->dev_data = zatm_dev;
- zatm_dev->copper = type;
- if (zatm_init(dev) || zatm_start(dev)) {
- atm_dev_deregister(dev);
- break;
- }
- zatm_dev->more = zatm_boards;
- zatm_boards = dev;
- devs++;
- zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct
- zatm_dev),GFP_KERNEL);
- if (!zatm_dev) {
- printk(KERN_EMERG "zatm.c: memory shortage\n");
- goto out;
- }
- }
+ int ret = -ENOMEM;
+
+ zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL);
+ if (!zatm_dev) {
+ printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL);
+ goto out;
}
+
+ dev = atm_dev_register(DEV_LABEL, &ops, -1, NULL);
+ if (!dev)
+ goto out_free;
+
+ ret = pci_enable_device(pci_dev);
+ if (ret < 0)
+ goto out_deregister;
+
+ ret = pci_request_regions(pci_dev, DEV_LABEL);
+ if (ret < 0)
+ goto out_disable;
+
+ zatm_dev->pci_dev = pci_dev;
+ dev->dev_data = zatm_dev;
+ zatm_dev->copper = (int)ent->driver_data;
+ if ((ret = zatm_init(dev)) || (ret = zatm_start(dev)))
+ goto out_release;
+
+ pci_set_drvdata(pci_dev, dev);
+ zatm_dev->more = zatm_boards;
+ zatm_boards = dev;
+ ret = 0;
out:
+ return ret;
+
+out_release:
+ pci_release_regions(pci_dev);
+out_disable:
+ pci_disable_device(pci_dev);
+out_deregister:
+ atm_dev_deregister(dev);
+out_free:
kfree(zatm_dev);
-
- return 0;
+ goto out;
}
+
MODULE_LICENSE("GPL");
-module_init(zatm_module_init);
+static struct pci_device_id zatm_pci_tbl[] __devinitdata = {
+ { PCI_VENDOR_ID_ZEITNET, PCI_DEVICE_ID_ZEITNET_1221,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, ZATM_COPPER },
+ { PCI_VENDOR_ID_ZEITNET, PCI_DEVICE_ID_ZEITNET_1225,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+ { 0, }
+};
+MODULE_DEVICE_TABLE(pci, zatm_pci_tbl);
+
+static struct pci_driver zatm_driver = {
+ .name = DEV_LABEL,
+ .id_table = zatm_pci_tbl,
+ .probe = zatm_init_one,
+};
+
+static int __init zatm_init_module(void)
+{
+ return pci_module_init(&zatm_driver);
+}
+
+module_init(zatm_init_module);
/* module_exit not defined so not unloadable */