From nobody Sat Mar 30 08:32:53 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 4V69Wp01GHz5GXLT; Sat, 30 Mar 2024 08:32:54 +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 4V69Wn5J5yz4YGs; Sat, 30 Mar 2024 08:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711787573; 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=jEOVjXFx28w5OcfwiLRBWm7j2bXRfP83LsXl6gy4egk=; b=Z+sh5deWm4t5Reea2s1oA+/4ZuF+GHY5CzNfz44UtOnGCTQi8VAwGX/tk2s7xr/J3x+5se dPjrM25+lpB5ht2f/iBPCneWcj6L/X+S2xnCl37USSAiqhS5/9HUAxVNT7gJlz/DBB0uoe frhdKzTRoyres8rKnkBCNfdlFhhnamXPEQRrCOoOqd+N/LXsiKGiuiU2hacKLSEB/K+8rl nhePD4b6kJW75f94mZfUwX6baP8+0NTjH/nHzalqEAQpJxcf9qqA0J40i6WQ7xZRfMhhzz t8ZAeUjGUvApKwpiZR1vv4SIW/WEsjs7ICCyffaBl+O1CBAyopv2EWCQ7WwXmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711787573; a=rsa-sha256; cv=none; b=hIu2ctMic18A+LtbRtlMtiQeso3ncwayitlp6RxDKXMI1wDeX112mwU+YVw0SNwe1pyJ5S gSIxPIAdfY+Noq/sGDfu0HZMpDTms5hi7tuaE1JihlKGyELSKrQOrbdSdPrn9WArHOFngq p7bKxfg7Rrc5kIdWdnNBwUTKyQ8ynbyIFAkZUvC34pgEap559YqVt1VY1fI8vYi5O6KQtj cxAD4y50zScyX8hU67mMcllx1iGzvAYruac+HH8W+O9nkQDrZWIvEgR2QB5tJ52wbkYKw1 FhCW1xOcDFr2nIXkLnMQadzfggXXLSSaPHkwQaGNsGB/VKl37GxrRR8EbmybHQ== 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=1711787573; 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=jEOVjXFx28w5OcfwiLRBWm7j2bXRfP83LsXl6gy4egk=; b=Nfhqilpn9AYzR50WxN8NDJW6duPGLe6Gil396lO8dkoJfRTDXE8G/+FUJ8rixEhvL/I+i8 dxWrbuGoPn4I0Mw3BpNLxxK2yyZJdRGNjXralzcpfBaVuBfx9JI59zJ8IIS3KSx0i0DWoW xPjm/H8vJGvs+mXZESx4rlcRZAJ3badV5/TTUH4fKRKkHqRbmMkc7dEwa8IkpCGlHySKxf dZLVCUiTvrS1sXnm97nMtMpz/KFuHC26hp7qPzxi+KIBEGtrSHWQs5DwpBTkWyKHkrszgu ExpYpHH4tI7lmVnhlnODNtwvsNpjWXaVXr6kKuS97tLLmYTFeDbyBndNtkrARg== 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 4V69Wn34lVzn5t; Sat, 30 Mar 2024 08:32:53 +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 42U8WrYr040920; Sat, 30 Mar 2024 08:32:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42U8WrlQ040917; Sat, 30 Mar 2024 08:32:53 GMT (envelope-from git) Date: Sat, 30 Mar 2024 08:32:53 GMT Message-Id: <202403300832.42U8WrlQ040917@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f13afa7f5478 - stable/13 - cdevpriv(9): document devfs_foreach_cdevpriv() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: f13afa7f547884ad0777527b4156eb0df574fe50 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f13afa7f547884ad0777527b4156eb0df574fe50 commit f13afa7f547884ad0777527b4156eb0df574fe50 Author: Konstantin Belousov AuthorDate: 2024-03-23 06:48:57 +0000 Commit: Konstantin Belousov CommitDate: 2024-03-30 08:32:23 +0000 cdevpriv(9): document devfs_foreach_cdevpriv() (cherry picked from commit 88f2c58d1a857f0ccedd49da3dc29d8d193b4fdd) --- share/man/man9/Makefile | 3 ++- share/man/man9/devfs_set_cdevpriv.9 | 41 +++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 30712ab4f987..ca17497fc490 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -992,7 +992,8 @@ MLINKS+=dev_clone.9 drain_dev_clone_events.9 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_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 ,