aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/spibus
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/spibus
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/spibus')
-rw-r--r--sys/dev/spibus/ofw_spibus.c2
-rw-r--r--sys/dev/spibus/spibus.c18
2 files changed, 5 insertions, 15 deletions
diff --git a/sys/dev/spibus/ofw_spibus.c b/sys/dev/spibus/ofw_spibus.c
index f24b12dccb90..7aae7f44b034 100644
--- a/sys/dev/spibus/ofw_spibus.c
+++ b/sys/dev/spibus/ofw_spibus.c
@@ -217,7 +217,7 @@ static device_method_t ofw_spibus_methods[] = {
DEVMETHOD(device_attach, ofw_spibus_attach),
/* Bus interface */
- DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
+ DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo),
DEVMETHOD(bus_add_child, ofw_spibus_add_child),
DEVMETHOD(bus_get_resource_list, ofw_spibus_get_resource_list),
diff --git a/sys/dev/spibus/spibus.c b/sys/dev/spibus/spibus.c
index 77b35b657381..f9392131e7b6 100644
--- a/sys/dev/spibus/spibus.c
+++ b/sys/dev/spibus/spibus.c
@@ -33,8 +33,8 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/queue.h>
+#include <sys/sbuf.h>
#include <sys/sysctl.h>
-#include <sys/types.h>
#include <sys/bus.h>
#include <machine/bus.h>
@@ -119,22 +119,13 @@ spibus_probe_nomatch(device_t bus, device_t child)
}
static int
-spibus_child_location_str(device_t bus, device_t child, char *buf,
- size_t buflen)
+spibus_child_location(device_t bus, device_t child, struct sbuf *sb)
{
struct spibus_ivar *devi = SPIBUS_IVAR(child);
int cs;
cs = devi->cs & ~SPIBUS_CS_HIGH; /* trim 'cs high' bit */
- snprintf(buf, buflen, "bus=%d cs=%d", device_get_unit(bus), cs);
- return (0);
-}
-
-static int
-spibus_child_pnpinfo_str(device_t bus, device_t child, char *buf,
- size_t buflen)
-{
- *buf = '\0';
+ sbuf_printf(sb, "bus=%d cs=%d", device_get_unit(bus), cs);
return (0);
}
@@ -270,8 +261,7 @@ static device_method_t spibus_methods[] = {
DEVMETHOD(bus_probe_nomatch, spibus_probe_nomatch),
DEVMETHOD(bus_read_ivar, spibus_read_ivar),
DEVMETHOD(bus_write_ivar, spibus_write_ivar),
- DEVMETHOD(bus_child_pnpinfo_str, spibus_child_pnpinfo_str),
- DEVMETHOD(bus_child_location_str, spibus_child_location_str),
+ DEVMETHOD(bus_child_location, spibus_child_location),
DEVMETHOD(bus_hinted_child, spibus_hinted_child),
/* spibus interface */