git: 41ab202ff74e - main - sound: Call device_get_name() and device_get_unit() only once in mixer_init()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Apr 2024 20:35:48 UTC
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=41ab202ff74ea6af7e9125c9dfb430c729380f41 commit 41ab202ff74ea6af7e9125c9dfb430c729380f41 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-04-18 20:35:01 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2024-04-18 20:35:40 +0000 sound: Call device_get_name() and device_get_unit() only once in mixer_init() No functional change intended. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D44840 --- sys/dev/sound/pcm/mixer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index cc8cf5b1ceea..9a83fc305bc7 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -726,14 +726,17 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo) struct snd_mixer *m; u_int16_t v; struct cdev *pdev; + const char *name; int i, unit, devunit, val; snddev = device_get_softc(dev); if (snddev == NULL) return (-1); - if (resource_int_value(device_get_name(dev), - device_get_unit(dev), "eq", &val) == 0 && val != 0) { + name = device_get_name(dev); + unit = device_get_unit(dev); + if (resource_int_value(name, unit, "eq", &val) == 0 && + val != 0) { snddev->flags |= SD_F_EQ; if ((val & SD_F_EQ_MASK) == val) snddev->flags |= val; @@ -749,8 +752,8 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo) for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) { v = snd_mixerdefaults[i]; - if (resource_int_value(device_get_name(dev), - device_get_unit(dev), snd_mixernames[i], &val) == 0) { + if (resource_int_value(name, unit, snd_mixernames[i], + &val) == 0) { if (val >= 0 && val <= 100) { v = (u_int16_t) val; } @@ -761,7 +764,6 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo) mixer_setrecsrc(m, 0); /* Set default input. */ - unit = device_get_unit(dev); devunit = snd_mkunit(unit, SND_DEV_CTL, 0); pdev = make_dev(&mixer_cdevsw, PCMMINOR(devunit), UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);