Page MenuHomeFreeBSD

bus: Add device_has_children predicate
ClosedPublic

Authored by des on Nov 26 2025, 9:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 18, 12:16 PM
Unknown Object (File)
Sun, Jan 4, 1:04 PM
Unknown Object (File)
Thu, Jan 1, 11:56 AM
Unknown Object (File)
Tue, Dec 30, 9:27 PM
Unknown Object (File)
Mon, Dec 29, 8:12 PM
Unknown Object (File)
Dec 26 2025, 12:45 PM
Unknown Object (File)
Dec 18 2025, 11:48 AM
Unknown Object (File)
Dec 17 2025, 6:43 PM
Subscribers

Details

Summary

Add a device_has_children() function which can be used to check if a
device has children without allocating a list of them which we aren't
going to use, or even counting them.

Also modify device_get_children() so it can be used to query the count
without allocating a list.

MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Nov 26 2025, 9:08 AM
This revision is now accepted and ready to land.Nov 26 2025, 1:49 PM
imp requested changes to this revision.Nov 26 2025, 3:10 PM

Why not

bool device_has_children(device_t dev) {return (!TAILQ_EMPTY(&dev->children))) }
This revision now requires changes to proceed.Nov 26 2025, 3:10 PM

I'm too used to thinking in terms of the least minimum diff to achieve the objective...

des retitled this revision from bus: Allow use of device_get_children as a predicate to bus: Add device_has_children predicate.Nov 27 2025, 9:04 AM

add device_has_children() like Warner suggested

Looks like a lot of whitespace changes unrelated as noted.

sys/sys/bus.h
973

Are these intentional? If so, maybe a separate commit?

This revision is now accepted and ready to land.Nov 28 2025, 6:58 AM
des marked an inline comment as done.Nov 28 2025, 9:10 AM
des added inline comments.
sys/sys/bus.h
973

Yes, they were intentional, and I can drop them.

This revision was automatically updated to reflect the committed changes.
des marked an inline comment as done.