diff options
author | Warner Losh <imp@FreeBSD.org> | 2021-06-23 02:27:57 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2021-06-23 02:52:06 +0000 |
commit | ddfc9c4c59e2ea4871100d8c076adffe3af8ff21 (patch) | |
tree | 3a4cc2294b046b13050512960da01d0af6acc963 /sys/isa | |
parent | a7f6c6fd94d658b9e3f6f9bec02edfefb1a3d652 (diff) |
newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper 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.
Reviewed by: jhb, bcr
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29937
Diffstat (limited to 'sys/isa')
-rw-r--r-- | sys/isa/isa_common.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index 7bc66d552e31..3255e76308c0 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <machine/bus.h> #include <sys/rman.h> +#include <sys/sbuf.h> #include <sys/sysctl.h> #include <machine/resource.h> @@ -1032,30 +1033,26 @@ isa_pnp_probe(device_t dev, device_t child, struct isa_pnp_id *ids) } static int -isa_child_pnpinfo_str(device_t bus, device_t child, char *buf, - size_t buflen) +isa_child_pnpinfo(device_t bus, device_t child, struct sbuf *sb) { struct isa_device *idev = DEVTOISA(child); if (idev->id_vendorid) - snprintf(buf, buflen, "pnpid=%s", + sbuf_printf(sb, "pnpid=%s", pnp_eisaformat(idev->id_vendorid)); return (0); } static int -isa_child_location_str(device_t bus, device_t child, char *buf, - size_t buflen) +isa_child_location(device_t bus, device_t child, struct sbuf *sb) { #if 0 /* id_pnphandle isn't there yet */ struct isa_device *idev = DEVTOISA(child); if (idev->id_vendorid) - snprintf(buf, buflen, "pnphandle=%d", idev->id_pnphandle); + sbuf_printf(sbuf, "pnphandle=%d", idev->id_pnphandle); #endif - /* Nothing here yet */ - *buf = '\0'; return (0); } @@ -1087,8 +1084,8 @@ static device_method_t isa_methods[] = { DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str), - DEVMETHOD(bus_child_location_str, isa_child_location_str), + DEVMETHOD(bus_child_pnpinfo, isa_child_pnpinfo), + DEVMETHOD(bus_child_location, isa_child_location), DEVMETHOD(bus_hinted_child, isa_hinted_child), DEVMETHOD(bus_hint_device_unit, isa_hint_device_unit), |