[ltp] Segmentation fault in PCI module

sensors linux-thinkpad@linux-thinkpad.org
Thu, 07 Oct 2004 08:40:03 +0000


Hi All
 
I have written a piece of code to detect a pci device, but it is causing  segmentation fault. What might have gone wrong in the code..........
Can any body please help me out with this.....................
 
#include<linux/pci.h>
 .................................
 ...............................
 .................................
 
int pci_init( void )
{
        struct pci_dev *pci_device = NULL;
        printk("\n Inside pci_init\n");
 
        if( !pci_present() )
        {
                printk("\nPCI not supported\n");
                return 0;
        }
 
        if(( pci_find_slot(1, PCI_DEVFN( 9, 0))) == NULL)
        {
                printk("\n Device not foumd\n");
                return 0;  
      }
 

                printk("\nVendor ID\t%x",pci_device->vendor);
                printk("\nDevice ID\t%x",pci_device->device);
                printk("\nVendor ID\t%s",pci_device->name);

                return 0;
}
 
Thanks in advance...........