Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pci/portdrv'

- Drop device reference unconditionally in pcie_port_remove_service() to
fix resource leak (Uwe Kleine-König)

- Remove empty pcie_port_shutdown_service() callback (Uwe Kleine-König)

- Remove unnecessary bus_type check in pcie_port_bus_match() (Uwe
Kleine-König)

- Move pcie_port_bus_match() and pcie_port_bus_type to PCIe-specific
portdrv.c (Uwe Kleine-König)

- Remove unnecessary dev and dev->driver checks in portdrv .probe() and
.remove() (Uwe Kleine-König)

- Take advantage of pcie_port_bus_type.probe() and .remove() instead of
assigning them for each portdrv service driver (Uwe Kleine-König)

* pci/portdrv:
PCI/portdrv: Use bus-type functions
PCI/portdrv: Don't check for valid device and driver in bus callbacks
PCI/portdrv: Move pcie_port_bus_type to pcie source file
PCI/portdrv: Don't check for the driver's and device's bus
PCI/portdrv: Drop empty shutdown callback
PCI/portdrv: Fix potential resource leak

+28 -55
-28
drivers/pci/pci-driver.c
··· 1701 1701 }; 1702 1702 EXPORT_SYMBOL(pci_bus_type); 1703 1703 1704 - #ifdef CONFIG_PCIEPORTBUS 1705 - static int pcie_port_bus_match(struct device *dev, const struct device_driver *drv) 1706 - { 1707 - struct pcie_device *pciedev; 1708 - const struct pcie_port_service_driver *driver; 1709 - 1710 - if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type) 1711 - return 0; 1712 - 1713 - pciedev = to_pcie_device(dev); 1714 - driver = to_service_driver(drv); 1715 - 1716 - if (driver->service != pciedev->service) 1717 - return 0; 1718 - 1719 - if (driver->port_type != PCIE_ANY_PORT && 1720 - driver->port_type != pci_pcie_type(pciedev->port)) 1721 - return 0; 1722 - 1723 - return 1; 1724 - } 1725 - 1726 - const struct bus_type pcie_port_bus_type = { 1727 - .name = "pci_express", 1728 - .match = pcie_port_bus_match, 1729 - }; 1730 - #endif 1731 - 1732 1704 static int __init pci_driver_init(void) 1733 1705 { 1734 1706 int ret;
+28 -27
drivers/pci/pcie/portdrv.c
··· 508 508 pci_free_irq_vectors(dev); 509 509 } 510 510 511 + static int pcie_port_bus_match(struct device *dev, const struct device_driver *drv) 512 + { 513 + struct pcie_device *pciedev = to_pcie_device(dev); 514 + const struct pcie_port_service_driver *driver = to_service_driver(drv); 515 + 516 + if (driver->service != pciedev->service) 517 + return 0; 518 + 519 + if (driver->port_type != PCIE_ANY_PORT && 520 + driver->port_type != pci_pcie_type(pciedev->port)) 521 + return 0; 522 + 523 + return 1; 524 + } 525 + 511 526 /** 512 - * pcie_port_probe_service - probe driver for given PCI Express port service 527 + * pcie_port_bus_probe - probe driver for given PCI Express port service 513 528 * @dev: PCI Express port service device to probe against 514 529 * 515 530 * If PCI Express port service driver is registered with 516 531 * pcie_port_service_register(), this function will be called by the driver core 517 532 * whenever match is found between the driver and a port service device. 518 533 */ 519 - static int pcie_port_probe_service(struct device *dev) 534 + static int pcie_port_bus_probe(struct device *dev) 520 535 { 521 536 struct pcie_device *pciedev; 522 537 struct pcie_port_service_driver *driver; 523 538 int status; 524 - 525 - if (!dev || !dev->driver) 526 - return -ENODEV; 527 539 528 540 driver = to_service_driver(dev->driver); 529 541 if (!driver || !driver->probe) ··· 551 539 } 552 540 553 541 /** 554 - * pcie_port_remove_service - detach driver from given PCI Express port service 542 + * pcie_port_bus_remove - detach driver from given PCI Express port service 555 543 * @dev: PCI Express port service device to handle 556 544 * 557 545 * If PCI Express port service driver is registered with ··· 559 547 * when device_unregister() is called for the port service device associated 560 548 * with the driver. 561 549 */ 562 - static int pcie_port_remove_service(struct device *dev) 550 + static void pcie_port_bus_remove(struct device *dev) 563 551 { 564 552 struct pcie_device *pciedev; 565 553 struct pcie_port_service_driver *driver; 566 554 567 - if (!dev || !dev->driver) 568 - return 0; 569 - 570 555 pciedev = to_pcie_device(dev); 571 556 driver = to_service_driver(dev->driver); 572 - if (driver && driver->remove) { 557 + if (driver && driver->remove) 573 558 driver->remove(pciedev); 574 - put_device(dev); 575 - } 576 - return 0; 559 + 560 + put_device(dev); 577 561 } 578 562 579 - /** 580 - * pcie_port_shutdown_service - shut down given PCI Express port service 581 - * @dev: PCI Express port service device to handle 582 - * 583 - * If PCI Express port service driver is registered with 584 - * pcie_port_service_register(), this function will be called by the driver core 585 - * when device_shutdown() is called for the port service device associated 586 - * with the driver. 587 - */ 588 - static void pcie_port_shutdown_service(struct device *dev) {} 563 + const struct bus_type pcie_port_bus_type = { 564 + .name = "pci_express", 565 + .match = pcie_port_bus_match, 566 + .probe = pcie_port_bus_probe, 567 + .remove = pcie_port_bus_remove, 568 + }; 589 569 590 570 /** 591 571 * pcie_port_service_register - register PCI Express port service driver ··· 590 586 591 587 new->driver.name = new->name; 592 588 new->driver.bus = &pcie_port_bus_type; 593 - new->driver.probe = pcie_port_probe_service; 594 - new->driver.remove = pcie_port_remove_service; 595 - new->driver.shutdown = pcie_port_shutdown_service; 596 589 597 590 return driver_register(&new->driver); 598 591 }