* [PATCH] pci: expose boot VGA device via sysfs.
@ 2009-03-04 5:57 Dave Airlie
2009-03-06 17:57 ` Greg KH
2009-03-20 2:12 ` Jesse Barnes
0 siblings, 2 replies; 3+ messages in thread
From: Dave Airlie @ 2009-03-04 5:57 UTC (permalink / raw)
To: linux-kernel, jbarnes; +Cc: greg
X really would like to know which VGA device was considered the boot
device by the system. The x86 PCI fixups have support for discovering this
but we provide no way to expose it to userspace.
This adds a sysfs file per VGA class device which has the value 0 for
non the boot device or unknown, and 1 if the VGA device is the boot device.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/pci/pci-sysfs.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index dfc4e0d..52afb3a 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -241,6 +241,17 @@ struct device_attribute pci_dev_attrs[] = {
};
static ssize_t
+boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return sprintf(buf, "%u\n",
+ !!(pdev->resource[PCI_ROM_RESOURCE].flags &
+ IORESOURCE_ROM_SHADOW));
+}
+struct device_attribute vga_attr = __ATTR_RO(boot_vga);
+
+static ssize_t
pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
@@ -884,18 +895,27 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
pdev->rom_attr = attr;
}
+ if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
+ retval = device_create_file(&pdev->dev, &vga_attr);
+ if (retval)
+ goto err_rom_file;
+ }
+
/* add platform-specific attributes */
retval = pcibios_add_platform_entries(pdev);
if (retval)
- goto err_rom_file;
+ goto err_vga_file;
/* add sysfs entries for various capabilities */
retval = pci_create_capabilities_sysfs(pdev);
if (retval)
- goto err_rom_file;
+ goto err_vga_file;
return 0;
+err_vga_file:
+ if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+ device_remove_file(&pdev->dev, &vga_attr);
err_rom_file:
if (rom_size) {
sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
--
1.6.0.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] pci: expose boot VGA device via sysfs.
2009-03-04 5:57 [PATCH] pci: expose boot VGA device via sysfs Dave Airlie
@ 2009-03-06 17:57 ` Greg KH
2009-03-20 2:12 ` Jesse Barnes
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2009-03-06 17:57 UTC (permalink / raw)
To: Dave Airlie; +Cc: linux-kernel, jbarnes
On Wed, Mar 04, 2009 at 05:57:05AM +0000, Dave Airlie wrote:
>
> X really would like to know which VGA device was considered the boot
> device by the system. The x86 PCI fixups have support for discovering this
> but we provide no way to expose it to userspace.
>
> This adds a sysfs file per VGA class device which has the value 0 for
> non the boot device or unknown, and 1 if the VGA device is the boot device.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Looks good to me:
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pci: expose boot VGA device via sysfs.
2009-03-04 5:57 [PATCH] pci: expose boot VGA device via sysfs Dave Airlie
2009-03-06 17:57 ` Greg KH
@ 2009-03-20 2:12 ` Jesse Barnes
1 sibling, 0 replies; 3+ messages in thread
From: Jesse Barnes @ 2009-03-20 2:12 UTC (permalink / raw)
To: Dave Airlie; +Cc: linux-kernel, greg
On Wed, 4 Mar 2009 05:57:05 +0000 (GMT)
Dave Airlie <airlied@linux.ie> wrote:
>
> X really would like to know which VGA device was considered the boot
> device by the system. The x86 PCI fixups have support for discovering
> this but we provide no way to expose it to userspace.
>
> This adds a sysfs file per VGA class device which has the value 0 for
> non the boot device or unknown, and 1 if the VGA device is the boot
> device.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Applied to my linux-next branch, thanks.
--
Jesse Barnes, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-20 2:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-04 5:57 [PATCH] pci: expose boot VGA device via sysfs Dave Airlie
2009-03-06 17:57 ` Greg KH
2009-03-20 2:12 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox