From nobody Sun Oct 20 11:21:36 2024 X-Original-To: dev-commits-src-all@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 4XWbcJ4V5sz5YvTY; Sun, 20 Oct 2024 11:21:36 +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 4XWbcJ3ZsQz4Wc5; Sun, 20 Oct 2024 11:21:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729423296; 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=BZN6ijW9ZLddhDxkAplp2jQRoWR2H6glzmkV/T8sTio=; b=cd6WaU9H9YatXKEAUPqN5f455w8fKloN/8ROCY55ZdiSk/rIyHYgEyTBBN4cK61bRNX3Ta PBmB26YHfpn0XkXuyp/fDQd3h9/8aq8bhWu4kecGjgnpUQmuUnpL5sNssFabTzrhMUtfJZ y2bSSWcFyLr08yVneY14ZcTcXRMgRHKEFLpIWelS3Bmo0UuB8CHEFR16kG5X6kADdH19k+ F1q3Od3rKSNFUigUMXU/SOEnzlqUvfRqP4sNWPdQhqLi2Ah3CbaztECHcUqUfGQcZxpcVi qEECvK/KBM1T4aKEOKuR2HamoR2a8F6+4Br5wsCHQ3sRkEn1Cp0nTHzOxuYmdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729423296; 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=BZN6ijW9ZLddhDxkAplp2jQRoWR2H6glzmkV/T8sTio=; b=wxQg9gGAeqrfkNf461cnJrp3I3QczvE9Bb1o0mPbak1rvqOTvOZY5ZkJiuyoCknwuzU2We PWBOcaRiAg3MISbD8Yx0NQ0UPou/SmUrECfRvjStVHW99chtagUoD9F+rc5fYmlYFkLl0l q2N/AOlS12spqGryc9Ely5e9eRIHH+kwZYgD53wLgyulCVZefuOmeqv1xAXS9b4NNTX2JC uVlBm3b8zFouWJrUfrzuvrN7lznBJDvYDp83VcTazbt0wX7Ng3YOykZTsyui1I6uM8yxS6 sqmuW3HV5P+LdY0n+bYzvq95qhLnEBroo2cNMgsp/B4vSVZSI1mK5SZX2YPr5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729423296; a=rsa-sha256; cv=none; b=O5tQNn2NS3X7J6INO3biE83loXwvIJHOZnXGGNoakhyVnCghRQwK2vRO26dtvR4plx7Ffj BJ6G2zJk/2A5kJeCKPERG3zJ31n8v+5wELZSNevtxJCNkt54DByrZVcUzS8DjLBoC+mbtb Pt1P5JYMVz7HNBiGPm93tyrGFHvEsA5PSalG1EJgayUXy5oZgQUpXMc84hvI5XQDkirnRD I9uHxEV93xnTCDGnQPsvZQN9yVZOcnyhpCV/eFJ6F1qZ4xzIkJ+RN0A5ZicOYaCUROZUyo 1ZRqxZC49tX687eXsZjK8WanaCmQ/FPTYoid6hyO0jGtT/kM46T4YcvqsBi20g== 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 4XWbcJ3CBPz108P; Sun, 20 Oct 2024 11:21:36 +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 49KBLaiH062776; Sun, 20 Oct 2024 11:21:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49KBLaEK062773; Sun, 20 Oct 2024 11:21:36 GMT (envelope-from git) Date: Sun, 20 Oct 2024 11:21:36 GMT Message-Id: <202410201121.49KBLaEK062773@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 1f4d968a299e - stable/14 - sound: Move root feeder initialization to separate function List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 1f4d968a299ea74f10276761932c2ece28531975 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=1f4d968a299ea74f10276761932c2ece28531975 commit 1f4d968a299ea74f10276761932c2ece28531975 Author: Christos Margiolis AuthorDate: 2024-10-18 08:39:58 +0000 Commit: Christos Margiolis CommitDate: 2024-10-20 11:21:05 +0000 sound: Move root feeder initialization to separate function feeder_register() is currently a SYSINIT in order to create the root feeder, which happens only when feedercnt is 0. Separating the root feeder registration makes the code more readable. No functional change intended. While here, fix some style errors. Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch, zlei, markj Differential Revision: https://reviews.freebsd.org/D46821 (cherry picked from commit 97570db05ced435f4fb1c6a67bdb16966ce5e4d9) --- sys/dev/sound/pcm/feeder.c | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/sys/dev/sound/pcm/feeder.c b/sys/dev/sound/pcm/feeder.c index 87437c6d00b5..c6f93ac54036 100644 --- a/sys/dev/sound/pcm/feeder.c +++ b/sys/dev/sound/pcm/feeder.c @@ -48,51 +48,55 @@ struct feedertab_entry { int idx; }; static SLIST_HEAD(, feedertab_entry) feedertab; +static int feedercnt = 0; /*****************************************************************************/ -void -feeder_register(void *p) +static void +feeder_register_root(void *p) { - static int feedercnt = 0; - struct feeder_class *fc = p; struct feedertab_entry *fte; - int i; - - if (feedercnt == 0) { - KASSERT(fc->desc == NULL, ("first feeder not root: %s", fc->name)); - - SLIST_INIT(&feedertab); - fte = malloc(sizeof(*fte), M_FEEDER, M_NOWAIT | M_ZERO); - if (fte == NULL) { - printf("can't allocate memory for root feeder: %s\n", - fc->name); - return; - } - fte->feederclass = fc; - fte->desc = NULL; - fte->idx = feedercnt; - SLIST_INSERT_HEAD(&feedertab, fte, link); - feedercnt++; - - /* we've got our root feeder so don't veto pcm loading anymore */ - pcm_veto_load = 0; + MPASS(feedercnt == 0); + KASSERT(fc->desc == NULL, ("first feeder not root: %s", fc->name)); + SLIST_INIT(&feedertab); + fte = malloc(sizeof(*fte), M_FEEDER, M_NOWAIT | M_ZERO); + if (fte == NULL) { + printf("can't allocate memory for root feeder: %s\n", fc->name); return; } + fte->feederclass = fc; + fte->desc = NULL; + fte->idx = feedercnt; + SLIST_INSERT_HEAD(&feedertab, fte, link); + feedercnt++; + + /* we've got our root feeder so don't veto pcm loading anymore */ + pcm_veto_load = 0; +} + +void +feeder_register(void *p) +{ + struct feeder_class *fc = p; + struct feedertab_entry *fte; + int i; KASSERT(fc->desc != NULL, ("feeder '%s' has no descriptor", fc->name)); - /* beyond this point failure is non-fatal but may result in some translations being unavailable */ + /* + * beyond this point failure is non-fatal but may result in some + * translations being unavailable + */ i = 0; while ((feedercnt < MAXFEEDERS) && (fc->desc[i].type > 0)) { - /* printf("adding feeder %s, %x -> %x\n", fc->name, fc->desc[i].in, fc->desc[i].out); */ fte = malloc(sizeof(*fte), M_FEEDER, M_NOWAIT | M_ZERO); if (fte == NULL) { - printf("can't allocate memory for feeder '%s', %x -> %x\n", fc->name, fc->desc[i].in, fc->desc[i].out); - + printf("can't allocate memory for feeder '%s', " + "%x -> %x\n", + fc->name, fc->desc[i].in, fc->desc[i].out); return; } fte->feederclass = fc; @@ -103,8 +107,10 @@ feeder_register(void *p) i++; } feedercnt++; - if (feedercnt >= MAXFEEDERS) - printf("MAXFEEDERS (%d >= %d) exceeded\n", feedercnt, MAXFEEDERS); + if (feedercnt >= MAXFEEDERS) { + printf("MAXFEEDERS (%d >= %d) exceeded\n", + feedercnt, MAXFEEDERS); + } } static void @@ -469,5 +475,6 @@ static struct feeder_class feeder_root_class = { .desc = NULL, .data = NULL, }; -SYSINIT(feeder_root, SI_SUB_DRIVERS, SI_ORDER_FIRST, feeder_register, &feeder_root_class); +SYSINIT(feeder_root, SI_SUB_DRIVERS, SI_ORDER_FIRST, feeder_register_root, + &feeder_root_class); SYSUNINIT(feeder_root, SI_SUB_DRIVERS, SI_ORDER_FIRST, feeder_unregisterall, NULL);