From nobody Fri Oct 18 08:44:55 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XVJDS2p5Rz5Ywgy; Fri, 18 Oct 2024 08:44:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XVJDR72DMz4mCS; Fri, 18 Oct 2024 08:44:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729241096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0U0aPFF8ZYQNwdzh91PjbAIC9Nxi4wFLxlYH+Ykrbww=; b=qrzsM1lPJ5yphzbejjNePGOgfLQRVzyzm2SLRsuJNelDUfqca50IAZpHOKYAIFazHNYIkE N8ws2k+4dor7I/tHAks2DWXMgDxLWd+2jz+EgGA06oANoTo26CEEULRuESjKvynZyjG069 qXA+tHBBih5vviVqHVT8c7o31cmIqhi00+Wry/49fTecbn7NOD/YlpbL9fQQftcVQbsp6n rcaqNHOYAagj8HmRU9aBn6wCkFjXtc47Mp+4S1ZIeIffS6mOvHX7ZzPzohYWKCYL7M8+a6 1g5A7D4e38HXQ5VWU+N4p9I8t71ZegDEJCqXvE8R0FwBMryGdVrqxTpw2aYRjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729241096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0U0aPFF8ZYQNwdzh91PjbAIC9Nxi4wFLxlYH+Ykrbww=; b=ABcf6ShW5F34nVyAoI7beVKNIE1hvBdmb1xpIiV32bsTyGP38c/TELNPO6o/EXD42i92hZ l4BMOvMiUpXzYHa0GU/Yt5qVA0XcDPwQ0KuBomOpYlFkC9Gc9GHjm5yOH7EeeXapixjNR+ Zgfo3Pj8K1n3zEvC37BcrdyI/I2EytParNoADVYZvhxuugz3Pevmz19ElJsKMyIZ605zCp Z15UPNKjrs7SSZxWsueugB2V5YjY3Vvg0b1MoyQGvVQq1Xhf0AwooJMHWvt4+GDMjUucu7 +ou1QAOpkQSNUtJt0Gad49C0F3oIGM4lFSjo5uENDOKM7hGXBJSctJyci6Y06w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729241096; a=rsa-sha256; cv=none; b=K3EeyTBgA1uiT3wvPLt5o5bzyvptYBPpvom+eCED9FEtw7OF0d66bY6Jum32O3X8vUfoh/ GWzEfrwkpJr5C346KclEBwjmKIOLh6ytfmEP+2afSAt21pjeW82nJLsxz/8oFp8XoLO6jp waM3s3mPEq+cHEynL8TFTlzTpvRrE5p5AntnlQ2M9VLg8s9IxdqHTq4fUnEU7/d2IWKWlR AUBaEHAlRrz3An4RZb08kh0nx7FcizpCuLEO40FoltuFldYZv0tSnYrPXCgK9ZACOXuP9T GRyEWoD89XYeBfgbRE1YeElsnPn5/LwS4/r6xDqGMqSoru5/evCCLC/L7nm3Aw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XVJDR6ZqQzRWS; Fri, 18 Oct 2024 08:44:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49I8it2s087950; Fri, 18 Oct 2024 08:44:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49I8itjc087947; Fri, 18 Oct 2024 08:44:55 GMT (envelope-from git) Date: Fri, 18 Oct 2024 08:44:55 GMT Message-Id: <202410180844.49I8itjc087947@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 0a0301deb5b6 - main - sound: Move global variable initialization to sound_modevent() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a0301deb5b6a9c66829dd20cff9d40c5ba9ad92 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=0a0301deb5b6a9c66829dd20cff9d40c5ba9ad92 commit 0a0301deb5b6a9c66829dd20cff9d40c5ba9ad92 Author: Christos Margiolis AuthorDate: 2024-10-18 08:39:46 +0000 Commit: Christos Margiolis CommitDate: 2024-10-18 08:39:46 +0000 sound: Move global variable initialization to sound_modevent() There is no reason to initialize global variables in feeder_register(), as these variables are unrelated to what the function does. Instead, initialize them during sound(4) load. Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: zlei Differential Revision: https://reviews.freebsd.org/D46749 --- sys/dev/sound/pcm/feeder.c | 43 ------------------------------------------- sys/dev/sound/pcm/sound.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/sys/dev/sound/pcm/feeder.c b/sys/dev/sound/pcm/feeder.c index 716eb07feaae..87437c6d00b5 100644 --- a/sys/dev/sound/pcm/feeder.c +++ b/sys/dev/sound/pcm/feeder.c @@ -77,49 +77,6 @@ feeder_register(void *p) SLIST_INSERT_HEAD(&feedertab, fte, link); feedercnt++; - /* initialize global variables */ - - if (snd_verbose < 0 || snd_verbose > 4) - snd_verbose = 1; - - if (snd_unit < 0) - snd_unit = -1; - - if (snd_maxautovchans < 0 || - snd_maxautovchans > SND_MAXVCHANS) - snd_maxautovchans = 0; - - if (chn_latency < CHN_LATENCY_MIN || - chn_latency > CHN_LATENCY_MAX) - chn_latency = CHN_LATENCY_DEFAULT; - - if (chn_latency_profile < CHN_LATENCY_PROFILE_MIN || - chn_latency_profile > CHN_LATENCY_PROFILE_MAX) - chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT; - - if (feeder_rate_min < FEEDRATE_MIN || - feeder_rate_max < FEEDRATE_MIN || - feeder_rate_min > FEEDRATE_MAX || - feeder_rate_max > FEEDRATE_MAX || - !(feeder_rate_min < feeder_rate_max)) { - feeder_rate_min = FEEDRATE_RATEMIN; - feeder_rate_max = FEEDRATE_RATEMAX; - } - - if (feeder_rate_round < FEEDRATE_ROUNDHZ_MIN || - feeder_rate_round > FEEDRATE_ROUNDHZ_MAX) - feeder_rate_round = FEEDRATE_ROUNDHZ; - - if (bootverbose) - printf("%s: snd_unit=%d snd_maxautovchans=%d " - "latency=%d " - "feeder_rate_min=%d feeder_rate_max=%d " - "feeder_rate_round=%d\n", - __func__, snd_unit, snd_maxautovchans, - chn_latency, - feeder_rate_min, feeder_rate_max, - feeder_rate_round); - /* we've got our root feeder so don't veto pcm loading anymore */ pcm_veto_load = 0; diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 330c99de14d1..da28a267c81a 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -829,6 +829,51 @@ sound_oss_card_info(oss_card_info *si) /************************************************************************/ +static void +sound_global_init(void) +{ + if (snd_verbose < 0 || snd_verbose > 4) + snd_verbose = 1; + + if (snd_unit < 0) + snd_unit = -1; + + if (snd_maxautovchans < 0 || + snd_maxautovchans > SND_MAXVCHANS) + snd_maxautovchans = 0; + + if (chn_latency < CHN_LATENCY_MIN || + chn_latency > CHN_LATENCY_MAX) + chn_latency = CHN_LATENCY_DEFAULT; + + if (chn_latency_profile < CHN_LATENCY_PROFILE_MIN || + chn_latency_profile > CHN_LATENCY_PROFILE_MAX) + chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT; + + if (feeder_rate_min < FEEDRATE_MIN || + feeder_rate_max < FEEDRATE_MIN || + feeder_rate_min > FEEDRATE_MAX || + feeder_rate_max > FEEDRATE_MAX || + !(feeder_rate_min < feeder_rate_max)) { + feeder_rate_min = FEEDRATE_RATEMIN; + feeder_rate_max = FEEDRATE_RATEMAX; + } + + if (feeder_rate_round < FEEDRATE_ROUNDHZ_MIN || + feeder_rate_round > FEEDRATE_ROUNDHZ_MAX) + feeder_rate_round = FEEDRATE_ROUNDHZ; + + if (bootverbose) + printf("%s: snd_unit=%d snd_maxautovchans=%d " + "latency=%d " + "feeder_rate_min=%d feeder_rate_max=%d " + "feeder_rate_round=%d\n", + __func__, snd_unit, snd_maxautovchans, + chn_latency, + feeder_rate_min, feeder_rate_max, + feeder_rate_round); +} + static int sound_modevent(module_t mod, int type, void *data) { @@ -839,6 +884,7 @@ sound_modevent(module_t mod, int type, void *data) case MOD_LOAD: pcm_devclass = devclass_create("pcm"); pcmsg_unrhdr = new_unrhdr(1, INT_MAX, NULL); + sound_global_init(); break; case MOD_UNLOAD: if (pcmsg_unrhdr != NULL) {