git: f7d3d0a4ded3 - main - sound: use device_set_descf() to set device descriptions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Jan 2024 09:46:03 UTC
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=f7d3d0a4ded35ba15d63cdf9287b4a2d6f80da11 commit f7d3d0a4ded35ba15d63cdf9287b4a2d6f80da11 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-01-22 09:44:51 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-01-22 09:44:51 +0000 sound: use device_set_descf() to set device descriptions Commit 6b6914c1e21b introduced a printf-like version of device_set_desc(), so use it to simplify device description setting in the audio stack. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D43467 --- sys/dev/sound/pci/emu10kx-pcm.c | 4 +--- sys/dev/sound/pci/emu10kx.c | 12 ++---------- sys/dev/sound/pci/hda/hdaa.c | 8 ++------ sys/dev/sound/pci/hda/hdac.c | 6 ++---- sys/dev/sound/pci/hda/hdacc.c | 3 +-- sys/dev/sound/pci/hdspe-pcm.c | 13 +++++-------- sys/dev/sound/usb/uaudio.c | 5 ++--- 7 files changed, 15 insertions(+), 36 deletions(-) diff --git a/sys/dev/sound/pci/emu10kx-pcm.c b/sys/dev/sound/pci/emu10kx-pcm.c index b4633efdddc7..825a39fc4e63 100644 --- a/sys/dev/sound/pci/emu10kx-pcm.c +++ b/sys/dev/sound/pci/emu10kx-pcm.c @@ -1298,7 +1298,6 @@ emu_pcm_probe(device_t dev) { uintptr_t func, route; const char *rt; - char buffer[255]; BUS_READ_IVAR(device_get_parent(dev), dev, EMU_VAR_FUNC, &func); @@ -1328,8 +1327,7 @@ emu_pcm_probe(device_t dev) break; } - snprintf(buffer, 255, "EMU10Kx DSP %s PCM interface", rt); - device_set_desc_copy(dev, buffer); + device_set_descf(dev, "EMU10Kx DSP %s PCM interface", rt); return (0); } diff --git a/sys/dev/sound/pci/emu10kx.c b/sys/dev/sound/pci/emu10kx.c index 29366c3b61f3..6bbbfcc1df0e 100644 --- a/sys/dev/sound/pci/emu10kx.c +++ b/sys/dev/sound/pci/emu10kx.c @@ -2985,7 +2985,6 @@ emu_write_ivar(device_t bus __unused, device_t dev __unused, static int emu_pci_probe(device_t dev) { - struct sbuf *s; unsigned int thiscard = 0; uint16_t vendor; @@ -2997,15 +2996,8 @@ emu_pci_probe(device_t dev) if (thiscard == 0) return (ENXIO); - s = sbuf_new(NULL, NULL, 4096, 0); - if (s == NULL) - return (ENOMEM); - sbuf_printf(s, "Creative %s [%s]", emu_cards[thiscard].desc, emu_cards[thiscard].SBcode); - sbuf_finish(s); - - device_set_desc_copy(dev, sbuf_data(s)); - - sbuf_delete(s); + device_set_descf(dev, "Creative %s [%s]", + emu_cards[thiscard].desc, emu_cards[thiscard].SBcode); return (BUS_PROBE_DEFAULT); } diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c index e64eac6114e4..02f4babcd331 100644 --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -6577,14 +6577,12 @@ static int hdaa_probe(device_t dev) { const char *pdesc; - char buf[128]; if (hda_get_node_type(dev) != HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) return (ENXIO); pdesc = device_get_desc(device_get_parent(dev)); - snprintf(buf, sizeof(buf), "%.*s Audio Function Group", + device_set_descf(dev, "%.*s Audio Function Group", (int)(strlen(pdesc) - 10), pdesc); - device_set_desc_copy(dev, buf); return (BUS_PROBE_DEFAULT); } @@ -6939,7 +6937,6 @@ hdaa_pcm_probe(device_t dev) struct hdaa_devinfo *devinfo = pdevinfo->devinfo; const char *pdesc; char chans1[8], chans2[8]; - char buf[128]; int loc1, loc2, t1, t2; if (pdevinfo->playas >= 0) @@ -6984,7 +6981,7 @@ hdaa_pcm_probe(device_t dev) if (pdevinfo->digital) t1 = -2; pdesc = device_get_desc(device_get_parent(dev)); - snprintf(buf, sizeof(buf), "%.*s (%s%s%s%s%s%s%s%s%s)", + device_set_descf(dev, "%.*s (%s%s%s%s%s%s%s%s%s)", (int)(strlen(pdesc) - 21), pdesc, loc1 >= 0 ? HDA_LOCS[loc1] : "", loc1 >= 0 ? " " : "", (pdevinfo->digital == 0x7)?"HDMI/DP": @@ -6994,7 +6991,6 @@ hdaa_pcm_probe(device_t dev) chans1[0] ? " " : "", chans1, chans2[0] ? "/" : "", chans2, t1 >= 0 ? " " : "", t1 >= 0 ? HDA_DEVS[t1] : ""); - device_set_desc_copy(dev, buf); return (BUS_PROBE_SPECIFIC); } diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 2cf9239499af..1f06692ba36e 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -1101,10 +1101,8 @@ hdac_probe(device_t dev) snprintf(desc, sizeof(desc), "Generic (0x%08x)", model); result = BUS_PROBE_GENERIC; } - if (result != ENXIO) { - strlcat(desc, " HDA Controller", sizeof(desc)); - device_set_desc_copy(dev, desc); - } + if (result != ENXIO) + device_set_descf(dev, "%s HDA Controller", desc); return (result); } diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c index b551b4b37701..f815e39392d4 100644 --- a/sys/dev/sound/pci/hda/hdacc.c +++ b/sys/dev/sound/pci/hda/hdacc.c @@ -472,8 +472,7 @@ hdacc_probe(device_t dev) hdacc_codecs[i].name, hda_get_device_id(dev)); } else snprintf(buf, sizeof(buf), "Generic (0x%04x)", id); - strlcat(buf, " HDA CODEC", sizeof(buf)); - device_set_desc_copy(dev, buf); + device_set_descf(dev, "%s HDA CODEC", buf); return (BUS_PROBE_DEFAULT); } diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c index 0360e84fbe91..db39b867879f 100644 --- a/sys/dev/sound/pci/hdspe-pcm.c +++ b/sys/dev/sound/pci/hdspe-pcm.c @@ -1000,23 +1000,20 @@ hdspe_pcm_attach(device_t dev) { char status[SND_STATUSLEN]; struct sc_pcminfo *scp; - char desc[64]; + const char *buf; int err; int play, rec; scp = device_get_ivars(dev); scp->ih = &hdspe_pcm_intr; - bzero(desc, sizeof(desc)); if (scp->hc->ports & HDSPE_CHAN_AIO_ALL) - snprintf(desc, sizeof(desc), "HDSPe AIO [%s]", - scp->hc->descr); + buf = "AIO"; else if (scp->hc->ports & HDSPE_CHAN_RAY_ALL) - snprintf(desc, sizeof(desc), "HDSPe RayDAT [%s]", - scp->hc->descr); + buf = "RayDAT"; else - snprintf(desc, sizeof(desc), "HDSPe ? [%s]", scp->hc->descr); - device_set_desc_copy(dev, desc); + buf = "?"; + device_set_descf(dev, "HDSPe %s [%s]", buf, scp->hc->descr); /* * We don't register interrupt handler with snd_setup_intr diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index ebbff0e633e4..917b6bd3f238 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -1171,7 +1171,7 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_class, kobj_class_t chan_clas { struct uaudio_softc *sc = device_get_softc(device_get_parent(dev)); unsigned i = uaudio_get_child_index_by_dev(sc, dev); - char status[SND_STATUSLEN], desc[128]; + char status[SND_STATUSLEN]; uaudio_mixer_init(sc, i); @@ -1199,10 +1199,9 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_class, kobj_class_t chan_clas mixer_hwvol_init(dev); - snprintf(desc, sizeof(desc), "%s %s", + device_set_descf(dev, "%s %s", usb_get_manufacturer(sc->sc_udev), usb_get_product(sc->sc_udev)); - device_set_desc_copy(dev, desc); snprintf(status, sizeof(status), "on %s", device_get_nameunit(device_get_parent(dev)));