PCI: flexible modules.pcimap & pci.ids paths
authorErwan Velu <erwan.velu@free.fr>
Wed, 11 Mar 2009 20:28:25 +0000 (21:28 +0100)
committerErwan Velu <erwan.velu@free.fr>
Wed, 11 Mar 2009 20:28:25 +0000 (21:28 +0100)
While detecting the pci names, class name & kernel modules, it's
better to let the user choosing the path instead of the harcoded value
"/" is not always the wanted path

com32/include/sys/pci.h
com32/lib/pci/scan.c
com32/modules/pcitest.c

index 374ccf8..fad7250 100644 (file)
@@ -131,8 +131,8 @@ struct pci_domain *pci_scan(void);
 void free_pci_domain(struct pci_domain *domain);
 struct match * find_pci_device(const struct pci_domain *pci_domain,
                               struct match *list);
-int get_name_from_pci_ids(struct pci_domain *pci_domain);
-int get_module_name_from_pci_ids(struct pci_domain *pci_domain);
-int get_class_name_from_pci_ids(struct pci_domain *pci_domain);
+int get_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path);
+int get_module_name_from_pci_ids(struct pci_domain *pci_domain, char *modules_pcimap_path);
+int get_class_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path);
 
 #endif /* _SYS_PCI_H */
index 598ca9b..cfd9e65 100644 (file)
@@ -73,7 +73,7 @@ static int hex_to_int(char *hexa)
 
 /* Try to match any pci device to the appropriate kernel module */
 /* it uses the modules.pcimap from the boot device */
-int get_module_name_from_pci_ids(struct pci_domain *domain)
+int get_module_name_from_pci_ids(struct pci_domain *domain, char *modules_pcimap_path)
 {
   char line[MAX_LINE];
   char module_name[21]; // the module name field is 21 char long
@@ -100,7 +100,7 @@ int get_module_name_from_pci_ids(struct pci_domain *domain)
   }
 
   /* Opening the modules.pcimap (of a linux kernel) from the boot device */
-  f=fopen("modules.pcimap", "r");
+  f=fopen(modules_pcimap_path, "r");
   if (!f)
     return -ENOMODULESPCIMAP;
 
@@ -161,7 +161,7 @@ int get_module_name_from_pci_ids(struct pci_domain *domain)
 
 /* Try to match any pci device to the appropriate class name */
 /* it uses the pci.ids from the boot device */
-int get_class_name_from_pci_ids(struct pci_domain *domain)
+int get_class_name_from_pci_ids(struct pci_domain *domain, char *pciids_path)
 {
   char line[MAX_LINE];
   char class_name[PCI_CLASS_NAME_SIZE];
@@ -185,7 +185,7 @@ int get_class_name_from_pci_ids(struct pci_domain *domain)
   }
 
   /* Opening the pci.ids from the boot device */
-  f = fopen("pci.ids","r");
+  f = fopen(pciids_path,"r");
   if (!f)
     return -ENOPCIIDS;
 
@@ -251,7 +251,7 @@ int get_class_name_from_pci_ids(struct pci_domain *domain)
 
 /* Try to match any pci device to the appropriate vendor and product name */
 /* it uses the pci.ids from the boot device */
-int get_name_from_pci_ids(struct pci_domain *domain)
+int get_name_from_pci_ids(struct pci_domain *domain, char *pciids_path)
 {
   char line[MAX_LINE];
   char vendor[PCI_VENDOR_NAME_SIZE];
@@ -282,7 +282,7 @@ int get_name_from_pci_ids(struct pci_domain *domain)
   }
 
   /* Opening the pci.ids from the boot device */
-  f = fopen("pci.ids","r");
+  f = fopen(pciids_path,"r");
   if (!f)
     return -ENOPCIIDS;
 
index 2c71611..0064753 100644 (file)
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
 
   printf("PCI: Looking for device name\n");
   /* Assigning product & vendor name for each device*/
-  return_code=get_name_from_pci_ids(pci_domain);
+  return_code=get_name_from_pci_ids(pci_domain,"pci.ids");
   if (return_code == -ENOPCIIDS) {
          printf("PCI: ERROR !\n");
          printf("PCI: Unable to open pci.ids in the same directory as pcitest.c32.\n");
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
 
   printf("PCI: Resolving class names\n");
   /* Assigning class name for each device*/
-  return_code=get_class_name_from_pci_ids(pci_domain);
+  return_code=get_class_name_from_pci_ids(pci_domain,"pci.ids");
   if (return_code == -ENOPCIIDS) {
          printf("PCI: ERROR !\n");
          printf("PCI: Unable to open pci.ids in the same directory as pcitest.c32.\n");
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
 
   printf("PCI: Looking for Kernel modules\n");
   /* Detecting which kernel module should match each device */
-  return_code=get_module_name_from_pci_ids(pci_domain);
+  return_code=get_module_name_from_pci_ids(pci_domain,"modules.pcimap");
   if (return_code == -ENOMODULESPCIMAP) {
          printf("PCI: ERROR !\n");
          printf("PCI: Unable to open modules.pcimap in the same directory as pcitest.c32.\n");