]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
libpci: hwdb: Remove ID_SUBSYSTEM and ID_GEN_SUBSYSTEM usage from pci_id_hwdb_lookup()
authorPali Rohár <pali@kernel.org>
Sat, 30 Mar 2024 10:06:25 +0000 (11:06 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 5 Apr 2024 11:14:07 +0000 (13:14 +0200)
Currently used udev hwdb key "ID_MODEL_FROM_DATABASE" does not return
subsystem, but returns device name.

There is no udev hwdb key which returns subsystem or generic subsystem.
So remove ID_SUBSYSTEM and ID_GEN_SUBSYSTEM from pci_id_hwdb_lookup().

This change fixes issue that pci_id_hwdb_lookup() as subsystem name always
returned device name.

lib/names-hwdb.c

index 71e7229470eacfe341fd4a023c9583fe576785f1..b1f60522b39fb63063ac270a6c677de6999849ad 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 
 char *
-pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4)
+pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4 UNUSED)
 {
   char modalias[64];
   const char *key = NULL;
@@ -41,13 +41,16 @@ pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int
       key = "ID_MODEL_FROM_DATABASE";
       break;
     case ID_SUBSYSTEM:
-      sprintf(modalias, "pci:v%08Xd%08Xsv%08Xsd%08X*", id1, id2, id3, id4);
-      key = "ID_MODEL_FROM_DATABASE";
-      break;
+      /*
+       * There is no udev hwdb key which returns subsystem. Also note that query
+       * modalias "pci:v%08Xd%08Xsv%08Xsd%08X*" matches also hwdb device with
+       * modalias "pci:v%08Xd%08Xsv*sd*" (which is the default modalias), so
+       * there is no way to get information specific for the subsystem.
+       */
+      return NULL;
     case ID_GEN_SUBSYSTEM:
-      sprintf(modalias, "pci:v*d*sv%08Xsd%08X*", id1, id2);
-      key = "ID_MODEL_FROM_DATABASE";
-      break;
+      /* There is no udev hwdb key which returns generic subsystem. */
+      return NULL;
     case ID_CLASS:
       sprintf(modalias, "pci:v*d*sv*sd*bc%02X*", id1);
       key = "ID_PCI_CLASS_FROM_DATABASE";