#include <stdlib.h>
#include <limits.h>
+#include "config.h"
#include "pciaccess.h"
#include "pciaccess_private.h"
parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match *match)
{
char *tok;
- char *input_sp, *count_sp, *pci_sp;
+ char *input_sp = NULL, *count_sp, *pci_sp;
char tmp[32];
tok = strtok_r(input,",",&input_sp);
if (dev->vgaarb_rsrc == new_vgaarb_rsrc)
return 0;
- len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(dev->vgaarb_rsrc));
+ len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(new_vgaarb_rsrc));
ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
if (ret == 0)
dev->vgaarb_rsrc = new_vgaarb_rsrc;
+
+ ret = read(pci_sys->vgaarb_fd, buf, BUFSIZE);
+ if (ret <= 0)
+ return -1;
+
+ parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, NULL);
+
return ret;
}