Re: [PATCH 5/8] PCI: add generic device into pci_host_bridge struct

Yinghai Lu
2012-02-27T20:49:38Z

On Mon, Feb 27, 2012 at 11:17 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Mon, Feb 27, 2012 at 12:08 PM, Yinghai Lu <yinghai@kernel.org> wrote:

>>> This doesn't feel right to me.  You're allocating a new struct device
>>> here, but the arch likely already has one.  In fact, I think we even
>>> passed it in to pci_create_root_bus().
>>
>> no.
>>
>> original pci_create_root_bus() will create one dummy struct device and
>> use it as parent for bus->dev.
>>
>>>
>>> On x86, we already have an ACPI device for the host bridge, and now
>>> we'll have a second one.  (Actually a *third* one, because PNPACPI
>>> also has one, but that's a long-standing problem.)
>>
>> not related.
>
> OK.  Can you educate me?  What is the device we pass in, what does the
> dummy one correspond to, why do we have two, what's the difference,
> etc., etc.?

for every bus will have ->bridge, and that is device pointer. to pci
bridge dev.

for root bus, there is not pci bridge for that. So create_root_bus
allocate local dummy one.

that dummy device will be bus->dev's parent.

Now pci_host_bridge is added, and it is allocated, so just put the
struct device into that pci_host_bridge.

and use pci_host_bridge->dev as parent of root bus->dev's parent.

Yinghai