[PATCH v6 4/9] PCI: separate device_initialize() from pci_device_add()

Jim Quinlan
2021-10-29T20:03:53Z

Do this so that device_initialize() may be called separately
(to prepare for an imminent commit). This change does reverse
the invocation of these calls:

pci_configure_device(dev);
device_initialize(&dev->dev)
to
device_initialize(&dev->dev)
pci_configure_device(dev);

I reviewed this and didn't see any issue but it deserves mentioning.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
drivers/pci/iov.c | 1 +
drivers/pci/probe.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index dafdc652fcd0..baf5c1af47de 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -292,6 +292,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
BUG_ON(rc);
}

+ device_initialize(&virtfn->dev);
pci_device_add(virtfn, virtfn->bus);
rc = pci_iov_sysfs_link(dev, virtfn, id);
if (rc)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f3fc807b4fe8..0f092882b33f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2391,6 +2391,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
kfree(dev);
return NULL;
}
+ device_initialize(&dev->dev);
pci_device_add(dev, bus);

return dev;
@@ -2491,7 +2492,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)

pci_configure_device(dev);

- device_initialize(&dev->dev);
dev->dev.release = pci_release_dev;

set_dev_node(&dev->dev, pcibus_to_node(bus));
--
2.17.1