]> xenbits.xensource.com Git - xen.git/commitdiff
drivers/pci: Get next capability without passing caps
authorJiqian Chen <Jiqian.Chen@amd.com>
Wed, 23 Apr 2025 07:42:08 +0000 (09:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 23 Apr 2025 07:42:08 +0000 (09:42 +0200)
Modify function pci_find_next_cap_ttl to support returning position
of next capability when size "n" is zero.

That can help caller to get next capability offset if caller just
has a information of current capability offset.

That will be used in a follow-on change.

Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/pci/pci.c

index edf5b9f7ae9f555ba9a9634223a0143db9b44c3e..acf4cebe42706c6d263bdc5fc540e1f2f0acd752 100644 (file)
@@ -55,6 +55,11 @@ unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned int pos,
 
         if ( id == 0xff )
             break;
+
+        if ( !n )
+            return pos;
+        ASSERT(caps);
+
         for ( i = 0; i < n; i++ )
         {
             if ( id == caps[i] )