Re: PCI Device list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I think.....u can find the interfcae (IDE interface) to which the
STORAGE device is connected...not the device...

try this out...

static int __init i_m (void)
{
  struct pci_dev *dev = NULL, *cdev = NULL;
  struct pci_driver *ddev = NULL;
  if (!pci_present ())
    {
      printk ("No pci device present\n");
      return;
    }
  else
    printk ("pci present\n");

  while (1)
    {

      if ((dev = pci_find_device (PCI_ANY_ID, PCI_ANY_ID, dev)) == NULL)
{
  printk (" end of storage devices\n");
  break;
}
      else
{
  if ((dev->class >> 16 == PCI_BASE_CLASS_STORAGE))
    {
      printk ("%s  ", dev->name);
      printk ("%x ", dev->class);
      printk ("%s ", pci_get_drvdata (dev));
      ddev = dev->driver;
      if (ddev == NULL)   printk ("<null>\n");
      else    printk ("%s\n", ddev->name);
    }
}
    }

  return 0;
}

static void __exit c_m (void)
{
  printk ("\n*******************clean************\n");
}

module_init (i_m);
module_exit (c_m);

========
Regards
Megharaj.
========




On Tue, 2003-11-04 at 01:17, Usman S. Ansari wrote:
> I am trying to list of the pci devices of type storage, for which I have following code,
> the code does not find any device. I was expecting to see hard disk and/or drives. What am I doing
> wrong.
> 
> struct pci_dev *disk=NULL;
> while (1)
>    {
>     if ((disk = pci_find_class(PCI_BASE_CLASS_STORAGE, disk)) == NULL)
>        {
>         printk("End of storage devices\n");
>         break;
>        }
>     else
>        {
>         pci_read_config_word(disk, PCI_VENDOR_ID, &vid);
>         pci_read_config_word(disk, PCI_DEVICE_ID, &did);
>         printk("Vendor id = %d, Device id = %x\n", vid, did);
>         printk("Class = %d\n", disk->class);
>        }
> }
> 
> __________________________________
> Do you Yahoo!?
> Exclusive Video Premiere - Britney Spears
> http://launch.yahoo.com/promos/britneyspears/
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux