diff options
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 4e0acefb7565..84c350994b06 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/vgaarb.h> | 30 | #include <linux/vgaarb.h> |
31 | #include <linux/pm_runtime.h> | 31 | #include <linux/pm_runtime.h> |
32 | #include <linux/of.h> | ||
32 | #include "pci.h" | 33 | #include "pci.h" |
33 | 34 | ||
34 | static int sysfs_initialized; /* = 0 */ | 35 | static int sysfs_initialized; /* = 0 */ |
@@ -416,6 +417,20 @@ static ssize_t d3cold_allowed_show(struct device *dev, | |||
416 | static DEVICE_ATTR_RW(d3cold_allowed); | 417 | static DEVICE_ATTR_RW(d3cold_allowed); |
417 | #endif | 418 | #endif |
418 | 419 | ||
420 | #ifdef CONFIG_OF | ||
421 | static ssize_t devspec_show(struct device *dev, | ||
422 | struct device_attribute *attr, char *buf) | ||
423 | { | ||
424 | struct pci_dev *pdev = to_pci_dev(dev); | ||
425 | struct device_node *np = pci_device_to_OF_node(pdev); | ||
426 | |||
427 | if (np == NULL || np->full_name == NULL) | ||
428 | return 0; | ||
429 | return sprintf(buf, "%s", np->full_name); | ||
430 | } | ||
431 | static DEVICE_ATTR_RO(devspec); | ||
432 | #endif | ||
433 | |||
419 | #ifdef CONFIG_PCI_IOV | 434 | #ifdef CONFIG_PCI_IOV |
420 | static ssize_t sriov_totalvfs_show(struct device *dev, | 435 | static ssize_t sriov_totalvfs_show(struct device *dev, |
421 | struct device_attribute *attr, | 436 | struct device_attribute *attr, |
@@ -499,6 +514,45 @@ static struct device_attribute sriov_numvfs_attr = | |||
499 | sriov_numvfs_show, sriov_numvfs_store); | 514 | sriov_numvfs_show, sriov_numvfs_store); |
500 | #endif /* CONFIG_PCI_IOV */ | 515 | #endif /* CONFIG_PCI_IOV */ |
501 | 516 | ||
517 | static ssize_t driver_override_store(struct device *dev, | ||
518 | struct device_attribute *attr, | ||
519 | const char *buf, size_t count) | ||
520 | { | ||
521 | struct pci_dev *pdev = to_pci_dev(dev); | ||
522 | char *driver_override, *old = pdev->driver_override, *cp; | ||
523 | |||
524 | if (count > PATH_MAX) | ||
525 | return -EINVAL; | ||
526 | |||
527 | driver_override = kstrndup(buf, count, GFP_KERNEL); | ||
528 | if (!driver_override) | ||
529 | return -ENOMEM; | ||
530 | |||
531 | cp = strchr(driver_override, '\n'); | ||
532 | if (cp) | ||
533 | *cp = '\0'; | ||
534 | |||
535 | if (strlen(driver_override)) { | ||
536 | pdev->driver_override = driver_override; | ||
537 | } else { | ||
538 | kfree(driver_override); | ||
539 | pdev->driver_override = NULL; | ||
540 | } | ||
541 | |||
542 | kfree(old); | ||
543 | |||
544 | return count; | ||
545 | } | ||
546 | |||
547 | static ssize_t driver_override_show(struct device *dev, | ||
548 | struct device_attribute *attr, char *buf) | ||
549 | { | ||
550 | struct pci_dev *pdev = to_pci_dev(dev); | ||
551 | |||
552 | return sprintf(buf, "%s\n", pdev->driver_override); | ||
553 | } | ||
554 | static DEVICE_ATTR_RW(driver_override); | ||
555 | |||
502 | static struct attribute *pci_dev_attrs[] = { | 556 | static struct attribute *pci_dev_attrs[] = { |
503 | &dev_attr_resource.attr, | 557 | &dev_attr_resource.attr, |
504 | &dev_attr_vendor.attr, | 558 | &dev_attr_vendor.attr, |
@@ -521,6 +575,10 @@ static struct attribute *pci_dev_attrs[] = { | |||
521 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) | 575 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) |
522 | &dev_attr_d3cold_allowed.attr, | 576 | &dev_attr_d3cold_allowed.attr, |
523 | #endif | 577 | #endif |
578 | #ifdef CONFIG_OF | ||
579 | &dev_attr_devspec.attr, | ||
580 | #endif | ||
581 | &dev_attr_driver_override.attr, | ||
524 | NULL, | 582 | NULL, |
525 | }; | 583 | }; |
526 | 584 | ||
@@ -1255,11 +1313,6 @@ static struct bin_attribute pcie_config_attr = { | |||
1255 | .write = pci_write_config, | 1313 | .write = pci_write_config, |
1256 | }; | 1314 | }; |
1257 | 1315 | ||
1258 | int __weak pcibios_add_platform_entries(struct pci_dev *dev) | ||
1259 | { | ||
1260 | return 0; | ||
1261 | } | ||
1262 | |||
1263 | static ssize_t reset_store(struct device *dev, | 1316 | static ssize_t reset_store(struct device *dev, |
1264 | struct device_attribute *attr, const char *buf, | 1317 | struct device_attribute *attr, const char *buf, |
1265 | size_t count) | 1318 | size_t count) |
@@ -1375,11 +1428,6 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
1375 | pdev->rom_attr = attr; | 1428 | pdev->rom_attr = attr; |
1376 | } | 1429 | } |
1377 | 1430 | ||
1378 | /* add platform-specific attributes */ | ||
1379 | retval = pcibios_add_platform_entries(pdev); | ||
1380 | if (retval) | ||
1381 | goto err_rom_file; | ||
1382 | |||
1383 | /* add sysfs entries for various capabilities */ | 1431 | /* add sysfs entries for various capabilities */ |
1384 | retval = pci_create_capabilities_sysfs(pdev); | 1432 | retval = pci_create_capabilities_sysfs(pdev); |
1385 | if (retval) | 1433 | if (retval) |