aboutsummaryrefslogtreecommitdiff
path: root/src/hci
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-09-15 14:55:26 +0100
committerMichael Brown <mcb30@ipxe.org>2022-09-15 15:20:58 +0100
commit8fc3c26eae8d45a5391a39ee698817449299bd76 (patch)
tree445b50f927ca1bcf75f2e64f8ce1a76b67625a96 /src/hci
parent6459e3b7b18c0e6b200f5c5ad995660ca0e2dd43 (diff)
downloadipxe-8fc3c26eae8d45a5391a39ee698817449299bd76.zip
ipxe-8fc3c26eae8d45a5391a39ee698817449299bd76.tar.gz
ipxe-8fc3c26eae8d45a5391a39ee698817449299bd76.tar.bz2
[pci] Allow pci_find_next() to return non-zero PCI segments
Separate the return status code from the returned PCI bus:dev.fn address, in order to allow pci_find_next() to be used to find devices with a non-zero PCI segment number. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r--src/hci/commands/pci_cmd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/hci/commands/pci_cmd.c b/src/hci/commands/pci_cmd.c
index a2a811a..515798b 100644
--- a/src/hci/commands/pci_cmd.c
+++ b/src/hci/commands/pci_cmd.c
@@ -58,7 +58,7 @@ static int pciscan_exec ( int argc, char **argv ) {
struct named_setting setting;
struct pci_device pci;
unsigned long prev;
- int next;
+ uint32_t busdevfn;
int len;
int rc;
@@ -75,17 +75,15 @@ static int pciscan_exec ( int argc, char **argv ) {
if ( ( len = fetchn_setting ( setting.settings, &setting.setting,
NULL, &setting.setting, &prev ) ) < 0 ) {
/* Setting not yet defined: start searching from 00:00.0 */
- prev = 0;
+ busdevfn = 0;
} else {
/* Setting is defined: start searching from next location */
- prev++;
+ busdevfn = ( prev + 1 );
}
/* Find next existent PCI device */
- if ( ( next = pci_find_next ( &pci, prev ) ) < 0 ) {
- rc = next;
+ if ( ( rc = pci_find_next ( &pci, &busdevfn ) ) != 0 )
goto err_find_next;
- }
/* Apply default type if necessary. Use ":uint16" rather than
* ":busdevfn" to allow for easy inclusion within a
@@ -96,7 +94,7 @@ static int pciscan_exec ( int argc, char **argv ) {
/* Store setting */
if ( ( rc = storen_setting ( setting.settings, &setting.setting,
- next ) ) != 0 ) {
+ busdevfn ) ) != 0 ) {
printf ( "Could not store \"%s\": %s\n",
setting.setting.name, strerror ( rc ) );
goto err_store;