From ce8a0280e32e91391f18ca018f0ace40d925e79c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 19 Dec 2009 20:13:02 +0200 Subject: vbetool: port to pciaccess Signed-off-by: Tiago Vignatti --- Makefile.am | 2 +- vbetool.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7060c25..4d7c949 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ sbin_PROGRAMS = vbetool -vbetool_LDADD = $(libdir)/libpci.a $(LIBX86_LIBS) -lz +vbetool_LDADD = $(LIBX86_LIBS) -lpciaccess -lz vbetool_CFLAGS = $(LIBX86_CFLAGS) vbetool_SOURCES = vbetool.c noinst_HEADERS = vbetool.h diff --git a/vbetool.c b/vbetool.c index ffc42bb..a4a6d41 100644 --- a/vbetool.c +++ b/vbetool.c @@ -11,7 +11,7 @@ version 2 #include #include -#include +#include #include #include #include @@ -38,8 +38,6 @@ version 2 #define DPMS_STATE_OFF 0x0400 #define DPMS_STATE_LOW 0x0800 -static struct pci_access *pacc; - int vbetool_init (void) { if (!LRMI_init()) { fprintf(stderr, "Failed to initialise LRMI (Linux Real-Mode Interface).\n"); @@ -48,9 +46,7 @@ int vbetool_init (void) { iopl(3); - pacc = pci_alloc(); - pacc->numeric_ids = 1; - pci_init(pacc); + pci_system_init(); return 0; } @@ -222,25 +218,29 @@ int do_real_post(unsigned pci_device) int do_post(void) { - struct pci_dev *p; - unsigned int c; - unsigned int pci_id; int error; + struct pci_id_match dev_match = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + (0x03 << 16), 0xff000, 0 }; + struct pci_device *dev; + struct pci_device_iterator *iter; + unsigned pci_id; + + iter = pci_id_match_iterator_create(&dev_match); + if (iter == NULL) { + return 1; + } - pci_scan_bus(pacc); - - for (p = pacc->devices; p; p = p->next) { - c = pci_read_word(p, PCI_CLASS_DEVICE); - if (c == 0x300) { - pci_id = - (p->bus << 8) + (p->dev << 3) + - (p->func & 0x7); - error = do_real_post(pci_id); - if (error != 0) { - return error; - } + while ((dev = pci_device_next(iter)) != NULL) { + pci_id = (dev->bus << 8) + (dev->dev << 3) + + (dev->func & 0x7); + + error = do_real_post(pci_id); + if (error != 0) { + return error; } } + pci_iterator_destroy(iter); return 0; } -- cgit v1.2.3