1 #include <linux/version.h>
4 #include <linux/modversions.h>
7 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <pcmcia/driver_ops.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
)
40 u8 bus
, devfn
, irq
, latency_tmr
;
41 struct pci_dev
*pci_device
;
43 struct zd1205_private
*macp
;
45 // perform some initial setting checks
46 if (loc
->bus
!= LOC_PCI
)
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");
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
);
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
);
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
);
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();
123 void cleanup_module(void)
125 unregister_driver(&zdpci_ops
);
127 printk(KERN_NOTICE
"Unloaded %s \n", DRIVER_NAME
);