portdrv_bus.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * File: portdrv_bus.c
  3. * Purpose: PCI Express Port Bus Driver's Bus Overloading Functions
  4. *
  5. * Copyright (C) 2004 Intel
  6. * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
  7. */
  8. #include <linux/module.h>
  9. #include <linux/pci.h>
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/pm.h>
  13. #include <linux/pcieport_if.h>
  14. #include "portdrv.h"
  15. static int pcie_port_bus_match(struct device *dev, struct device_driver *drv);
  16. struct bus_type pcie_port_bus_type = {
  17. .name = "pci_express",
  18. .match = pcie_port_bus_match,
  19. };
  20. EXPORT_SYMBOL_GPL(pcie_port_bus_type);
  21. static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
  22. {
  23. struct pcie_device *pciedev;
  24. struct pcie_port_service_driver *driver;
  25. if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type)
  26. return 0;
  27. pciedev = to_pcie_device(dev);
  28. driver = to_service_driver(drv);
  29. if (driver->service != pciedev->service)
  30. return 0;
  31. if ((driver->port_type != PCIE_ANY_PORT) &&
  32. (driver->port_type != pci_pcie_type(pciedev->port)))
  33. return 0;
  34. return 1;
  35. }
  36. int pcie_port_bus_register(void)
  37. {
  38. return bus_register(&pcie_port_bus_type);
  39. }
  40. void pcie_port_bus_unregister(void)
  41. {
  42. bus_unregister(&pcie_port_bus_type);
  43. }