From nobody Sat Mar 23 06:59:16 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 4V1qn107LQz5Djnk; Sat, 23 Mar 2024 06:59:17 +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 4V1qn06YnPz4KSJ; Sat, 23 Mar 2024 06:59:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711177156; 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=Y1TtqChr/Q1oU6FfG/ueHUfV9w81VTP5GMs88NZL4Uk=; b=WdrqStHZslQk3/ZNrlWHca1aL3CQjMt5MURqo8DPoURDuPEgQr7SLDvbLJ3SS5e3dEz9cX hoVLxyS8OSAHlOpc5eCs+dx8/khIjssw2i4xjDUCHSzND5Os1lDFU84gnQsJHCRkFxViwH 0dhFEKgmBtUlMqcJciS3XlnnS1PLbVDP6UhZL6c7oi8FHYxXHVP7pWIG1KOUdFv/7ZyxD/ Mu7wOjkvEok3HOjKE/zc5CyXIZSyqct7rEXfgEoIRojtx1iC7K6IU5f2qgH35KMCGpmRJX gmZoYthMgRRGwcofGJcbgeZQIu9vF7EOiTOYbbMscHVRugjBPULJMfiN6bL5jA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711177156; a=rsa-sha256; cv=none; b=c8pff4tcjatPCkdUu6jWCIgUkHEVxeZTmqfrMWGgeWuXYjxfQDP9MWBikzbp+RcMudkpat 9OtUWEokrt9fZDYRGTbr6wyWHHizsIAb0YTy8TZxgAoJkPv1OFpS4qnivCq8qySO7I7Lws EK3vyuvIwr+3NBEFX6RdjPfsSNQc9qgKIR0ZxWodQzLuVmeK/gk6DR7gH3W/eWqrlihQ2p fGwODVWfmWUDPlOb9Uh185oSwLIW2zqmgkZVAxuVkOrly1CuHjRjPbWzSe83olphmjNxmR qingZo88EMrvxjKU8+hmEumQTxdqVs0jop9aROygccoT8H3YUy36r0bMvWMkQA== 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=1711177156; 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=Y1TtqChr/Q1oU6FfG/ueHUfV9w81VTP5GMs88NZL4Uk=; b=cnoXD3XI0xmw4H1Aq0hCWZntLCUpPG5ITWeMIbOQd9qdDxfJ1gPeye3DO5bGiMyMZ/JNx5 ypHcpwckuzki+1nk8TbZMLc9rXTF2afJMC2t7FViFiu8MZmAOWn5EEexB0JrhJdBmUYk/K SB1Lq10w4OA8op/ngQRJpKchDfuHzhz5XOYJJcFDmi5OHV63TN4wCm8ryzlZPPKhgJTne7 rxGemrkol2F8wRpa+HDx3W9Bm0sPml+TNjbTG9IozQFnrxwS2P8HoNSrpBczgK+Gh5E3UM IhTsQEEqcGly/3MGwyFKWqCduZwwQYy/gnvdQcWxkH/QllqZgQppZ6a95yJspg== 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 4V1qn05jxYzdJ4; Sat, 23 Mar 2024 06:59:16 +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 42N6xGcv065517; Sat, 23 Mar 2024 06:59:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42N6xGZb065514; Sat, 23 Mar 2024 06:59:16 GMT (envelope-from git) Date: Sat, 23 Mar 2024 06:59:16 GMT Message-Id: <202403230659.42N6xGZb065514@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 88f2c58d1a85 - main - cdevpriv(9): document devfs_foreach_cdevpriv() 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 88f2c58d1a857f0ccedd49da3dc29d8d193b4fdd Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=88f2c58d1a857f0ccedd49da3dc29d8d193b4fdd commit 88f2c58d1a857f0ccedd49da3dc29d8d193b4fdd Author: Konstantin Belousov AuthorDate: 2024-03-23 06:48:57 +0000 Commit: Konstantin Belousov CommitDate: 2024-03-23 06:59:00 +0000 cdevpriv(9): document devfs_foreach_cdevpriv() Sponsored by: The FreeBSD Foundation MFC after: 1 week --- share/man/man9/Makefile | 1 + share/man/man9/devfs_set_cdevpriv.9 | 41 +++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 87fb2f0906c9..597b487bb8ae 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -998,6 +998,7 @@ MLINKS+=dev_refthread.9 devvn_refthread.9 \ dev_refthread.9 dev_relthread.9 MLINKS+=devfs_set_cdevpriv.9 devfs_clear_cdevpriv.9 \ devfs_set_cdevpriv.9 devfs_get_cdevpriv.9 + devfs_set_cdevpriv.9 devfs_foreach_cdevpriv.9 MLINKS+=device_add_child.9 device_add_child_ordered.9 MLINKS+=device_enable.9 device_disable.9 \ device_enable.9 device_is_enabled.9 diff --git a/share/man/man9/devfs_set_cdevpriv.9 b/share/man/man9/devfs_set_cdevpriv.9 index 945d31a58d0a..3258ca082e5f 100644 --- a/share/man/man9/devfs_set_cdevpriv.9 +++ b/share/man/man9/devfs_set_cdevpriv.9 @@ -22,13 +22,14 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 2, 2015 +.Dd March 23, 2024 .Dt DEVFS_CDEVPRIV 9 .Os .Sh NAME .Nm devfs_set_cdevpriv , .Nm devfs_get_cdevpriv , -.Nm devfs_clear_cdevpriv +.Nm devfs_clear_cdevpriv , +.Nm devfs_foreach_cdevpriv .Nd manage per-open filedescriptor data for devices .Sh SYNOPSIS .In sys/param.h @@ -42,6 +43,12 @@ typedef void d_priv_dtor_t(void *data); .Fn devfs_set_cdevpriv "void *priv" "d_priv_dtor_t *dtr" .Ft void .Fn devfs_clear_cdevpriv "void" +.Ft int +.Fo devfs_foreach_cdevpriv +.Fa "struct cdev *dev" +.Fa "int (*cb)(void *data, void *arg)" +.Fa "void *arg" +.Fc .Sh DESCRIPTION The .Fn devfs_xxx_cdevpriv @@ -111,6 +118,36 @@ filedescriptor, or .Fn devfs_clear_cdevpriv was called. .El +.Pp +The function +.Fn devfs_foreach_cdevpriv +sequentially calls the function +.Fa cb +for each +.Nm cdevpriv +structure, currently associated with the +.Fa cdev +device. +The iterated +.Nm cdevpriv +data pointer and the user-supplied context +.Fa arg +are passed to the function +.Fa cb . +If +.Fa cb +returns non-zero value, the iteration stops on that element. +The +.Fn devfs_foreach_cdevpriv +returns the return value from the last call to +.Fa cb , +or zero if no +.Nm cdevpriv +data is currently associated with the device. +.Pp +Current implementation of the iterator makes it impossible to use +any blockable locking inside the callback +.Fa cb . .Sh SEE ALSO .Xr close 2 , .Xr open 2 ,