Results 1 to 1 of 1
Hai friend,
I have a doubt in pci device driver program..In the following example program, when does the functions(probe and skel_get_revision) are called in this program..and how does the VenderID ...
- 04-29-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 18
How the functions are called in PCI DEVICE DRIVER Program
Hai friend,
I have a doubt in pci device driver program..In the following example program, when does the functions(probe and skel_get_revision) are called in this program..and how does the VenderID and DeviceID are assigned and also what is MODULE_DEVICE_TABLE in this program,plz give me ur detail explanation about my problems...
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
static struct pci_device_id ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3), },
{ 0, }
};
MODULE_DEVICE_TABLE(pci, ids);
static unsigned char skel_get_revision(struct pci_dev *dev)
{
printk (KERN_NOTICE "GET REVISION CALLED ");
u8 revision;
pci_read_config_byte(dev, PCI_REVISION_ID, &revision);
printk (KERN_NOTICE "EXIT CALLED %d",revision);
return revision;
}
static int probe(struct pci_dev *dev, const struct pci_device_id *id)
{
/* Do probing type stuff here.
* Like calling request_region();
*/
printk (KERN_NOTICE "PROBE CALLED");
pci_enable_device(dev);
if (skel_get_revision(dev) == 0x42)
return -ENODEV;
return 0;
}
static void remove(struct pci_dev *dev)
{
printk (KERN_NOTICE "REMOVE CALLED");
/* clean up any allocated resources and stuff here.
* like call release_region();
*/
}
static struct pci_driver pci_driver = {
.name = "pci_skel",
.id_table = ids,
.probe = probe,
.remove = remove,
};
static int __init pci_skel_init(void)
{
printk (KERN_NOTICE "Beyond-end write");
return pci_register_driver(&pci_driver);
}
static void __exit pci_skel_exit(void)
{
printk (KERN_NOTICE "EXIT CALLED");
pci_unregister_driver(&pci_driver);
}
MODULE_LICENSE("GPL");
module_init(pci_skel_init);
module_exit(pci_skel_exit);
Thanks in advance,
vivek


Reply With Quote