pciaccess: make linux rom reading fallback optional
authorDave Airlie <airlied@redhat.com>
Wed, 5 Aug 2009 23:39:01 +0000 (09:39 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 5 Aug 2009 23:41:54 +0000 (09:41 +1000)
On kernels which have ROM files, the boot VGA rom file
will contain the 0xc0000 file anyways. If another card
is missing a rom file there is no need for this.

This is fallback is disabled by default, on the premise
that distro shipping this new a pciaccess will be running
on kernels with working rom support which is been upstream
for a long time

configure.ac
src/linux_sysfs.c

index c55112c..528e32b 100644 (file)
@@ -43,6 +43,14 @@ AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
        [Path to pci.ids file]), [pciids_path="$withval"])
 AC_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids])
 
+AC_ARG_ENABLE(linux-rom-fallback, AS_HELP_STRING([--enable-linux-rom-fallback],
+               [Enable support for falling back to /dev/mem for roms (default: enabled)]),
+               [LINUX_ROM=$enableval],[LINUX_ROM=no])
+
+if test "x$LINUX_ROM" = xyes; then
+       AC_DEFINE(LINUX_ROM, 1, [Linux ROM read fallback])
+fi
+
 use_zlib=no
 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],
        [Enable zlib support to read gzip compressed pci.ids]),
index 1ae9e52..7fcd327 100644 (file)
@@ -325,10 +325,15 @@ pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer )
     
     fd = open( name, O_RDWR );
     if ( fd == -1 ) {
+#ifdef LINUX_ROM
        /* If reading the ROM using sysfs fails, fall back to the old
         * /dev/mem based interface.
+        * disable this for newer kernels using configure
         */
        return pci_device_linux_devmem_read_rom(dev, buffer);
+#else
+       return errno;
+#endif
     }