diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2013-10-31 15:50:08 -0400 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-10-31 15:50:08 -0400 |
| commit | f36c493491df1c83d6fee03433dd9ceaf2563e8b (patch) | |
| tree | c6f505d1ef469efdad9d19bf9c22f7ac70cfae2d /drivers/pci | |
| parent | 605d240052473228bf0c8c051cad825fddb25502 (diff) | |
| parent | bf22c90fb190e837173d61368e3c80f5b78751a8 (diff) | |
Merge branch 'pci/gregkh-driver-core' into next
* pci/gregkh-driver-core:
PCI: Make pci_bus_attrs, pci_dev_attrs, dev_rescan_attr, dev_remove_attr, vga_attr static
PCI: convert bus code to use dev_groups
PCI: convert bus code to use drv_groups
PCI: convert bus code to use bus_groups
Diffstat (limited to 'drivers/pci')
| -rw-r--r-- | drivers/pci/pci-driver.c | 17 | ||||
| -rw-r--r-- | drivers/pci/pci-sysfs.c | 101 | ||||
| -rw-r--r-- | drivers/pci/pci.h | 4 |
3 files changed, 78 insertions, 44 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 98f7b9b89507..9f85960a62ed 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
| @@ -135,6 +135,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
| 135 | return retval; | 135 | return retval; |
| 136 | return count; | 136 | return count; |
| 137 | } | 137 | } |
| 138 | static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); | ||
| 138 | 139 | ||
| 139 | /** | 140 | /** |
| 140 | * store_remove_id - remove a PCI device ID from this driver | 141 | * store_remove_id - remove a PCI device ID from this driver |
| @@ -180,12 +181,14 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count) | |||
| 180 | return retval; | 181 | return retval; |
| 181 | return count; | 182 | return count; |
| 182 | } | 183 | } |
| 184 | static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); | ||
| 183 | 185 | ||
| 184 | static struct driver_attribute pci_drv_attrs[] = { | 186 | static struct attribute *pci_drv_attrs[] = { |
| 185 | __ATTR(new_id, S_IWUSR, NULL, store_new_id), | 187 | &driver_attr_new_id.attr, |
| 186 | __ATTR(remove_id, S_IWUSR, NULL, store_remove_id), | 188 | &driver_attr_remove_id.attr, |
| 187 | __ATTR_NULL, | 189 | NULL, |
| 188 | }; | 190 | }; |
| 191 | ATTRIBUTE_GROUPS(pci_drv); | ||
| 189 | 192 | ||
| 190 | /** | 193 | /** |
| 191 | * pci_match_id - See if a pci device matches a given pci_id table | 194 | * pci_match_id - See if a pci device matches a given pci_id table |
| @@ -1316,9 +1319,9 @@ struct bus_type pci_bus_type = { | |||
| 1316 | .probe = pci_device_probe, | 1319 | .probe = pci_device_probe, |
| 1317 | .remove = pci_device_remove, | 1320 | .remove = pci_device_remove, |
| 1318 | .shutdown = pci_device_shutdown, | 1321 | .shutdown = pci_device_shutdown, |
| 1319 | .dev_attrs = pci_dev_attrs, | 1322 | .dev_groups = pci_dev_groups, |
| 1320 | .bus_attrs = pci_bus_attrs, | 1323 | .bus_groups = pci_bus_groups, |
| 1321 | .drv_attrs = pci_drv_attrs, | 1324 | .drv_groups = pci_drv_groups, |
| 1322 | .pm = PCI_PM_OPS_PTR, | 1325 | .pm = PCI_PM_OPS_PTR, |
| 1323 | }; | 1326 | }; |
| 1324 | 1327 | ||
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7128cfdd64aa..82cc45867eaa 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 | } \ |
| 46 | static DEVICE_ATTR_RO(field) | ||
| 46 | 47 | ||
| 47 | pci_config_attr(vendor, "0x%04x\n"); | 48 | pci_config_attr(vendor, "0x%04x\n"); |
| 48 | pci_config_attr(device, "0x%04x\n"); | 49 | pci_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 | } |
| 77 | static DEVICE_ATTR_RW(broken_parity_status); | ||
| 76 | 78 | ||
| 77 | static ssize_t local_cpus_show(struct device *dev, | 79 | static 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 | 96 | static DEVICE_ATTR_RO(local_cpus); | |
| 95 | 97 | ||
| 96 | static ssize_t local_cpulist_show(struct device *dev, | 98 | static 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 | } |
| 115 | static 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 | } |
| 176 | static DEVICE_ATTR_RO(resource); | ||
| 173 | 177 | ||
| 174 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) | 178 | static 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 | } |
| 188 | static DEVICE_ATTR_RO(modalias); | ||
| 184 | 189 | ||
| 185 | static ssize_t is_enabled_store(struct device *dev, | 190 | static 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 | ||
| 211 | static ssize_t is_enabled_show(struct device *dev, | 216 | static 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 | } |
| 224 | static DEVICE_ATTR_RW(enabled); | ||
| 219 | 225 | ||
| 220 | #ifdef CONFIG_NUMA | 226 | #ifdef CONFIG_NUMA |
| 221 | static ssize_t | 227 | static 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 | } |
| 232 | static DEVICE_ATTR_RO(numa_node); | ||
| 226 | #endif | 233 | #endif |
| 227 | 234 | ||
| 228 | static ssize_t | 235 | static 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 | } |
| 242 | static DEVICE_ATTR_RO(dma_mask_bits); | ||
| 235 | 243 | ||
| 236 | static ssize_t | 244 | static ssize_t |
| 237 | consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr, | 245 | consistent_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 | } |
| 250 | static DEVICE_ATTR_RO(consistent_dma_mask_bits); | ||
| 242 | 251 | ||
| 243 | static ssize_t | 252 | static ssize_t |
| 244 | msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf) | 253 | msi_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 | } |
| 295 | static DEVICE_ATTR_RW(msi_bus); | ||
| 286 | 296 | ||
| 287 | static DEFINE_MUTEX(pci_remove_rescan_mutex); | 297 | static DEFINE_MUTEX(pci_remove_rescan_mutex); |
| 288 | static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf, | 298 | static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf, |
| @@ -302,10 +312,20 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf, | |||
| 302 | } | 312 | } |
| 303 | return count; | 313 | return count; |
| 304 | } | 314 | } |
| 315 | static BUS_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store); | ||
| 316 | |||
| 317 | static struct attribute *pci_bus_attrs[] = { | ||
| 318 | &bus_attr_rescan.attr, | ||
| 319 | NULL, | ||
| 320 | }; | ||
| 305 | 321 | ||
| 306 | struct bus_attribute pci_bus_attrs[] = { | 322 | static const struct attribute_group pci_bus_group = { |
| 307 | __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store), | 323 | .attrs = pci_bus_attrs, |
| 308 | __ATTR_NULL | 324 | }; |
| 325 | |||
| 326 | const struct attribute_group *pci_bus_groups[] = { | ||
| 327 | &pci_bus_group, | ||
| 328 | NULL, | ||
| 309 | }; | 329 | }; |
| 310 | 330 | ||
| 311 | static ssize_t | 331 | static ssize_t |
| @@ -325,8 +345,9 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr, | |||
| 325 | } | 345 | } |
| 326 | return count; | 346 | return count; |
| 327 | } | 347 | } |
| 328 | struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP), | 348 | static struct device_attribute dev_rescan_attr = __ATTR(rescan, |
| 329 | NULL, dev_rescan_store); | 349 | (S_IWUSR|S_IWGRP), |
| 350 | NULL, dev_rescan_store); | ||
| 330 | 351 | ||
| 331 | static void remove_callback(struct device *dev) | 352 | static void remove_callback(struct device *dev) |
| 332 | { | 353 | { |
| @@ -356,8 +377,9 @@ remove_store(struct device *dev, struct device_attribute *dummy, | |||
| 356 | count = ret; | 377 | count = ret; |
| 357 | return count; | 378 | return count; |
| 358 | } | 379 | } |
| 359 | struct device_attribute dev_remove_attr = __ATTR(remove, (S_IWUSR|S_IWGRP), | 380 | static struct device_attribute dev_remove_attr = __ATTR(remove, |
| 360 | NULL, remove_store); | 381 | (S_IWUSR|S_IWGRP), |
| 382 | NULL, remove_store); | ||
| 361 | 383 | ||
| 362 | static ssize_t | 384 | static ssize_t |
| 363 | dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, | 385 | dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, |
| @@ -404,6 +426,7 @@ static ssize_t d3cold_allowed_show(struct device *dev, | |||
| 404 | struct pci_dev *pdev = to_pci_dev(dev); | 426 | struct pci_dev *pdev = to_pci_dev(dev); |
| 405 | return sprintf (buf, "%u\n", pdev->d3cold_allowed); | 427 | return sprintf (buf, "%u\n", pdev->d3cold_allowed); |
| 406 | } | 428 | } |
| 429 | static DEVICE_ATTR_RW(d3cold_allowed); | ||
| 407 | #endif | 430 | #endif |
| 408 | 431 | ||
| 409 | #ifdef CONFIG_PCI_IOV | 432 | #ifdef CONFIG_PCI_IOV |
| @@ -489,30 +512,38 @@ static struct device_attribute sriov_numvfs_attr = | |||
| 489 | sriov_numvfs_show, sriov_numvfs_store); | 512 | sriov_numvfs_show, sriov_numvfs_store); |
| 490 | #endif /* CONFIG_PCI_IOV */ | 513 | #endif /* CONFIG_PCI_IOV */ |
| 491 | 514 | ||
| 492 | struct device_attribute pci_dev_attrs[] = { | 515 | static struct attribute *pci_dev_attrs[] = { |
| 493 | __ATTR_RO(resource), | 516 | &dev_attr_resource.attr, |
| 494 | __ATTR_RO(vendor), | 517 | &dev_attr_vendor.attr, |
| 495 | __ATTR_RO(device), | 518 | &dev_attr_device.attr, |
| 496 | __ATTR_RO(subsystem_vendor), | 519 | &dev_attr_subsystem_vendor.attr, |
| 497 | __ATTR_RO(subsystem_device), | 520 | &dev_attr_subsystem_device.attr, |
| 498 | __ATTR_RO(class), | 521 | &dev_attr_class.attr, |
| 499 | __ATTR_RO(irq), | 522 | &dev_attr_irq.attr, |
| 500 | __ATTR_RO(local_cpus), | 523 | &dev_attr_local_cpus.attr, |
| 501 | __ATTR_RO(local_cpulist), | 524 | &dev_attr_local_cpulist.attr, |
| 502 | __ATTR_RO(modalias), | 525 | &dev_attr_modalias.attr, |
| 503 | #ifdef CONFIG_NUMA | 526 | #ifdef CONFIG_NUMA |
| 504 | __ATTR_RO(numa_node), | 527 | &dev_attr_numa_node.attr, |
| 505 | #endif | 528 | #endif |
| 506 | __ATTR_RO(dma_mask_bits), | 529 | &dev_attr_dma_mask_bits.attr, |
| 507 | __ATTR_RO(consistent_dma_mask_bits), | 530 | &dev_attr_consistent_dma_mask_bits.attr, |
| 508 | __ATTR(enable, 0600, is_enabled_show, is_enabled_store), | 531 | &dev_attr_enabled.attr, |
| 509 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), | 532 | &dev_attr_broken_parity_status.attr, |
| 510 | broken_parity_status_show,broken_parity_status_store), | 533 | &dev_attr_msi_bus.attr, |
| 511 | __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), | ||
| 512 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) | 534 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) |
| 513 | __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store), | 535 | &dev_attr_d3cold_allowed.attr, |
| 514 | #endif | 536 | #endif |
| 515 | __ATTR_NULL, | 537 | NULL, |
| 538 | }; | ||
| 539 | |||
| 540 | static const struct attribute_group pci_dev_group = { | ||
| 541 | .attrs = pci_dev_attrs, | ||
| 542 | }; | ||
| 543 | |||
| 544 | const struct attribute_group *pci_dev_groups[] = { | ||
| 545 | &pci_dev_group, | ||
| 546 | NULL, | ||
| 516 | }; | 547 | }; |
| 517 | 548 | ||
| 518 | static struct attribute *pcibus_attrs[] = { | 549 | static struct attribute *pcibus_attrs[] = { |
| @@ -544,7 +575,7 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
| 544 | !!(pdev->resource[PCI_ROM_RESOURCE].flags & | 575 | !!(pdev->resource[PCI_ROM_RESOURCE].flags & |
| 545 | IORESOURCE_ROM_SHADOW)); | 576 | IORESOURCE_ROM_SHADOW)); |
| 546 | } | 577 | } |
| 547 | struct device_attribute vga_attr = __ATTR_RO(boot_vga); | 578 | static struct device_attribute vga_attr = __ATTR_RO(boot_vga); |
| 548 | 579 | ||
| 549 | static ssize_t | 580 | static ssize_t |
| 550 | pci_read_config(struct file *filp, struct kobject *kobj, | 581 | pci_read_config(struct file *filp, struct kobject *kobj, |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 8a00c063d7bc..9c91ecc1301b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
| @@ -153,10 +153,10 @@ 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 | } |
| 156 | extern struct device_attribute pci_dev_attrs[]; | 156 | extern const struct attribute_group *pci_dev_groups[]; |
| 157 | extern const struct attribute_group *pcibus_groups[]; | 157 | extern const struct attribute_group *pcibus_groups[]; |
| 158 | extern struct device_type pci_dev_type; | 158 | extern struct device_type pci_dev_type; |
| 159 | extern struct bus_attribute pci_bus_attrs[]; | 159 | extern const struct attribute_group *pci_bus_groups[]; |
| 160 | 160 | ||
| 161 | 161 | ||
| 162 | /** | 162 | /** |
