aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 4e0acefb7565..faa4ab554d68 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -499,6 +499,45 @@ static struct device_attribute sriov_numvfs_attr =
499 sriov_numvfs_show, sriov_numvfs_store); 499 sriov_numvfs_show, sriov_numvfs_store);
500#endif /* CONFIG_PCI_IOV */ 500#endif /* CONFIG_PCI_IOV */
501 501
502static ssize_t driver_override_store(struct device *dev,
503 struct device_attribute *attr,
504 const char *buf, size_t count)
505{
506 struct pci_dev *pdev = to_pci_dev(dev);
507 char *driver_override, *old = pdev->driver_override, *cp;
508
509 if (count > PATH_MAX)
510 return -EINVAL;
511
512 driver_override = kstrndup(buf, count, GFP_KERNEL);
513 if (!driver_override)
514 return -ENOMEM;
515
516 cp = strchr(driver_override, '\n');
517 if (cp)
518 *cp = '\0';
519
520 if (strlen(driver_override)) {
521 pdev->driver_override = driver_override;
522 } else {
523 kfree(driver_override);
524 pdev->driver_override = NULL;
525 }
526
527 kfree(old);
528
529 return count;
530}
531
532static ssize_t driver_override_show(struct device *dev,
533 struct device_attribute *attr, char *buf)
534{
535 struct pci_dev *pdev = to_pci_dev(dev);
536
537 return sprintf(buf, "%s\n", pdev->driver_override);
538}
539static DEVICE_ATTR_RW(driver_override);
540
502static struct attribute *pci_dev_attrs[] = { 541static struct attribute *pci_dev_attrs[] = {
503 &dev_attr_resource.attr, 542 &dev_attr_resource.attr,
504 &dev_attr_vendor.attr, 543 &dev_attr_vendor.attr,
@@ -521,6 +560,7 @@ static struct attribute *pci_dev_attrs[] = {
521#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 560#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
522 &dev_attr_d3cold_allowed.attr, 561 &dev_attr_d3cold_allowed.attr,
523#endif 562#endif
563 &dev_attr_driver_override.attr,
524 NULL, 564 NULL,
525}; 565};
526 566