Commit 8a54ecac authored by garcialasheras's avatar garcialasheras Committed by Federico Vaga

tools: ascending order PCI scan

parent e84a063d
......@@ -83,18 +83,19 @@ static int spec_check_id(int bus, int dev)
static int spec_scan(int *bus, int *devfn)
{
struct dirent **namelist;
int n, found = 0;
int n, i, found = 0;
int my_bus, my_devfn;
// Automatic search for the first availabe card
n = scandir("/sys/bus/pci/devices/", &namelist, 0, 0);
if (n < 0)
{
perror("scandir");
exit(-1);
} else {
while (n--)
for(i = 0; i < n; i++)
{
if(!found && sscanf(namelist[n]->d_name,
if(!found && sscanf(namelist[i]->d_name,
"0000:%02x:%02x.0",
&my_bus, &my_devfn) == 2)
{
......@@ -108,7 +109,7 @@ static int spec_scan(int *bus, int *devfn)
}
}
free(namelist[n]);
free(namelist[i]);
}
free(namelist);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment