Find the answer to your Linux question:
Results 1 to 2 of 2
Hi 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 ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    5

    How the functions are called in PCI DEVICE DRIVER Program

    Hi 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,
    Vipin

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Please move this question to The Linux Kernel thread.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...