Page MenuHomeFreeBSD

newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
AcceptedPublic

Authored by imp on Apr 22 2021, 8:50 PM.

Details

Reviewers
manu
rpokala
jhb
Group Reviewers
manpages
Summary

Now that the uppoer layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.
Sponsored by: Netflix

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 38819
Build 35708: arc lint + arc unit

Event Timeline

imp requested review of this revision.Apr 22 2021, 8:50 PM
imp added reviewers: rpokala, jhb.
sys/dev/ahci/ahci.c
707

I rather hate that the return value from sbuf_printf() is being ignored, but the return value from snprintf() was _also_ being ignored, so... 😢

sys/dev/bhnd/bhnd.c
909

Since you're here: "Default implementation" is seems wrong; this is the bhnd(4)-specific implementation, right? The "Default implementation" would be the one in subr_bus.c, right?

sys/dev/ahci/ahci.c
707

At least with sbuf, you can get an error status from it. and once the buffer is full, there's no harm in calling sbuf functions again. The caller can still extract the errors and decide what to do, so the client functions needn't worry about it.

sys/dev/bhnd/bhnd.c
909

Well, it's no worse then before, but you're right that it reads weird.

bcr added a subscriber: bcr.

The manpages look good to me.

jhb added inline comments.
sys/dev/bhnd/bhnd.c
909

Maybe fix it to match what is done below for BUS_CHILD_DELETED() and use:

* Default bhnd(4) bus driver implementation of BUS_CHILD_PNPINFO().

But these comments actually add no useful value and I'd be happy to see them be axed instead.

This revision is now accepted and ready to land.May 11 2021, 9:08 PM