Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 2020 09:29:06 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Andriy Gapon <avg@freebsd.org>
Cc:        Rajesh Kumar <rajfbsd@gmail.com>, freebsd-drivers@freebsd.org,  FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Can we hook a device as device to two different parent devices?
Message-ID:  <CANCZdfpF%2BaiZYLRHo-NOizZcAuBz%2BXhsqYvXTazHrMVz_%2Bh=3w@mail.gmail.com>
In-Reply-To: <c1b611bc-4fa7-7975-da3f-e7c68a26e92b@FreeBSD.org>
References:  <CAAO%2BANOB8m6OjRY-FOVVHQi3vdcCEnHdjE2s3xoHdh0rjaTruQ@mail.gmail.com> <c1b611bc-4fa7-7975-da3f-e7c68a26e92b@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon <avg@freebsd.org> wrote:

> On 03/06/2020 14:20, Rajesh Kumar wrote:
> > Hi,
> >
> > Is it really possible to declare a module with two parents? Like the
> > following declarations in the same driver.
> >
> > devclass_t test_dev_devclass;
> > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods,
> > sizeof(struct test_dev_ctx));
> > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass,
> > NULL, NULL);
> > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass,
> > NULL, NULL);
> >
> > I see similar references in other drivers attaching to both simpleus and
> > ofwbus. So, If it's possible, how to get the reference for both the
> > parents?  device_get_parent(test_dev) will give reference of one parent
> > only right, so how to get the reference of the desired parent?
>
> A device can have only one parent.
> The declaration you quoted describes a _driver_ that can attach to devices
> hanging off two different buses.  They would still be different devices.
>

Yes. You can have a driver attach to multiple bus types, but each instance
has a unique parent one exactly on of them.

If you need to talk to other devices, you'll need to find them by name or
other means.

Warner



> --
> Andriy Gapon
> _______________________________________________
> freebsd-drivers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers
> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpF%2BaiZYLRHo-NOizZcAuBz%2BXhsqYvXTazHrMVz_%2Bh=3w>