--- pulsar.c 2008/01/29 18:05:54 1.20
+++ pulsar.c 2010/05/25 18:03:27 1.22
@@ -25,6 +25,21 @@
// Wayne Peart - Our Globespan FAE
// Charles Michael Heard - CRC-10 routine
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+*/
#include
@@ -339,7 +354,7 @@
// PDEBUG("%X ",(unsigned int)oam_cell[i]);
// }
//#endif
- PDEBUG("oam_cell at address: %X\n", (unsigned int)oam_cell);
+// PDEBUG("oam_cell at address: %X\n", (unsigned int)oam_cell);
size = ATM_CELL_SIZE-1; //52 bytes
if (size > MAX_TX_DMA)
@@ -348,7 +363,7 @@
printk(KERN_WARNING "%s: Tx DMA truncated\n", name);
}
#ifdef DEBUG
- PDEBUG("oam_cell at address: %x\n", (unsigned int)oam_cell);
+// PDEBUG("oam_cell at address: %x\n", (unsigned int)oam_cell);
#endif
spin_lock(&oam_lock);
memcpy(txb, oam_cell, size);
@@ -356,7 +371,7 @@
oam_cell = NULL;
spin_unlock(&oam_lock);
#ifdef DEBUG
- PDEBUG("oam_cell at address: %X\n", (unsigned int)oam_cell);
+// PDEBUG("oam_cell at address: %X\n", (unsigned int)oam_cell);
#endif
// todo check for left overs
cell_ptr = (u32)txb;
@@ -548,7 +563,7 @@
}
else {
#ifdef DEBUG
- PDEBUG("oam_cell not NULL!\n");
+// PDEBUG("oam_cell not NULL!\n");
PDEBUG("Skipped memcpy\n");
#endif
}
@@ -950,7 +965,7 @@
}
memset(pmodem, 0, sizeof(MODEM_PTR));
- PDEBUG("oam_cell points to %p\n", oam_cell);
+// PDEBUG("oam_cell points to %p\n", oam_cell);
sprintf(name, "%s%d", PTAG, index);
@@ -1094,19 +1109,16 @@
/* Get MAC address */ // XXX: Todo
- /* Start training modem */
-
/* Create /proc/pulsar/pulsarX */
sprintf(proc_name, "driver/pulsar/pulsar%d", dev_number);
- pulsar_proc = create_proc_read_entry(proc_name, 0, NULL,pulsar_read_procmem,NULL);
- if (pulsar_proc == NULL){ //failed to create proc file, therefore directory /proc/driver/pulsar doesn't exist
- pulsar_dir = proc_mkdir("driver/pulsar", NULL); //create the missing directory
- pulsar_proc = create_proc_read_entry(proc_name, 0, NULL,pulsar_read_procmem,NULL); //try to create file again
- }
- if ((pulsar_proc == NULL) && (pulsar_dir != NULL)){
- remove_proc_entry("driver/pulsar",NULL); //still failed, so give up and remove directory.
+ pulsar_dir = proc_mkdir("driver/pulsar", NULL);
+ if (pulsar_dir) {
+ pulsar_proc = create_proc_read_entry(proc_name, 0, NULL, pulsar_read_procmem, NULL);
+ if (!pulsar_proc)
+ remove_proc_entry("driver/pulsar",NULL);
}
+ /* Start training modem */
start_training(pmodem);
err = 0;
goto pulsar_init_exit;
@@ -1128,6 +1140,9 @@
pci_disable_device(pci_dev);
pulsar_init_exit_free:
pci_set_drvdata(pci_dev, NULL);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+ pci_dev_put(pci_dev);
+#endif
kfree(txb);
kfree(oam_cell);
kfree(pmodem->handle);
@@ -1175,6 +1190,10 @@
#endif
pci_disable_device(pci_dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ pci_dev_put(pci_dev);
+#endif
+
//sarlib_close(vcc_list);
/* Remove /proc/driver/pulsar/pulsarX */
@@ -1191,12 +1210,11 @@
PDEBUG("May Crash Here\n");
kfree(txb);
kfree(oam_cell);
- PDEBUG("Freed oam_cell\n");
- PDEBUG("oam_cell = %p\n",oam_cell);
+// PDEBUG("Freed oam_cell\n");
+// PDEBUG("oam_cell = %p\n",oam_cell);
kfree(pmodem->handle);
kfree(pmodem);
-
}
#ifdef PULSAR_NEWPCISTYLE
@@ -1230,20 +1248,23 @@
printk(KERN_INFO "%s: PCI ADSL ATM Driver %s Lib %s loaded\n", PTAG, VERSION, getlibver());
+ printk(KERN_INFO "%s: Searching for card %d\n", PTAG, dev_number);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ while ((pci_dev = pci_get_device(VID, DID, pci_dev)) != NULL) {
+#else
while ((pci_dev = pci_find_device(VID, DID, pci_dev)) != NULL) {
+#endif
if (dev_found == dev_number) // we've found the one were looking for
- break;
+ return pulsar_init_one(pci_dev, NULL);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ pci_dev_put(pci_dev);
+#endif
dev_found++;
}
- printk(KERN_DEBUG "%s: dev_found = %d, dev_number = %d\n", PTAG, dev_found, dev_number);
-
- if ((pci_dev) && (dev_found == dev_number)) {
- return pulsar_init_one(pci_dev, NULL);
- } else {
- printk(KERN_ERR "%s: No PCI card found\n", PTAG);
- return -ENODEV;
- }
+ printk(KERN_ERR "%s: No card found\n", PTAG);
+ return -ENODEV;
#endif
}
@@ -1253,9 +1274,21 @@
pci_unregister_driver(&pulsar_driver);
#else
struct pci_dev *pci_dev = NULL;
+ int dev_found = 0;
- pci_dev = pci_find_device(VID, DID, pci_dev); // just one device at the moment
- pulsar_remove_one(pci_dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ while ((pci_dev = pci_get_device(VID, DID, pci_dev)) != NULL) {
+#else
+ while ((pci_dev = pci_find_device(VID, DID, pci_dev)) != NULL) {
+#endif
+ if (dev_found == dev_number)
+ pulsar_remove_one(pci_dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ else
+ pci_dev_put(pci_dev);
+#endif
+ dev_found++;
+ }
#endif
printk(KERN_INFO "%s: PCI ADSL ATM Driver %s Lib %s unloaded\n", PTAG, VERSION, getlibver());
}