path: root/sys/dev/ntb/ntb_transport.c
diff options
authorWarner Losh <imp@FreeBSD.org>2021-06-23 02:27:57 +0000
committerWarner Losh <imp@FreeBSD.org>2021-06-23 02:52:06 +0000
commitddfc9c4c59e2ea4871100d8c076adffe3af8ff21 (patch)
tree3a4cc2294b046b13050512960da01d0af6acc963 /sys/dev/ntb/ntb_transport.c
parenta7f6c6fd94d658b9e3f6f9bec02edfefb1a3d652 (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/dev/ntb/ntb_transport.c')
1 files changed, 4 insertions, 4 deletions
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 <sys/module.h>
#include <sys/mutex.h>
#include <sys/queue.h>
+#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
@@ -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),