[ltp] (no subject)
Martin Hauser
linux-thinkpad@linux-thinkpad.org
Fri, 8 Oct 2004 11:49:39 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi There,
> 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.....................
>
givin it a shot i maybe see a general mistake there... , see below
> #include<linux/pci.h>
> .................................
> ...............................
> .................................
>
> int pci_init( void )
> {
> struct pci_dev *pci_device = NULL;
a moment, to get this right, you declare something as NULL pointer...
and then you try below to use it? Or does pci_find_slot use this
pci_device pointer?
> 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);
this is where i guess your programm is segfaulting, right?
> printk("\nDevice ID\t%x",pci_device->device);
> printk("\nVendor ID\t%s",pci_device->name);
>
> return 0;
> }
I hope this helps, as said, just a shot
Happy Progging
Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBZmKyQhKguG3eJz0RAmERAKDA0e/tP4SW2ZgjhW4/K7iF6ZG6IQCgzBFT
bglqTcyJRzYjnczqmZUfjeg=
=gH4+
-----END PGP SIGNATURE-----