Can we hook a device as device to two different parent devices?
Mark Millard
marklmi at yahoo.com
Thu Jun 4 23:02:02 UTC 2020
[I'm only trying to follow along for my own edification
in an area I'm not familiar with.]
On 2020-Jun-4, at 14:53, John-Mark Gurney <jmg at funkthat.com> wrote:
> Rajesh Kumar wrote this message on Fri, Jun 05, 2020 at 00:01 +0530:
>> Thanks Warner and Andriy for your answers.
>>
>> Having said they are two separate instances, if the child driver calls the
>> interface of two parents as below
>> device1_interface(child_dev), then device_get_parent(child_dev) in the
>> device1 interface will return device1 reference
>> device2_interface(child_dev), then device_get_parent(child_dev) in the
>> device2 interface will return device2 reference
>>
>> Is that right?
>
> I think you're confused. The device tree is a strict tree. This
> means that a device can have ONLY one parent. The multiple parents
> is simply saying that a device can attach at different points in the
> tree...
>
> example, you have a device dev that is declared as possibly having both
> pci and simplebus:
>
> nexus0
> acpi0
> pcib0
> pci0
> hostb0
> pcib1
> pci1
> dev0
> ofwbus0
> simplebus1 pnpinfo compat=simple-bus
> dev1
>
> This example (and entirely made up, I've merged the tree from two
> different machines, running devinfo -v, only merged to make a point),
> dev0, when calling device_get_parent, will get the pci1 device, and
> dev1 when calling device_get_parent will get simplebus1...
>
> I think this might be what you said above, but couldn't follow the
> device1_interface(child_dev) part, as that didn't make sense to me...
You have 3 "dev" names mentioned above: dev, dev0, dev1
You mention "dev" as the "device".
So am I to infer that for "dev" only one of dev0 vs. dev1
can be attached at a time (to its parent)? Code can still
find out what the alternative would be for the other one
of the two, but having both dev0 and dev1 based attachments
at the same time can not be done?
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-hackers
mailing list