MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / usb / net / Zydas / zdpci_pcmcia.c
blob383513b117b25d89706e0be4072a6190326efe81
1 #include <linux/version.h>
3 #ifdef MODVERSIONS
4 #include <linux/modversions.h>
5 #endif
7 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <pcmcia/driver_ops.h>
13 #include "zd1205.h"
14 #include "zddebug.h"
15 #include "zdpci_pcmcia.h"
16 #include "zdversion.h"
18 /******************************************************************************
19 Global variable definition section
20 ******************************************************************************/
21 MODULE_AUTHOR("Yarco Yang");
22 MODULE_DESCRIPTION("ZyDAS 802.11 Wireless LAN adapter");
23 MODULE_LICENSE("GPL");
25 extern struct net_device *g_dev;
27 struct driver_operations zdpci_ops =
29 "zd1205", zdpci_attach, zdpci_suspend, zdpci_resume, zdpci_detach
33 /******************************************************************************
34 Module initialization functions
35 ******************************************************************************/
36 dev_node_t *zdpci_attach(dev_locator_t * loc)
38 u32 io;
39 u16 dev_id;
40 u8 bus, devfn, irq, latency_tmr;
41 struct pci_dev *pci_device;
42 dev_node_t *node;
43 struct zd1205_private *macp;
45 // perform some initial setting checks
46 if (loc->bus != LOC_PCI)
47 return NULL;
49 bus = loc->b.pci.bus;
50 devfn = loc->b.pci.devfn;
52 // get some pci settings for verification
53 pcibios_read_config_dword(bus, devfn, PCI_BASE_ADDRESS_0, &io);
54 pcibios_read_config_byte(bus, devfn, PCI_INTERRUPT_LINE, &irq);
55 pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID, &dev_id);
57 // check whether the latency timer is set correctly
58 pcibios_read_config_byte(bus, devfn, PCI_LATENCY_TIMER, &latency_tmr);
60 if (io &= ~3, io == 0 || irq == 0)
62 printk(KERN_ERR "The interface was not assigned\n");
63 return NULL;
66 // get pci device information by loading the pci_dev structure
67 if (pci_device = pci_find_slot(bus, devfn), pci_device == NULL)
69 // error reading the pci device structure
70 printk(KERN_ERR "ERROR: %s could not get PCI device "
71 "information \n", DRIVER_NAME );
72 return NULL;
75 zd1205_found1(pci_device, NULL);
78 // finally setup the node structure with the device information
79 node = kmalloc(sizeof(dev_node_t), GFP_KERNEL);
80 strcpy(node->dev_name, macp->device->name);
81 node->major = 0;
82 node->minor = 0;
83 node->next = NULL;
84 MOD_INC_USE_COUNT;
85 return node;
88 void zdpci_suspend(dev_node_t * node)
93 void zdpci_resume(dev_node_t * node)
98 void zdpci_detach(dev_node_t * node)
100 struct zd1205_private *macp = g_dev->priv;
102 unregister_netdev(g_dev);
103 zd1205_remove_proc_subdir(macp);
104 zd1205_clear_structs(g_dev);
105 //--zd1205nics;
107 // free the node
108 kfree(node);
109 MOD_DEC_USE_COUNT;
113 int init_module(void)
115 printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID);
116 //register_driver(&zdpci_ops);
117 register_pcmcia_driver();
119 return 0;
123 void cleanup_module(void)
125 unregister_driver(&zdpci_ops);
127 printk(KERN_NOTICE "Unloaded %s \n", DRIVER_NAME);