aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/nvdimm
diff options
context:
space:
mode:
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/nvdimm
parenta7f6c6fd94d658b9e3f6f9bec02edfefb1a3d652 (diff)
downloadsrc-ddfc9c4c59e2ea4871100d8c076adffe3af8ff21.tar.gz
src-ddfc9c4c59e2ea4871100d8c076adffe3af8ff21.zip
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/nvdimm')
-rw-r--r--sys/dev/nvdimm/nvdimm_acpi.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/dev/nvdimm/nvdimm_acpi.c b/sys/dev/nvdimm/nvdimm_acpi.c
index ccb5dd048210..11c93ad29fdb 100644
--- a/sys/dev/nvdimm/nvdimm_acpi.c
+++ b/sys/dev/nvdimm/nvdimm_acpi.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
+#include <sys/sbuf.h>
#include <sys/uuid.h>
#include <contrib/dev/acpica/include/acpi.h>
@@ -245,20 +246,14 @@ nvdimm_root_write_ivar(device_t dev, device_t child, int index,
}
static int
-nvdimm_root_child_location_str(device_t dev, device_t child, char *buf,
- size_t buflen)
+nvdimm_root_child_location(device_t dev, device_t child, struct sbuf *sb)
{
ACPI_HANDLE handle;
- int res;
handle = nvdimm_root_get_acpi_handle(child);
if (handle != NULL)
- res = snprintf(buf, buflen, "handle=%s", acpi_name(handle));
- else
- res = snprintf(buf, buflen, "");
+ sbuf_printf(sb, "handle=%s", acpi_name(handle));
- if (res >= buflen)
- return (EOVERFLOW);
return (0);
}
@@ -269,7 +264,7 @@ static device_method_t nvdimm_acpi_methods[] = {
DEVMETHOD(bus_add_child, bus_generic_add_child),
DEVMETHOD(bus_read_ivar, nvdimm_root_read_ivar),
DEVMETHOD(bus_write_ivar, nvdimm_root_write_ivar),
- DEVMETHOD(bus_child_location_str, nvdimm_root_child_location_str),
+ DEVMETHOD(bus_child_location, nvdimm_root_child_location),
DEVMETHOD_END
};