aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/smbus
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/smbus
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/smbus')
-rw-r--r--sys/dev/smbus/smbus.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c
index d6b4d9ab78b6..3de5cbc2b1f8 100644
--- a/sys/dev/smbus/smbus.c
+++ b/sys/dev/smbus/smbus.c
@@ -32,11 +32,12 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/bus.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
-#include <sys/bus.h>
+#include <sys/sbuf.h>
#include <dev/smbus/smbconf.h>
#include <dev/smbus/smbus.h>
@@ -135,16 +136,13 @@ smbus_hinted_child(device_t bus, const char *dname, int dunit)
}
static int
-smbus_child_location_str(device_t parent, device_t child, char *buf,
- size_t buflen)
+smbus_child_location(device_t parent, device_t child, struct sbuf *sb)
{
struct smbus_ivar *devi;
devi = device_get_ivars(child);
if (devi->addr != 0)
- snprintf(buf, buflen, "addr=0x%x", devi->addr);
- else if (buflen)
- buf[0] = 0;
+ sbuf_printf(sb, "addr=0x%x", devi->addr);
return (0);
}
@@ -228,7 +226,7 @@ static device_method_t smbus_methods[] = {
DEVMETHOD(bus_add_child, smbus_add_child),
DEVMETHOD(bus_hinted_child, smbus_hinted_child),
DEVMETHOD(bus_probe_nomatch, smbus_probe_nomatch),
- DEVMETHOD(bus_child_location_str, smbus_child_location_str),
+ DEVMETHOD(bus_child_location, smbus_child_location),
DEVMETHOD(bus_print_child, smbus_print_child),
DEVMETHOD(bus_read_ivar, smbus_read_ivar),
DEVMETHOD(bus_write_ivar, smbus_write_ivar),