diff options
author | Yijing Wang <wangyijing@huawei.com> | 2013-09-30 03:02:38 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-10-07 17:12:46 -0400 |
commit | c489f5fbb1f5a770f98e492af5c47befb32890cd (patch) | |
tree | 171e6ae2cc4de91c7aaa04eaaed98aca23e404ee /drivers/pci/pci-sysfs.c | |
parent | 135530d584bafa88bcb924552fb13bcab07ca1a5 (diff) |
PCI: Add pci_dev_show_local_cpu() to simplify code
local_cpus_show() and local_cpulist_show() are almost the same.
This adds a new helper function, pci_dev_show_local_cpu(), to simplify
code.
The same strategy is already used by cpuaffinity_show() and
cpulistaffinity_show().
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7128cfdd64aa..d9252dd89ea9 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -74,9 +74,11 @@ static ssize_t broken_parity_status_store(struct device *dev, | |||
74 | return count; | 74 | return count; |
75 | } | 75 | } |
76 | 76 | ||
77 | static ssize_t local_cpus_show(struct device *dev, | 77 | static ssize_t pci_dev_show_local_cpu(struct device *dev, |
78 | struct device_attribute *attr, char *buf) | 78 | int type, |
79 | { | 79 | struct device_attribute *attr, |
80 | char *buf) | ||
81 | { | ||
80 | const struct cpumask *mask; | 82 | const struct cpumask *mask; |
81 | int len; | 83 | int len; |
82 | 84 | ||
@@ -86,29 +88,25 @@ static ssize_t local_cpus_show(struct device *dev, | |||
86 | #else | 88 | #else |
87 | mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); | 89 | mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); |
88 | #endif | 90 | #endif |
89 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); | 91 | len = type ? |
92 | cpumask_scnprintf(buf, PAGE_SIZE-2, mask) : | ||
93 | cpulist_scnprintf(buf, PAGE_SIZE-2, mask); | ||
94 | |||
90 | buf[len++] = '\n'; | 95 | buf[len++] = '\n'; |
91 | buf[len] = '\0'; | 96 | buf[len] = '\0'; |
92 | return len; | 97 | return len; |
93 | } | 98 | } |
94 | 99 | ||
100 | static ssize_t local_cpus_show(struct device *dev, | ||
101 | struct device_attribute *attr, char *buf) | ||
102 | { | ||
103 | return pci_dev_show_local_cpu(dev, 1, attr, buf); | ||
104 | } | ||
95 | 105 | ||
96 | static ssize_t local_cpulist_show(struct device *dev, | 106 | static ssize_t local_cpulist_show(struct device *dev, |
97 | struct device_attribute *attr, char *buf) | 107 | struct device_attribute *attr, char *buf) |
98 | { | 108 | { |
99 | const struct cpumask *mask; | 109 | return pci_dev_show_local_cpu(dev, 0, attr, buf); |
100 | int len; | ||
101 | |||
102 | #ifdef CONFIG_NUMA | ||
103 | mask = (dev_to_node(dev) == -1) ? cpu_online_mask : | ||
104 | cpumask_of_node(dev_to_node(dev)); | ||
105 | #else | ||
106 | mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); | ||
107 | #endif | ||
108 | len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask); | ||
109 | buf[len++] = '\n'; | ||
110 | buf[len] = '\0'; | ||
111 | return len; | ||
112 | } | 110 | } |
113 | 111 | ||
114 | /* | 112 | /* |