From ddfc9c4c59e2ea4871100d8c076adffe3af8ff21 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 22 Jun 2021 20:27:57 -0600 Subject: 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 --- sys/dev/ntb/ntb_transport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/dev/ntb/ntb_transport.c') diff --git a/sys/dev/ntb/ntb_transport.c b/sys/dev/ntb/ntb_transport.c index d6bccfb0f08c..90420db0b9aa 100644 --- a/sys/dev/ntb/ntb_transport.c +++ b/sys/dev/ntb/ntb_transport.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -576,12 +577,11 @@ ntb_transport_print_child(device_t dev, device_t child) } static int -ntb_transport_child_location_str(device_t dev, device_t child, char *buf, - size_t buflen) +ntb_transport_child_location(device_t dev, device_t child, struct sbuf *sb) { struct ntb_transport_child *nc = device_get_ivars(child); - snprintf(buf, buflen, "consumer=%d", nc->consumer); + sbuf_printf(sb, "consumer=%d", nc->consumer); return (0); } @@ -1684,7 +1684,7 @@ static device_method_t ntb_transport_methods[] = { DEVMETHOD(device_attach, ntb_transport_attach), DEVMETHOD(device_detach, ntb_transport_detach), /* Bus interface */ - DEVMETHOD(bus_child_location_str, ntb_transport_child_location_str), + DEVMETHOD(bus_child_location, ntb_transport_child_location), DEVMETHOD(bus_print_child, ntb_transport_print_child), DEVMETHOD_END }; -- cgit v1.2.3