From nobody Fri May 17 19:30:50 2024 X-Original-To: dev-commits-src-branches@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 4Vgxrq1D5vz5LgBS; Fri, 17 May 2024 19:30:51 +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 4Vgxrq089Bz4tnC; Fri, 17 May 2024 19:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974251; 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=uCLZ8sJ7kYlg9Y20+L3DOuIqDsxnaNeaX9SkzJFDLEo=; b=HBO+J1/A+ZPg6tMIoaPBR7iMIqhY3QZ0PJFkOQAbxY6vBLXd/0Nyy6d7KHkcPL8KVSSXuz DGEKbU9xPJdJyyJ8mhR3WYE5q46dCoBfovhHvRJLU8CYJuJAYgiQpIcGynl+fNy7dA5PiS yWlfgXPoUb6KTsePqvMBidKiDFt2va84zUZJ10gYrX+v18EPpF+qtF0BVAn/TriyNr3yUo nPXTG5r0IBK8pc5zQ/VL9GJtq54s6gTi9igELd425J1s4UwqNqMspRO3sOMnORBCoUWUgD BEQJSdMWL2dATD1ckjqW4hQIK9NRNlUii9YJ/cq56SCtgpaSZ7sx3A6+b3YWWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715974251; a=rsa-sha256; cv=none; b=yyBwkzLvT7EIsC0w/uQs4psLytkhxuNienKhG4S81zMAc9buYvSPTp9brbwHQWtmdlEAft GrwYYv22hvwHxu46TGnxq4n4Cqp35Td766qku1idEtKYfOIRb3GX9vuOFfuHlBKV/xu5bG ZvwER3bILe6o4PGkR4lL8UBsR8941zBxicUEKs+MSbes+2B92oSzttznGvtV1upeVX3xIk +grlKBmIezTXJ4XQbj8Oq3dtahslX38upHYzGBQUvcDRNQBHS4otB3Cn3gPNP3rrUHtTij GOwRoBNyeWrNbDEXLJGjIWyy6OdHdlzX8Izsdj2Dx3R29wjmLSpBg1TfTMgV0g== 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=1715974251; 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=uCLZ8sJ7kYlg9Y20+L3DOuIqDsxnaNeaX9SkzJFDLEo=; b=YUu1TDnJlZ+25PTl/6XXRmS7J84A29a6Okcq47xY3pHxpzKufqse26P1P4ZvUQeNqqnrZf gYFOyyzeiNhxyCZlKn7w1xR1iXNsp/Si9i3nyOIPwVZ8jmQITUw0IGA5xftDQbD3nZeT/6 c5M9yhR9NcEfIROgWO0sMvjuIt3F9yb7oV7m8jljZ+PLLTNhFLLZZEHH1Q5wRp5cr6lpsB FbgZM4Pa0MDvt9jyQSJqgqA1RQdb10qaV5Qupd37us2xZnX9zX8HWP+h4bAoep3y7r6rs1 qUY2ewf4Na3drjxc4Zs2ebMzlkUpvcKeo8nvBq6VBc4XY/eHUaGQ8d3kfO9Z0w== 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 4Vgxrp6tFWzvgb; Fri, 17 May 2024 19:30:50 +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 44HJUoNB099212; Fri, 17 May 2024 19:30:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HJUoEs099209; Fri, 17 May 2024 19:30:50 GMT (envelope-from git) Date: Fri, 17 May 2024 19:30:50 GMT Message-Id: <202405171930.44HJUoEs099209@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: d27972ec911d - stable/14 - sound: Get rid of snddev_info->devcount List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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: d27972ec911d09379bfbd400a7e7e7ebd4a595ec Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=d27972ec911d09379bfbd400a7e7e7ebd4a595ec commit d27972ec911d09379bfbd400a7e7e7ebd4a595ec Author: Christos Margiolis AuthorDate: 2024-04-18 20:35:06 +0000 Commit: Christos Margiolis CommitDate: 2024-05-17 19:30:01 +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 (cherry picked from commit 4d2be7be3837d66ba242a0a7fd51632c3f89285d) --- 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 83248efd3f37..92ff041d0fb9 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); } @@ -974,7 +970,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; @@ -1137,7 +1132,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;