Currently there's only one user of pci_host_common_init(), the
pcie-apple driver, and it goes to great lengths to store its own
per-device private pointer, because the device's drvdata is used by
pci_host_common_init() to store a pointer to struct pci_host_bridge.
See commit 643c0c9d0496 ("PCI: apple: Add tracking of probed root
ports").
However, it looks like this is necessary only for simple drivers that
use pci_host_common_{probe,remove}() directly as their platform
probe/remove functions. More complex drivers that allocate their own
private structure, like pcie-apple, can store a pointer to that instead;
the pointer to struct pci_host_bridge can be encapsulated in the private
structure if it's needed.
The first patch changes the pci-host-common library to free up drvdata
for drivers that do not use pci_host_common_{probe,remove}() directly.
The second patch uses the changes in the first patch to simplify the
pointer storage logic. This patch is *untested* because I don't have
access to the hardware.
Radu Rendec (2):
PCI: host-common: Do not set drvdata in pci_host_common_init()
PCI: apple: Store private pointer in platform device's drvdata
drivers/pci/controller/pci-host-common.c | 36 +++++++++++-----
drivers/pci/controller/pci-host-common.h | 6 ++-
drivers/pci/controller/pcie-apple.c | 53 ++++--------------------
3 files changed, 36 insertions(+), 59 deletions(-)
--
2.51.1