aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/pccard
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/pccard
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/pccard')
-rw-r--r--sys/dev/pccard/pccard.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c
index 3bab77864347..8f19eb84725c 100644
--- a/sys/dev/pccard/pccard.c
+++ b/sys/dev/pccard/pccard.c
@@ -1022,34 +1022,28 @@ pccard_probe_nomatch(device_t bus, device_t child)
}
static int
-pccard_child_location_str(device_t bus, device_t child, char *buf,
- size_t buflen)
+pccard_child_location(device_t bus, device_t child, struct sbuf *sb)
{
struct pccard_ivar *devi = PCCARD_IVAR(child);
struct pccard_function *pf = devi->pf;
- snprintf(buf, buflen, "function=%d", pf->number);
+ sbuf_printf(sb, "function=%d", pf->number);
return (0);
}
static int
-pccard_child_pnpinfo_str(device_t bus, device_t child, char *buf,
- size_t buflen)
+pccard_child_pnpinfo(device_t bus, device_t child, struct sbuf *sb)
{
struct pccard_ivar *devi = PCCARD_IVAR(child);
struct pccard_function *pf = devi->pf;
struct pccard_softc *sc = PCCARD_SOFTC(bus);
- struct sbuf sb;
- sbuf_new(&sb, buf, buflen, SBUF_FIXEDLEN | SBUF_INCLUDENUL);
- sbuf_printf(&sb, "manufacturer=0x%04x product=0x%04x "
+ sbuf_printf(sb, "manufacturer=0x%04x product=0x%04x "
"cisvendor=\"", sc->card.manufacturer, sc->card.product);
- devctl_safe_quote_sb(&sb, sc->card.cis1_info[0]);
- sbuf_printf(&sb, "\" cisproduct=\"");
- devctl_safe_quote_sb(&sb, sc->card.cis1_info[1]);
- sbuf_printf(&sb, "\" function_type=%d", pf->function);
- sbuf_finish(&sb);
- sbuf_delete(&sb);
+ devctl_safe_quote_sb(sb, sc->card.cis1_info[0]);
+ sbuf_printf(sb, "\" cisproduct=\"");
+ devctl_safe_quote_sb(sb, sc->card.cis1_info[1]);
+ sbuf_printf(sb, "\" function_type=%d", pf->function);
return (0);
}
@@ -1455,8 +1449,8 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
DEVMETHOD(bus_probe_nomatch, pccard_probe_nomatch),
DEVMETHOD(bus_read_ivar, pccard_read_ivar),
- DEVMETHOD(bus_child_pnpinfo_str, pccard_child_pnpinfo_str),
- DEVMETHOD(bus_child_location_str, pccard_child_location_str),
+ DEVMETHOD(bus_child_pnpinfo, pccard_child_pnpinfo),
+ DEVMETHOD(bus_child_location, pccard_child_location),
/* Card Interface */
DEVMETHOD(card_set_res_flags, pccard_set_res_flags),