From nobody Thu Apr 18 20:35:49 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 4VL8gB2Bp9z5HXRw; Thu, 18 Apr 2024 20:35:50 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VL8g96lSlz4My3; Thu, 18 Apr 2024 20:35:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713472549; 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=xq8eq9nL8hJ+j9IJrH8k8RiGAimrd8fuhVDhr4hW5pg=; b=mkynAUdD1tn+mvr5zxHsyKGetn+IIu33WqGYyW7Ya1NHTN5d1vZ/lGWvBRxI4OPCVeBmLV HOBQCZ9sjnA4a/C/zcq8LH4CV0+1w5iltv+WYUj8IIHvYj0cS58bCW1lS6SidYJECtoeEm JwGnqQts1wTwihx6gnZnEgCXqz6dXxuwgc8EhEjVWrpc3djRAK0/2Vugtp8R45v0nRENyh WeG1mS9a9Mye/4kNOg3/c3Osi0sX9ufChJLubuKEl0aBjoawadQmqjE3/VTjukyfJUpwKd 6ZHJHAdIUhla51uJrA3P//hKYREGQD5CaU2qbIB0YUbn8Sv4vTvwM6mqlduCMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713472549; a=rsa-sha256; cv=none; b=oUwZcmoZqZQM9Lla3eMtUctMctfCXtI8A6vlWo/I3v6hUoW5TlPmBJ8OPPLe8AChODuy7m NBLVoAilUmA6RdYpK/A3p5uDRJA522zSt16OXjA0ibKaizLbigp+aiMSeujLoQNvWgQFY6 x5iEXM14qxoWEM9shSWdX+da/coaFbuV25Jy8z4UccAwZ3/qqQMPmCqd/uozD7srWb9USs SkUhRND4Q5rnG0goocscVMKOuQ8gXsqjcDokQUrfx4in4tr1rkAS4C/TVWQtqLslGDRYzz bftV7wrHbq0mkU8vqFGVSwJdqPrkjdz1m/YeVtfq7APi3PmzBp2zcV24zhtpnQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713472549; 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=xq8eq9nL8hJ+j9IJrH8k8RiGAimrd8fuhVDhr4hW5pg=; b=WP+Ras5DA4+fqeBq7z4c34j7YJOMWIuntAFTAKQLQhST5Sxl9ACAB44BpvPvaA2dEeLviD 2ZRslRqWX53XYW5+dqOi8fB5UAz1L6CwtepP7IfDfipEumI7fPuQ0i2I5Hy7Xa9StHk/s3 uaf9p46zE01IO1OiyJ+a3EhuAYtY+rYdU2FtdWBITrl3UmzHMItHirdHgwvEsI2C30Vlhi vawoQxu8At9HPw5HOZAL+VtwqsOE0/sqwVR82wzeAM/6wITwo13AAS6mxRW+BAC9mdRQZI z8Mo1QUOYv99s00aeKXofkaAu8CuKXcn6pKvJ5Pa4HMiFYZPA27kP/y2YSAi/w== 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 4VL8g9648lzPXr; Thu, 18 Apr 2024 20:35:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43IKZndT056679; Thu, 18 Apr 2024 20:35:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43IKZnKG056676; Thu, 18 Apr 2024 20:35:49 GMT (envelope-from git) Date: Thu, 18 Apr 2024 20:35:49 GMT Message-Id: <202404182035.43IKZnKG056676@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: 4d2be7be3837 - main - sound: Get rid of snddev_info->devcount 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: 4d2be7be3837d66ba242a0a7fd51632c3f89285d Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=4d2be7be3837d66ba242a0a7fd51632c3f89285d commit 4d2be7be3837d66ba242a0a7fd51632c3f89285d Author: Christos Margiolis AuthorDate: 2024-04-18 20:35:06 +0000 Commit: Christos Margiolis CommitDate: 2024-04-18 20:35:41 +0000 sound: Get rid of snddev_info->devcount snddev_info->devcount keeps track of the total number of channels for a given device. However, it is redundant to have it, since it is only used in sound_oss_sysinfo() to populate the "numaudios" field, and we also keep track of the channel counts in the playcount, pvchancount, reccount and rvchancount fields anyway. We can simply sum those fields together instead of updating a separate variable upon every channel addition/deletion. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44852 --- sys/dev/sound/pcm/sound.c | 7 +------ sys/dev/sound/pcm/sound.h | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 4b5c2573239c..e88ccb1f25a6 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -602,8 +602,6 @@ pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch) break; } - d->devcount++; - return (0); } @@ -644,8 +642,6 @@ pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch) break; } - d->devcount--; - return (0); } @@ -947,7 +943,6 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec) d->flags |= SD_F_BITPERFECT; d->devinfo = devinfo; - d->devcount = 0; d->reccount = 0; d->playcount = 0; d->pvchancount = 0; @@ -1116,7 +1111,7 @@ sound_oss_sysinfo(oss_sysinfo *si) PCM_UNLOCKASSERT(d); PCM_LOCK(d); - si->numaudios += d->devcount; + si->numaudios += PCM_CHANCOUNT(d); ++ncards; CHN_FOREACH(c, d, channels.pcm) { diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index b48aed7c2d6e..3b725603ee2b 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -175,6 +175,9 @@ struct snd_mixer; #define PCM_DETACHING(x) ((x)->flags & SD_F_DETACHING) +#define PCM_CHANCOUNT(d) \ + (d->playcount + d->pvchancount + d->reccount + d->rvchancount) + /* many variables should be reduced to a range. Here define a macro */ #define RANGE(var, low, high) (var) = \ (((var)<(low))? (low) : ((var)>(high))? (high) : (var)) @@ -367,7 +370,7 @@ struct snddev_info { } opened; } pcm; } channels; - unsigned devcount, playcount, reccount, pvchancount, rvchancount ; + unsigned playcount, reccount, pvchancount, rvchancount; unsigned flags; unsigned int bufsz; void *devinfo;