diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-11-05 15:20:35 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-11-09 22:09:53 -0500 |
commit | 625e1d59a89f50bace376f429d8cf50347af75f7 (patch) | |
tree | 97c75014668c80a17a3133e2db7dd91b1c5ba004 /drivers/pci | |
parent | 4e15c46bdc4d5ea0e7991a05edbd807328d38a2c (diff) |
PCI: Use is_visible() with boot_vga attribute for pci_dev
Should make pci_create_sysfs_dev_files() simpler. Also fix possible
memleak in remove path.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 3d160aa608c1..fbbb97f28259 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -1303,29 +1303,20 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
1303 | pdev->rom_attr = attr; | 1303 | pdev->rom_attr = attr; |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { | ||
1307 | retval = device_create_file(&pdev->dev, &vga_attr); | ||
1308 | if (retval) | ||
1309 | goto err_rom_file; | ||
1310 | } | ||
1311 | |||
1312 | /* add platform-specific attributes */ | 1306 | /* add platform-specific attributes */ |
1313 | retval = pcibios_add_platform_entries(pdev); | 1307 | retval = pcibios_add_platform_entries(pdev); |
1314 | if (retval) | 1308 | if (retval) |
1315 | goto err_vga_file; | 1309 | goto err_rom_file; |
1316 | 1310 | ||
1317 | /* add sysfs entries for various capabilities */ | 1311 | /* add sysfs entries for various capabilities */ |
1318 | retval = pci_create_capabilities_sysfs(pdev); | 1312 | retval = pci_create_capabilities_sysfs(pdev); |
1319 | if (retval) | 1313 | if (retval) |
1320 | goto err_vga_file; | 1314 | goto err_rom_file; |
1321 | 1315 | ||
1322 | pci_create_firmware_label_files(pdev); | 1316 | pci_create_firmware_label_files(pdev); |
1323 | 1317 | ||
1324 | return 0; | 1318 | return 0; |
1325 | 1319 | ||
1326 | err_vga_file: | ||
1327 | if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) | ||
1328 | device_remove_file(&pdev->dev, &vga_attr); | ||
1329 | err_rom_file: | 1320 | err_rom_file: |
1330 | if (rom_size) { | 1321 | if (rom_size) { |
1331 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); | 1322 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); |
@@ -1413,12 +1404,20 @@ static int __init pci_sysfs_init(void) | |||
1413 | late_initcall(pci_sysfs_init); | 1404 | late_initcall(pci_sysfs_init); |
1414 | 1405 | ||
1415 | static struct attribute *pci_dev_dev_attrs[] = { | 1406 | static struct attribute *pci_dev_dev_attrs[] = { |
1407 | &vga_attr.attr, | ||
1416 | NULL, | 1408 | NULL, |
1417 | }; | 1409 | }; |
1418 | 1410 | ||
1419 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | 1411 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, |
1420 | struct attribute *a, int n) | 1412 | struct attribute *a, int n) |
1421 | { | 1413 | { |
1414 | struct device *dev = container_of(kobj, struct device, kobj); | ||
1415 | struct pci_dev *pdev = to_pci_dev(dev); | ||
1416 | |||
1417 | if (a == &vga_attr.attr) | ||
1418 | if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) | ||
1419 | return 0; | ||
1420 | |||
1422 | return a->mode; | 1421 | return a->mode; |
1423 | } | 1422 | } |
1424 | 1423 | ||