Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 #include <linux/config.h>
  2 #include <linux/kernel.h>
  3 #include <linux/module.h>
  4 #include <linux/pci.h>
  5 #include <linux/init.h>
  6 
  7 
  8 static struct pci_device_id ids[] = {
  9         { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3), },
 10         { 0, }
 11 };
 12 MODULE_DEVICE_TABLE(pci, ids);
 13 
 14 static unsigned char skel_get_revision(struct pci_dev *dev)
 15 {
 16         u8 revision;
 17 
 18         pci_read_config_byte(dev, PCI_REVISION_ID, &revision);
 19         return revision;
 20 }
 21 
 22 static int probe(struct pci_dev *dev, const struct pci_device_id *id)
 23 {
 24         /* Do probing type stuff here.  
 25          * Like calling request_region();
 26          */
 27         pci_enable_device(dev);
 28         
 29         if (skel_get_revision(dev) == 0x42)
 30                 return -ENODEV;
 31 
 32 
 33         return 0;
 34 }
 35 
 36 static void remove(struct pci_dev *dev)
 37 {
 38         /* clean up any allocated resources and stuff here.
 39          * like call release_region();
 40          */
 41 }
 42 
 43 static struct pci_driver pci_driver = {
 44         .name = "pci_skel",
 45         .id_table = ids,
 46         .probe = probe,
 47         .remove = remove,
 48 };
 49 
 50 static int __init pci_skel_init(void)
 51 {
 52         return pci_register_driver(&pci_driver);
 53 }
 54 
 55 static void __exit pci_skel_exit(void)
 56 {
 57         pci_unregister_driver(&pci_driver);
 58 }
 59 
 60 MODULE_LICENSE("GPL");
 61 
 62 module_init(pci_skel_init);
 63 module_exit(pci_skel_exit);
 64 
  This page was automatically generated by the LXR engine.