aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/pci
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/sound/pci
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/sound/pci')
-rw-r--r--sys/dev/sound/pci/hda/hdaa.c15
-rw-r--r--sys/dev/sound/pci/hda/hdac.c13
-rw-r--r--sys/dev/sound/pci/hda/hdacc.c13
3 files changed, 18 insertions, 23 deletions
diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c
index 8eeeadce6666..ae7d77d431b2 100644
--- a/sys/dev/sound/pci/hda/hdaa.c
+++ b/sys/dev/sound/pci/hda/hdaa.c
@@ -6738,23 +6738,21 @@ hdaa_print_child(device_t dev, device_t child)
}
static int
-hdaa_child_location_str(device_t dev, device_t child, char *buf,
- size_t buflen)
+hdaa_child_location(device_t dev, device_t child, struct sbuf *sb)
{
struct hdaa_devinfo *devinfo = device_get_softc(dev);
struct hdaa_pcm_devinfo *pdevinfo =
(struct hdaa_pcm_devinfo *)device_get_ivars(child);
struct hdaa_audio_as *as;
- int first = 1, i, len = 0;
+ int first = 1, i;
- len += snprintf(buf + len, buflen - len, "nid=");
+ sbuf_printf(sb, "nid=");
if (pdevinfo->playas >= 0) {
as = &devinfo->as[pdevinfo->playas];
for (i = 0; i < 16; i++) {
if (as->pins[i] <= 0)
continue;
- len += snprintf(buf + len, buflen - len,
- "%s%d", first ? "" : ",", as->pins[i]);
+ sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]);
first = 0;
}
}
@@ -6763,8 +6761,7 @@ hdaa_child_location_str(device_t dev, device_t child, char *buf,
for (i = 0; i < 16; i++) {
if (as->pins[i] <= 0)
continue;
- len += snprintf(buf + len, buflen - len,
- "%s%d", first ? "" : ",", as->pins[i]);
+ sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]);
first = 0;
}
}
@@ -6830,7 +6827,7 @@ static device_method_t hdaa_methods[] = {
DEVMETHOD(device_resume, hdaa_resume),
/* Bus interface */
DEVMETHOD(bus_print_child, hdaa_print_child),
- DEVMETHOD(bus_child_location_str, hdaa_child_location_str),
+ DEVMETHOD(bus_child_location, hdaa_child_location),
DEVMETHOD(hdac_stream_intr, hdaa_stream_intr),
DEVMETHOD(hdac_unsol_intr, hdaa_unsol_intr),
DEVMETHOD(hdac_pindump, hdaa_pindump),
diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c
index ec907715c5b1..b1fb193595fe 100644
--- a/sys/dev/sound/pci/hda/hdac.c
+++ b/sys/dev/sound/pci/hda/hdac.c
@@ -1774,21 +1774,20 @@ hdac_print_child(device_t dev, device_t child)
}
static int
-hdac_child_location_str(device_t dev, device_t child, char *buf, size_t buflen)
+hdac_child_location(device_t dev, device_t child, struct sbuf *sb)
{
- snprintf(buf, buflen, "cad=%d", (int)(intptr_t)device_get_ivars(child));
+ sbuf_printf(sb, "cad=%d", (int)(intptr_t)device_get_ivars(child));
return (0);
}
static int
-hdac_child_pnpinfo_str_method(device_t dev, device_t child, char *buf,
- size_t buflen)
+hdac_child_pnpinfo_method(device_t dev, device_t child, struct sbuf *sb)
{
struct hdac_softc *sc = device_get_softc(dev);
nid_t cad = (uintptr_t)device_get_ivars(child);
- snprintf(buf, buflen,
+ sbuf_printf(sb,
"vendor=0x%04x device=0x%04x revision=0x%02x stepping=0x%02x",
sc->codecs[cad].vendor_id, sc->codecs[cad].device_id,
sc->codecs[cad].revision_id, sc->codecs[cad].stepping_id);
@@ -2137,8 +2136,8 @@ static device_method_t hdac_methods[] = {
/* Bus interface */
DEVMETHOD(bus_get_dma_tag, hdac_get_dma_tag),
DEVMETHOD(bus_print_child, hdac_print_child),
- DEVMETHOD(bus_child_location_str, hdac_child_location_str),
- DEVMETHOD(bus_child_pnpinfo_str, hdac_child_pnpinfo_str_method),
+ DEVMETHOD(bus_child_location, hdac_child_location),
+ DEVMETHOD(bus_child_pnpinfo, hdac_child_pnpinfo_method),
DEVMETHOD(bus_read_ivar, hdac_read_ivar),
DEVMETHOD(hdac_get_mtx, hdac_get_mtx),
DEVMETHOD(hdac_codec_command, hdac_codec_command),
diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c
index 3b1ca7ea61e5..ff72498ecb9f 100644
--- a/sys/dev/sound/pci/hda/hdacc.c
+++ b/sys/dev/sound/pci/hda/hdacc.c
@@ -542,21 +542,20 @@ hdacc_detach(device_t dev)
}
static int
-hdacc_child_location_str(device_t dev, device_t child, char *buf, size_t buflen)
+hdacc_child_location(device_t dev, device_t child, struct sbuf *sb)
{
struct hdacc_fg *fg = device_get_ivars(child);
- snprintf(buf, buflen, "nid=%d", fg->nid);
+ sbuf_printf(sb, "nid=%d", fg->nid);
return (0);
}
static int
-hdacc_child_pnpinfo_str_method(device_t dev, device_t child, char *buf,
- size_t buflen)
+hdacc_child_pnpinfo_method(device_t dev, device_t child, struct sbuf *sb)
{
struct hdacc_fg *fg = device_get_ivars(child);
- snprintf(buf, buflen, "type=0x%02x subsystem=0x%08x",
+ sbuf_printf(sb, "type=0x%02x subsystem=0x%08x",
fg->type, fg->subsystem_id);
return (0);
}
@@ -766,8 +765,8 @@ static device_method_t hdacc_methods[] = {
DEVMETHOD(device_suspend, hdacc_suspend),
DEVMETHOD(device_resume, hdacc_resume),
/* Bus interface */
- DEVMETHOD(bus_child_location_str, hdacc_child_location_str),
- DEVMETHOD(bus_child_pnpinfo_str, hdacc_child_pnpinfo_str_method),
+ DEVMETHOD(bus_child_location, hdacc_child_location),
+ DEVMETHOD(bus_child_pnpinfo, hdacc_child_pnpinfo_method),
DEVMETHOD(bus_print_child, hdacc_print_child),
DEVMETHOD(bus_probe_nomatch, hdacc_probe_nomatch),
DEVMETHOD(bus_read_ivar, hdacc_read_ivar),