[patch] pciaccess check if device is boot VGA device

Dave Airlie airlied at redhat.com
Wed Mar 4 03:45:00 PST 2009


On Wed, 2009-03-04 at 12:01 +0100, Julien Cristau wrote:
> Hi,
> 
> is this going to be available in 2.6.30?

I've sent the patch to lkml + pci maintainer so we'll see how it goes,
but unless it gets bikeshedded I see no reason for it not to.

> 
> 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.

Oh good point,

Thanks,
Dave.
> 
> > +    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