aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-07 02:55:40 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-10-07 16:58:42 -0400
commit5136b2da770d53f026ab091f0423729ebf37a6b5 (patch)
tree9f5600f01406afb9c623f8cac369ada925e32b47 /drivers/pci
parent2229c1fbc5bd3bd7eb376285de159d086e79d58a (diff)
PCI: convert bus code to use dev_groups
The dev_attrs field of struct bus_type is going away soon, dev_groups should be used instead. This converts the PCI bus code to use the correct field. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c2
-rw-r--r--drivers/pci/pci-sysfs.c73
-rw-r--r--drivers/pci/pci.h2
3 files changed, 48 insertions, 29 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 38f3c0140dfb..9f85960a62ed 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1319,7 +1319,7 @@ struct bus_type pci_bus_type = {
1319 .probe = pci_device_probe, 1319 .probe = pci_device_probe,
1320 .remove = pci_device_remove, 1320 .remove = pci_device_remove,
1321 .shutdown = pci_device_shutdown, 1321 .shutdown = pci_device_shutdown,
1322 .dev_attrs = pci_dev_attrs, 1322 .dev_groups = pci_dev_groups,
1323 .bus_groups = pci_bus_groups, 1323 .bus_groups = pci_bus_groups,
1324 .drv_groups = pci_drv_groups, 1324 .drv_groups = pci_drv_groups,
1325 .pm = PCI_PM_OPS_PTR, 1325 .pm = PCI_PM_OPS_PTR,
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d8eb880bd1fc..618c06094295 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -42,7 +42,8 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
42 \ 42 \
43 pdev = to_pci_dev (dev); \ 43 pdev = to_pci_dev (dev); \
44 return sprintf (buf, format_string, pdev->field); \ 44 return sprintf (buf, format_string, pdev->field); \
45} 45} \
46static DEVICE_ATTR_RO(field)
46 47
47pci_config_attr(vendor, "0x%04x\n"); 48pci_config_attr(vendor, "0x%04x\n");
48pci_config_attr(device, "0x%04x\n"); 49pci_config_attr(device, "0x%04x\n");
@@ -73,6 +74,7 @@ static ssize_t broken_parity_status_store(struct device *dev,
73 74
74 return count; 75 return count;
75} 76}
77static DEVICE_ATTR_RW(broken_parity_status);
76 78
77static ssize_t local_cpus_show(struct device *dev, 79static ssize_t local_cpus_show(struct device *dev,
78 struct device_attribute *attr, char *buf) 80 struct device_attribute *attr, char *buf)
@@ -91,7 +93,7 @@ static ssize_t local_cpus_show(struct device *dev,
91 buf[len] = '\0'; 93 buf[len] = '\0';
92 return len; 94 return len;
93} 95}
94 96static DEVICE_ATTR_RO(local_cpus);
95 97
96static ssize_t local_cpulist_show(struct device *dev, 98static ssize_t local_cpulist_show(struct device *dev,
97 struct device_attribute *attr, char *buf) 99 struct device_attribute *attr, char *buf)
@@ -110,6 +112,7 @@ static ssize_t local_cpulist_show(struct device *dev,
110 buf[len] = '\0'; 112 buf[len] = '\0';
111 return len; 113 return len;
112} 114}
115static DEVICE_ATTR_RO(local_cpulist);
113 116
114/* 117/*
115 * PCI Bus Class Devices 118 * PCI Bus Class Devices
@@ -170,6 +173,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
170 } 173 }
171 return (str - buf); 174 return (str - buf);
172} 175}
176static DEVICE_ATTR_RO(resource);
173 177
174static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) 178static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
175{ 179{
@@ -181,10 +185,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
181 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), 185 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
182 (u8)(pci_dev->class)); 186 (u8)(pci_dev->class));
183} 187}
188static DEVICE_ATTR_RO(modalias);
184 189
185static ssize_t is_enabled_store(struct device *dev, 190static ssize_t enabled_store(struct device *dev,
186 struct device_attribute *attr, const char *buf, 191 struct device_attribute *attr, const char *buf,
187 size_t count) 192 size_t count)
188{ 193{
189 struct pci_dev *pdev = to_pci_dev(dev); 194 struct pci_dev *pdev = to_pci_dev(dev);
190 unsigned long val; 195 unsigned long val;
@@ -208,14 +213,15 @@ static ssize_t is_enabled_store(struct device *dev,
208 return result < 0 ? result : count; 213 return result < 0 ? result : count;
209} 214}
210 215
211static ssize_t is_enabled_show(struct device *dev, 216static ssize_t enabled_show(struct device *dev,
212 struct device_attribute *attr, char *buf) 217 struct device_attribute *attr, char *buf)
213{ 218{
214 struct pci_dev *pdev; 219 struct pci_dev *pdev;
215 220
216 pdev = to_pci_dev (dev); 221 pdev = to_pci_dev (dev);
217 return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt)); 222 return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
218} 223}
224static DEVICE_ATTR_RW(enabled);
219 225
220#ifdef CONFIG_NUMA 226#ifdef CONFIG_NUMA
221static ssize_t 227static ssize_t
@@ -223,6 +229,7 @@ numa_node_show(struct device *dev, struct device_attribute *attr, char *buf)
223{ 229{
224 return sprintf (buf, "%d\n", dev->numa_node); 230 return sprintf (buf, "%d\n", dev->numa_node);
225} 231}
232static DEVICE_ATTR_RO(numa_node);
226#endif 233#endif
227 234
228static ssize_t 235static ssize_t
@@ -232,6 +239,7 @@ dma_mask_bits_show(struct device *dev, struct device_attribute *attr, char *buf)
232 239
233 return sprintf (buf, "%d\n", fls64(pdev->dma_mask)); 240 return sprintf (buf, "%d\n", fls64(pdev->dma_mask));
234} 241}
242static DEVICE_ATTR_RO(dma_mask_bits);
235 243
236static ssize_t 244static ssize_t
237consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr, 245consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
@@ -239,6 +247,7 @@ consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
239{ 247{
240 return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask)); 248 return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask));
241} 249}
250static DEVICE_ATTR_RO(consistent_dma_mask_bits);
242 251
243static ssize_t 252static ssize_t
244msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf) 253msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -283,6 +292,7 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,
283 292
284 return count; 293 return count;
285} 294}
295static DEVICE_ATTR_RW(msi_bus);
286 296
287static DEFINE_MUTEX(pci_remove_rescan_mutex); 297static DEFINE_MUTEX(pci_remove_rescan_mutex);
288static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf, 298static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
@@ -414,6 +424,7 @@ static ssize_t d3cold_allowed_show(struct device *dev,
414 struct pci_dev *pdev = to_pci_dev(dev); 424 struct pci_dev *pdev = to_pci_dev(dev);
415 return sprintf (buf, "%u\n", pdev->d3cold_allowed); 425 return sprintf (buf, "%u\n", pdev->d3cold_allowed);
416} 426}
427static DEVICE_ATTR_RW(d3cold_allowed);
417#endif 428#endif
418 429
419#ifdef CONFIG_PCI_IOV 430#ifdef CONFIG_PCI_IOV
@@ -499,30 +510,38 @@ static struct device_attribute sriov_numvfs_attr =
499 sriov_numvfs_show, sriov_numvfs_store); 510 sriov_numvfs_show, sriov_numvfs_store);
500#endif /* CONFIG_PCI_IOV */ 511#endif /* CONFIG_PCI_IOV */
501 512
502struct device_attribute pci_dev_attrs[] = { 513struct attribute *pci_dev_attrs[] = {
503 __ATTR_RO(resource), 514 &dev_attr_resource.attr,
504 __ATTR_RO(vendor), 515 &dev_attr_vendor.attr,
505 __ATTR_RO(device), 516 &dev_attr_device.attr,
506 __ATTR_RO(subsystem_vendor), 517 &dev_attr_subsystem_vendor.attr,
507 __ATTR_RO(subsystem_device), 518 &dev_attr_subsystem_device.attr,
508 __ATTR_RO(class), 519 &dev_attr_class.attr,
509 __ATTR_RO(irq), 520 &dev_attr_irq.attr,
510 __ATTR_RO(local_cpus), 521 &dev_attr_local_cpus.attr,
511 __ATTR_RO(local_cpulist), 522 &dev_attr_local_cpulist.attr,
512 __ATTR_RO(modalias), 523 &dev_attr_modalias.attr,
513#ifdef CONFIG_NUMA 524#ifdef CONFIG_NUMA
514 __ATTR_RO(numa_node), 525 &dev_attr_numa_node.attr,
515#endif 526#endif
516 __ATTR_RO(dma_mask_bits), 527 &dev_attr_dma_mask_bits.attr,
517 __ATTR_RO(consistent_dma_mask_bits), 528 &dev_attr_consistent_dma_mask_bits.attr,
518 __ATTR(enable, 0600, is_enabled_show, is_enabled_store), 529 &dev_attr_enabled.attr,
519 __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), 530 &dev_attr_broken_parity_status.attr,
520 broken_parity_status_show,broken_parity_status_store), 531 &dev_attr_msi_bus.attr,
521 __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
522#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 532#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
523 __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store), 533 &dev_attr_d3cold_allowed.attr,
524#endif 534#endif
525 __ATTR_NULL, 535 NULL,
536};
537
538static const struct attribute_group pci_dev_group = {
539 .attrs = pci_dev_attrs,
540};
541
542const struct attribute_group *pci_dev_groups[] = {
543 &pci_dev_group,
544 NULL,
526}; 545};
527 546
528static struct attribute *pcibus_attrs[] = { 547static struct attribute *pcibus_attrs[] = {
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 607be58dd728..9c91ecc1301b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -153,7 +153,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
153 return (dev->no_d1d2 || parent_dstates); 153 return (dev->no_d1d2 || parent_dstates);
154 154
155} 155}
156extern struct device_attribute pci_dev_attrs[]; 156extern const struct attribute_group *pci_dev_groups[];
157extern const struct attribute_group *pcibus_groups[]; 157extern const struct attribute_group *pcibus_groups[];
158extern struct device_type pci_dev_type; 158extern struct device_type pci_dev_type;
159extern const struct attribute_group *pci_bus_groups[]; 159extern const struct attribute_group *pci_bus_groups[];