Subject: Re: device tree traversal, round 2
To: Quentin Garnier <cube@cubidou.net>
From: Jachym Holecek <freza@NetBSD.org>
List: tech-kern
Date: 07/16/2007 13:11:30
# Quentin Garnier 2007-07-14:
> On Fri, Jul 21, 2006 at 02:15:42PM +0200, Jachym Holecek wrote:
> > deviter_t di;
> > device_t dv;
> >
> > di = device_iterator_alloc();
> > if (di == NULL)
> > panic("borked");
> >
> > device_iterator_init(di, TAILQ_FIRST(&alldevs),
> > DIF_PREORDER | DIF_WAITOK);
> >
> > while ((dv = device_iterator_foreach(di)) != NULL)
> > printf("FOO %s\n", device_xname(dv));
> >
> > device_iterator_init(di, TAILQ_FIRST(&alldevs),
> > DIF_POSTORDER | DIF_WAITOK);
> >
> > while ((dv = device_iterator_foreach(di)) != NULL)
> > printf("BAR %s\n", device_xname(dv));
> >
> > device_iterator_free(di);
>
> Why didn't this hit the tree?
I got sidetracked and never came up with an user of the API, so I thought
I'd wait for actual need. Do you have some application in mind? Maybe
Jared's power management code would find it handy?
> I have one comment about the example above: you need a slightly different
> API if you want to go through all devices. The first device in alldevs
> might not be the parent of all devices, because there can be several root
> devices.
True, I can revisit the API over the weekend.
-- Jachym