diff options
author | Dave Airlie <airlied@redhat.com> | 2009-08-04 09:10:46 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-08-04 09:11:43 +1000 |
commit | 2ce97c754ac1fa655d9201740b120255a060e770 (patch) | |
tree | f9e451d8288f4c15660ddb45f445500f5ca64e5d | |
parent | 2dd13517503c806dbf950c51072153cad2798a01 (diff) |
vbetool: port to pciaccess
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | vbetool.c | 42 |
2 files changed, 22 insertions, 22 deletions
diff --git a/Makefile.am b/Makefile.am index 07605b6..808a9d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = foreign sbin_PROGRAMS = vbetool -vbetool_LDADD = $(libdir)/libpci.a +vbetool_LDADD = $(VBETOOL_LIBS) -lpciaccess -lz man_MANS = vbetool.1 vbetool_SOURCES = vbetool.c $(x86) @@ -8,7 +8,7 @@ This program is released under the terms of the GNU General Public License, version 2 */ -#include <pci/pci.h> +#include <pciaccess.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -36,8 +36,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"); @@ -46,9 +44,7 @@ int vbetool_init (void) { iopl(3); - pacc = pci_alloc(); - pacc->numeric_ids = 1; - pci_init(pacc); + pci_system_init(); return 0; } @@ -220,25 +216,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; } |