aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2009-03-04 00:57:05 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-03-20 13:48:17 -0400
commit217f45de3d2f68b6d0b646bb4f2a155a71648396 (patch)
tree8994d8e8e76d5a339ba9e9e3f6403b8005083e11 /drivers/pci/pci-sysfs.c
parentdfadd9edff498d767008edc6b2a6e86a7a19934d (diff)
PCI: expose boot VGA device via sysfs.
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. Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 1c8929801400..ec7a175dcbaf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -241,6 +241,17 @@ struct device_attribute pci_dev_attrs[] = {
241}; 241};
242 242
243static ssize_t 243static ssize_t
244boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
245{
246 struct pci_dev *pdev = to_pci_dev(dev);
247
248 return sprintf(buf, "%u\n",
249 !!(pdev->resource[PCI_ROM_RESOURCE].flags &
250 IORESOURCE_ROM_SHADOW));
251}
252struct device_attribute vga_attr = __ATTR_RO(boot_vga);
253
254static ssize_t
244pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, 255pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr,
245 char *buf, loff_t off, size_t count) 256 char *buf, loff_t off, size_t count)
246{ 257{
@@ -899,18 +910,27 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
899 pdev->rom_attr = attr; 910 pdev->rom_attr = attr;
900 } 911 }
901 912
913 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
914 retval = device_create_file(&pdev->dev, &vga_attr);
915 if (retval)
916 goto err_rom_file;
917 }
918
902 /* add platform-specific attributes */ 919 /* add platform-specific attributes */
903 retval = pcibios_add_platform_entries(pdev); 920 retval = pcibios_add_platform_entries(pdev);
904 if (retval) 921 if (retval)
905 goto err_rom_file; 922 goto err_vga_file;
906 923
907 /* add sysfs entries for various capabilities */ 924 /* add sysfs entries for various capabilities */
908 retval = pci_create_capabilities_sysfs(pdev); 925 retval = pci_create_capabilities_sysfs(pdev);
909 if (retval) 926 if (retval)
910 goto err_rom_file; 927 goto err_vga_file;
911 928
912 return 0; 929 return 0;
913 930
931err_vga_file:
932 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
933 device_remove_file(&pdev->dev, &vga_attr);
914err_rom_file: 934err_rom_file:
915 if (rom_size) { 935 if (rom_size) {
916 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); 936 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);