aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2011-05-12 20:11:40 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2011-05-21 15:17:13 -0400
commitdc2c2c9dd513dec6c17df04e8abff795e20a5271 (patch)
tree096e73fc6775edbe389c687df08f96bd85788d02 /drivers
parentb9d320fcb6259baffaeaf93a5fce252cd09333d6 (diff)
PCI/sysfs: move bus cpuaffinity to class dev_attrs
Requested by Greg KH to fix a race condition in the creating of PCI bus cpuaffinity files. Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/bus.c6
-rw-r--r--drivers/pci/pci-sysfs.c36
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/probe.c42
-rw-r--r--drivers/pci/remove.c2
5 files changed, 36 insertions, 52 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 69546e9213dd..1e2ad92a4752 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -163,12 +163,6 @@ int pci_bus_add_child(struct pci_bus *bus)
163 163
164 bus->is_added = 1; 164 bus->is_added = 1;
165 165
166 retval = device_create_file(&bus->dev, &dev_attr_cpuaffinity);
167 if (retval)
168 return retval;
169
170 retval = device_create_file(&bus->dev, &dev_attr_cpulistaffinity);
171
172 /* Create legacy_io and legacy_mem files for this bus */ 166 /* Create legacy_io and legacy_mem files for this bus */
173 pci_create_legacy_files(bus); 167 pci_create_legacy_files(bus);
174 168
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index c690abc0e5b8..7bcf12adced7 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -108,6 +108,40 @@ static ssize_t local_cpulist_show(struct device *dev,
108 return len; 108 return len;
109} 109}
110 110
111/*
112 * PCI Bus Class Devices
113 */
114static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
115 int type,
116 struct device_attribute *attr,
117 char *buf)
118{
119 int ret;
120 const struct cpumask *cpumask;
121
122 cpumask = cpumask_of_pcibus(to_pci_bus(dev));
123 ret = type ?
124 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) :
125 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
126 buf[ret++] = '\n';
127 buf[ret] = '\0';
128 return ret;
129}
130
131static inline ssize_t pci_bus_show_cpumaskaffinity(struct device *dev,
132 struct device_attribute *attr,
133 char *buf)
134{
135 return pci_bus_show_cpuaffinity(dev, 0, attr, buf);
136}
137
138static inline ssize_t pci_bus_show_cpulistaffinity(struct device *dev,
139 struct device_attribute *attr,
140 char *buf)
141{
142 return pci_bus_show_cpuaffinity(dev, 1, attr, buf);
143}
144
111/* show resources */ 145/* show resources */
112static ssize_t 146static ssize_t
113resource_show(struct device * dev, struct device_attribute *attr, char * buf) 147resource_show(struct device * dev, struct device_attribute *attr, char * buf)
@@ -370,6 +404,8 @@ struct device_attribute pcibus_dev_attrs[] = {
370#ifdef CONFIG_HOTPLUG 404#ifdef CONFIG_HOTPLUG
371 __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store), 405 __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store),
372#endif 406#endif
407 __ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL),
408 __ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL),
373 __ATTR_NULL, 409 __ATTR_NULL,
374}; 410};
375 411
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index dcf640ad8df6..4ee9e8a2607f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -157,8 +157,6 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
157} 157}
158extern struct device_attribute pci_dev_attrs[]; 158extern struct device_attribute pci_dev_attrs[];
159extern struct device_attribute pcibus_dev_attrs[]; 159extern struct device_attribute pcibus_dev_attrs[];
160extern struct device_attribute dev_attr_cpuaffinity;
161extern struct device_attribute dev_attr_cpulistaffinity;
162#ifdef CONFIG_HOTPLUG 160#ifdef CONFIG_HOTPLUG
163extern struct bus_attribute pci_bus_attrs[]; 161extern struct bus_attribute pci_bus_attrs[];
164#else 162#else
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c471295cd4b9..48849ffdd672 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -43,43 +43,6 @@ int no_pci_devices(void)
43EXPORT_SYMBOL(no_pci_devices); 43EXPORT_SYMBOL(no_pci_devices);
44 44
45/* 45/*
46 * PCI Bus Class Devices
47 */
48static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
49 int type,
50 struct device_attribute *attr,
51 char *buf)
52{
53 int ret;
54 const struct cpumask *cpumask;
55
56 cpumask = cpumask_of_pcibus(to_pci_bus(dev));
57 ret = type?
58 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) :
59 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
60 buf[ret++] = '\n';
61 buf[ret] = '\0';
62 return ret;
63}
64
65static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev,
66 struct device_attribute *attr,
67 char *buf)
68{
69 return pci_bus_show_cpuaffinity(dev, 0, attr, buf);
70}
71
72static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev,
73 struct device_attribute *attr,
74 char *buf)
75{
76 return pci_bus_show_cpuaffinity(dev, 1, attr, buf);
77}
78
79DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL);
80DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL);
81
82/*
83 * PCI Bus Class 46 * PCI Bus Class
84 */ 47 */
85static void release_pcibus_dev(struct device *dev) 48static void release_pcibus_dev(struct device *dev)
@@ -1456,9 +1419,6 @@ struct pci_bus * pci_create_bus(struct device *parent,
1456 error = device_register(&b->dev); 1419 error = device_register(&b->dev);
1457 if (error) 1420 if (error)
1458 goto class_dev_reg_err; 1421 goto class_dev_reg_err;
1459 error = device_create_file(&b->dev, &dev_attr_cpuaffinity);
1460 if (error)
1461 goto dev_create_file_err;
1462 1422
1463 /* Create legacy_io and legacy_mem files for this bus */ 1423 /* Create legacy_io and legacy_mem files for this bus */
1464 pci_create_legacy_files(b); 1424 pci_create_legacy_files(b);
@@ -1469,8 +1429,6 @@ struct pci_bus * pci_create_bus(struct device *parent,
1469 1429
1470 return b; 1430 return b;
1471 1431
1472dev_create_file_err:
1473 device_unregister(&b->dev);
1474class_dev_reg_err: 1432class_dev_reg_err:
1475 device_unregister(dev); 1433 device_unregister(dev);
1476dev_reg_err: 1434dev_reg_err:
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 176615e7231f..7f87beed35ac 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -73,8 +73,6 @@ void pci_remove_bus(struct pci_bus *pci_bus)
73 return; 73 return;
74 74
75 pci_remove_legacy_files(pci_bus); 75 pci_remove_legacy_files(pci_bus);
76 device_remove_file(&pci_bus->dev, &dev_attr_cpuaffinity);
77 device_remove_file(&pci_bus->dev, &dev_attr_cpulistaffinity);
78 device_unregister(&pci_bus->dev); 76 device_unregister(&pci_bus->dev);
79} 77}
80EXPORT_SYMBOL(pci_remove_bus); 78EXPORT_SYMBOL(pci_remove_bus);