[PATCH 5/6] xfree86: fbdevhw: remove secondary way to find fb PCI device

Tiago Vignatti tiago.vignatti at nokia.com
Mon May 31 06:16:55 PDT 2010


fbdevhw already relies in libpciaccess, which in turn relies in sysfs to probe
devices. If sysfs is reporting wrong values then we're doomed anyway. So we
totally rely on sys and this second suspicious way to match fb <-> PCI becomes
superfluous.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
I haven't test it though. Can someone please do so?

 hw/xfree86/fbdevhw/fbdevhw.c |   43 +-----------------------------------------
 1 files changed, 1 insertions(+), 42 deletions(-)

diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 1ea163b..60279ed 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -275,8 +275,7 @@ fbdev_open_pci(struct pci_device * pPci)
 {
     struct	fb_fix_screeninfo fix;
     char	filename[256];
-    int	fd,i,j;
-
+    int	fd,i;
 
     /* There are two ways to that we can determine which fb device is
      * associated with this PCI device.  The more modern way is to look in
@@ -310,46 +309,6 @@ fbdev_open_pci(struct pci_device * pPci)
 	}
     }
 
-
-    /* The other way is to examine the resources associated with each fb
-     * device and see if there is a match with the PCI device.  This technique
-     * has some problems on certain mixed 64-bit / 32-bit architectures.
-     * There is a flaw in the fb_fix_screeninfo structure in that it only
-     * returns the low 32-bits of the address of the resources associated with
-     * a device.  However, on a mixed architecture the base addresses of PCI
-     * devices, even for 32-bit applications, may be higher than 0x0f0000000.
-     */
-
-    for (i = 0; i < 8; i++) {
-	sprintf(filename,"/dev/fb%d",i);
-	if (-1 == (fd = open(filename,O_RDWR,0))) {
-	    xf86DrvMsg(-1, X_WARNING,
-		       "open %s: %s\n", filename, strerror(errno));
-	    continue;
-	}
-	if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)&fix)) {
-	    close(fd);
-	    continue;
-	}
-	for (j = 0; j < 6; j++) {
-	    const pciaddr_t res_start = pPci->regions[j].base_addr;
-	    const pciaddr_t res_end = res_start + pPci->regions[j].size;
-
-	    if ((0 != fix.smem_len &&
-		 (pciaddr_t) fix.smem_start >= res_start &&
-		 (pciaddr_t) fix.smem_start < res_end) ||
-		(0 != fix.mmio_len &&
-		 (pciaddr_t) fix.mmio_start >= res_start &&
-		 (pciaddr_t) fix.mmio_start < res_end))
-	      break;
-	}
-	if (j == 6) {
-	    close(fd);
-	    continue;
-	}
-	return fd;
-    }
-
     xf86DrvMsg(-1, X_ERROR,
 	       "Unable to find a valid framebuffer device\n");
     return -1;
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list