summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-08-03 09:39:22 +1000
committerDave Airlie <airlied@redhat.com>2009-08-03 09:39:22 +1000
commit3a6c1be79c05517cfddbce88157bb352237058ab (patch)
tree11d255b8f0c75e4c1c26d4f6238cedd59f782a7e
parente5127339c6c48ae6f63f9dc841a94fe960d11496 (diff)
downloadxorg-lib-libpciaccess-3a6c1be79c05517cfddbce88157bb352237058ab.tar.gz
vgaarb: more api changes + cleanup
add a comma for ease of parsing, use hex on the interface in both directions instead of hex on one and decimal on the other
-rw-r--r--src/common_vgaarb.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index 5d46d70..1978ce3 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -42,15 +42,20 @@ static int
parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match *match)
{
char *tok;
- char count[16];
+ char *input_sp, *count_sp, *pci_sp;
+ char tmp[32];
- strncpy(count, input, 10);
- count[11] = 0;
+ tok = strtok_r(input,",",&input_sp);
+ if (!tok)
+ goto fail;
+
+ strncpy(tmp, input, 15);
+ tmp[15] = 0;
- tok = strtok(count,":");
+ tok = strtok_r(tmp,":",&count_sp);
if (!tok)
goto fail;
- tok = strtok(NULL, "");
+ tok = strtok_r(NULL, ":",&count_sp);
if (!tok)
goto fail;
@@ -62,39 +67,44 @@ parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match
fprintf(stderr,"vga count is %d\n", *vga_count);
#endif
- tok = strtok(input, ",");
+ tok = strtok_r(NULL, ",",&input_sp);
if (!tok)
goto fail;
if (match) {
- tok = strtok(NULL, ":");
+ strncpy(tmp, tok, 32);
+ tmp[31] = 0;
+ tok = strtok_r(tmp, ":", &pci_sp);
+ if (!tok)
+ goto fail;
+ tok = strtok_r(NULL, ":", &pci_sp);
if (!tok)
goto fail;
match->domain = strtoul(tok, NULL, 16);
- tok = strtok(NULL, ":");
+ tok = strtok_r(NULL, ":", &pci_sp);
if (!tok)
goto fail;
match->bus = strtoul(tok, NULL, 16);
- tok = strtok(NULL, ".");
+ tok = strtok_r(NULL, ".", &pci_sp);
if (!tok)
goto fail;
match->dev = strtoul(tok, NULL, 16);
- tok = strtok(NULL, ".");
+ tok = strtok_r(NULL, ".", &pci_sp);
if (!tok)
goto fail;
match->func = strtoul(tok, NULL, 16);
}
- tok = strtok(NULL, ",");
+ tok = strtok_r(NULL, ",",&input_sp);
if (!tok)
goto fail;
- tok = strtok(tok, "=");
+ tok = strtok_r(tok, "=", &input_sp);
if (!tok)
goto fail;
- tok = strtok(NULL, "=");
+ tok = strtok_r(NULL, "=", &input_sp);
if (!tok)
goto fail;
@@ -213,7 +223,7 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
if (!dev)
return -1;
- len = snprintf(buf, BUFSIZE, "target PCI:%d:%d:%d.%d",
+ len = snprintf(buf, BUFSIZE, "target PCI:%04x:%02x:%02x.%x",
dev->domain, dev->bus, dev->dev, dev->func);
ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);