nvme_manage: accept more PCI address formats

Change-Id: Ie8177b320271c9e7cb9b2216dbdd9c3c11f39579
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-03-10 16:09:06 -07:00
parent 73b0afa867
commit e3cabfafd7

View File

@ -244,7 +244,19 @@ get_controller(void)
p++;
}
sscanf(p, "%x:%x:%x.%x", &domain, &bus, &devid, &function);
if (sscanf(p, "%x:%x:%x.%x", &domain, &bus, &devid, &function) == 4) {
/* Matched a full address - all variables are initialized */
} else if (sscanf(p, "%x:%x:%x", &domain, &bus, &devid) == 3) {
function = 0;
} else if (sscanf(p, "%x:%x.%x", &bus, &devid, &function) == 3) {
domain = 0;
} else if (sscanf(p, "%x:%x", &bus, &devid) == 2) {
domain = 0;
function = 0;
} else {
return NULL;
}
pci_addr = (uint64_t)domain << 24;
pci_addr |= (uint64_t)bus << 16;
pci_addr |= (uint64_t)devid << 8;