]> Zhao Yanbai Git Server - minix.git/commitdiff
printconfig(8): print PCI sub-VID/DID when set 97/3397/1
authorDavid van Moolenbroek <david@minix3.org>
Mon, 16 Jan 2017 14:05:45 +0000 (14:05 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Thu, 16 Feb 2017 10:22:28 +0000 (10:22 +0000)
In order to allow for proper matching of available drivers to system
hardware, the output of this utility should reflect the full details
of the input from configuration files.  In particular, that includes
sub-IDs of PCI devices when those have been specified.

Change-Id: Iea24d72795cd714268dbdb95df998eb74de8f2bd

minix/commands/service/print.c

index 7f42396ba743918247bf250910712816eb026ce7..b8ba367b96345545a85e6adbe5ecccd5886a158f 100644 (file)
@@ -68,6 +68,7 @@ int main(int argc, char **argv)
 {
        struct rs_config config;
        const char *label;
+       uint16_t sub_vid, sub_did;
         int id;
 
        if(argc != 2) {
@@ -87,9 +88,25 @@ int main(int argc, char **argv)
                printstack();
                printf("%s %s ", KW_PCI, KW_DEVICE);
                for(id = 0; id < config.rs_start.rss_nr_pci_id; id++) {
-                       printf("%04X:%04X ",
-                               config.rs_start.rss_pci_id[id].vid,
-                               config.rs_start.rss_pci_id[id].did);
+                       sub_vid = config.rs_start.rss_pci_id[id].sub_vid;
+                       sub_did = config.rs_start.rss_pci_id[id].sub_did;
+                       /*
+                        * The PCI driver interprets each of these two fields
+                        * individually, so we must print them even if just one
+                        * of them is set.  Correct matching of just one of
+                        * the fields may be hard to do from a script though,
+                        * so driver writers are advised to specify either both
+                        * or neither of these two fields.
+                        */
+                       if (sub_vid != NO_SUB_VID || sub_did != NO_SUB_DID)
+                               printf("%04X:%04X/%04X:%04X ",
+                                       config.rs_start.rss_pci_id[id].vid,
+                                       config.rs_start.rss_pci_id[id].did,
+                                       sub_vid, sub_did);
+                       else
+                               printf("%04X:%04X ",
+                                       config.rs_start.rss_pci_id[id].vid,
+                                       config.rs_start.rss_pci_id[id].did);
                }
                printf("\n");
        }