From 1fa90d5abecd896362e551b2bd2ec987d8f60a6b Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 4 Jan 2021 17:53:10 +0000 Subject: re-work PCI config setup API (#198) Split up vfu_pci_setup_config_hdr(): individual "helpers" like vfu_pci_set_id() are much simpler to use than making the user specify the values in header-formatted structs; and this way if we want to add additional helpers, we won't need to modify the existing functions. Signed-off-by: John Levon Reviewed-by: Thanos Makatos --- samples/gpio-pci-idio-16.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'samples/gpio-pci-idio-16.c') diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index 08f2cca..350d11f 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -75,9 +75,6 @@ main(int argc, char *argv[]) char opt; struct sigaction act = { .sa_handler = _sa_handler }; vfu_ctx_t *vfu_ctx; - vfu_pci_hdr_id_t id = { .vid = 0x494F, .did = 0x0DC8 }; - vfu_pci_hdr_ss_t ss = { .vid = 0x0, .sid = 0x0 }; - vfu_pci_hdr_cc_t cc = { { 0 } }; while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { @@ -114,13 +111,14 @@ main(int argc, char *argv[]) err(EXIT_FAILURE, "failed to setup log"); } - ret = vfu_pci_setup_config_hdr(vfu_ctx, id, ss, cc, - VFU_PCI_TYPE_CONVENTIONAL, 0); + ret = vfu_pci_init(vfu_ctx, VFU_PCI_TYPE_CONVENTIONAL, + PCI_HEADER_TYPE_NORMAL, 0); if (ret < 0) { - fprintf(stderr, "failed to setup pci header\n"); - goto out; + err(EXIT_FAILURE, "vfu_pci_init() failed"); } + vfu_pci_set_id(vfu_ctx, 0x494f, 0x0dc8, 0x0, 0x0); + ret = vfu_setup_region(vfu_ctx, VFU_PCI_DEV_BAR2_REGION_IDX, 0x100, &bar2_access, VFU_REGION_FLAG_RW, NULL, 0, -1); if (ret < 0) { -- cgit v1.1