[patch] pciaccess check if device is boot VGA device

Julien Cristau jcristau at debian.org
Wed Mar 4 03:01:48 PST 2009


Hi,

is this going to be available in 2.6.30?

On Wed, Mar  4, 2009 at 16:01:25 +1000, Dave Airlie wrote:

> +static int pci_device_linux_sysfs_boot_vga(struct pci_device *dev)
> +{
> +    char name[256];
> +    char reply[3];
> +    int fd, bytes_read;
> +    int ret = 0;
> +
> +    snprintf( name, 255, "%s/%04x:%02x:%02x.%1u/boot_vga",
> +	      SYS_BUS_PCI,
> +	      dev->domain,
> +	      dev->bus,
> +	      dev->dev,
> +	      dev->func );
> +    
> +    fd = open( name, O_RDWR );
> +    if (fd == -1)
> +       return 0;
> +

Maybe use O_RDONLY instead?  It doesn't matter for X, but it might for
other users.

> +    bytes_read = read(fd, reply, 1);
> +    if (bytes_read != 1)
> +	goto out;
> +    if (reply[0] == '1')
> +	ret = 1;
> +out:
> +    close(fd);
> +    return ret;
> +}

Cheers,
Julien


More information about the xorg-devel mailing list