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