From nobody Fri Oct 18 08:44:57 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 4XVJDT3LWkz5YwJs; Fri, 18 Oct 2024 08:44:57 +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 4XVJDT0ypkz4mKM; Fri, 18 Oct 2024 08:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729241097; 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=8rliVtWm7i3u6ElzdMBeqm4IRrmKoainOdZ6QDhSTro=; b=BMCUlfVkmFzaVOwBbHukJTO3x8wneWAPxTyZrCJzJb0FlWw8CGAQmq6Gy6neUORrD8hEFk oWHKqdNktJKlRDn8Ao7XbLMY/1zvNwjZxNHYxbj8q+BWWA2nfmZcxXiDx5MKmjBAiZCuu7 3dNalLOsHJGc9n43gbFRAWpDShgLbN4pOc/PyLeOv9jkttKoXUcjNbgFAdQQJBv7OL4jSa DGm+oDk+YBkupsLYH6YeBikr9NioQBdz6BS4P05lzZ0pfRcNeO0fisNZBm0RNWMrchM8BM 4lGyCJkcSQZKO+clyFevTLVtWRjisPQzsaYJ9sNoeuzjhyF2GJdA/swM9bkNpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729241097; 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=8rliVtWm7i3u6ElzdMBeqm4IRrmKoainOdZ6QDhSTro=; b=xrrvl7IyRyTHt5VFnUtcOqNKKVz/0VAMK6P5Qqh766zu6xbmNthrfSgwlDxVGpjpviALCf bYkThC5RZU83boYKyhCs95vjOM5ZUCn1sMh5bGD4hWtXmsEGBD8I7i7QlRhNw2YAipmCMy q8xf8y3p+lx+Fa3a01Q+81TmwlmyRT69jkMUhYhbkLFL/h7GIB2VrldJVVw9lJi0iTRCfR YG21gtYOlldLLurpkVJhKXh0HO4e5MnX7HlkzuhFfKyblcsl2PALQNYqR4Xm1uWWvaaMrE nuhd3yyztEtnvZ0kMxBu1V1la1JhrxIYvV+obKbiZXeNWuQ5+k9btdwVH94uCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729241097; a=rsa-sha256; cv=none; b=VBnreTkIlkX0KWwC4qr7Wzfh3gcp3m7xdagcqeM0mtfCHPHPWZr6ZoJDfKTvD8X3k4pWB9 /1t8SAA98V2vsEmgPdXfiWZeNu+gP16+/RqEKKUg3LtoVMeKNwpXSo9ANl1fMf4ZiDnmcH qwu3r15fOsokRZYhtXijXlaRRKh38+fU9Oqx371J8nMykIIwLfqP0CdP+P5wmvM2l4M93/ SAObzilU3JspsPI1cunXREWPgpD8q2vDwN9/RaNToz2Hong7O2Yy/BSIonL2Z3hM/hW2O2 6wENbGxXZlyvpzVvKuFmCFbva3g6ULCGiFstDKfDgiAcFpCro8UWip73go2ZkQ== 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 4XVJDT0X6wzRTm; Fri, 18 Oct 2024 08:44:57 +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 49I8iv1H088003; Fri, 18 Oct 2024 08:44:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49I8ivk7088000; Fri, 18 Oct 2024 08:44:57 GMT (envelope-from git) Date: Fri, 18 Oct 2024 08:44:57 GMT Message-Id: <202410180844.49I8ivk7088000@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: 97570db05ced - main - sound: Move root feeder initialization to separate function 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: 97570db05ced435f4fb1c6a67bdb16966ce5e4d9 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=97570db05ced435f4fb1c6a67bdb16966ce5e4d9 commit 97570db05ced435f4fb1c6a67bdb16966ce5e4d9 Author: Christos Margiolis AuthorDate: 2024-10-18 08:39:58 +0000 Commit: Christos Margiolis CommitDate: 2024-10-18 08:39:58 +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 --- 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);