From nobody Mon Jul 21 06:17:14 2025 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 4blqtf5KZsz62D7R; Mon, 21 Jul 2025 06:17:14 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4blqtf34MDz3SpN; Mon, 21 Jul 2025 06:17:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078634; 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=WUd2ajOjXb5rXvIcbrhpN33DGQ1ZnKjSP4V+8pHQXTM=; b=jUv45wv2WwEczb+SDSS9JN3NqHF9iFilPocOLrVfwYQlVz08LW/xMa/v4sEDunAtXN7qLO HRHIx6Jlqfd7XEaQ+OZuitEdPcg3tN5iCnfJ+zSM22obCArptZUERHp+Dpln2OXL2ABbFi JfT8BeH6tm1mqGXBFw39tL3H73pNEgJH0cdaOzhyY00lgTE8Psr8dRwUqYEEG0icwBLf3h kk8/OKi8LqZWLzj/9h3FM4K8Pjkk02IKjkHlhc9KZi/atIpybc0NO97/gmhLNlTNt7uEZj RfR9hR6WtregXRjHDKou6WaDB1k7cWBUSZvUBF2L7PmKOlMFnOpXpMi3PG6KEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078634; 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=WUd2ajOjXb5rXvIcbrhpN33DGQ1ZnKjSP4V+8pHQXTM=; b=Hbj5blhh7NtD9gQ1EMqyOBPZs/EebeZ9dwApwl9TNtoWkfwS9xcNGba7S0Ny+a8qD7jylt BCQ433NpAA1J4zmrpSejo+ZlGZyxIZXMVbc4eMgUXpwQ0B7kQEox5r0UIgQIMpFjjVBjh2 5Xda7o8ijZojf8B9lLkuY/75raoXzwWcXUqVMr1zRe2CDjhbKZf1Kf8oIkYh/KWfCcouzC 1coXhtXI0fJrRw28qk2ev7228Zgd3aZBXmOHRKZplXzp9qCuJ1oppxur8V/L6l8FoDi1xU 0k/IGk9D4ZrekaYka1ma46jLFFZVudUjDN8Bvg1E6uquR6H1rWALxCZMg3pMrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753078634; a=rsa-sha256; cv=none; b=vN8B/ZikOtPQcLRIXjTZbPSaaJ9MJuTOc/yOZQhdMBu95b9F9QWUqXjmlGem3YUoDZMdsZ hXGqrrsZsJR+BS3YeOLoM6J/LnvO/nW0maeA/abfNCHhfGxyKGb7QkhdfFdfTfkLEOw2ZE M0LpO43zW132mhsXJsiyriWm6ZLrjkDMu9sG1iJhY4089+2MQktK8s+nSXb6A30T1gc24r LMxPyKT0qrWjIbPoxMIJEmt6TfWxxQZua0BeXZ2M5ltMRn2TORxpW1plFl/jvpF+dNxy9J jQh6A+/d4HWkUF1x+okH5oEmFlYxsaR5U5PGr3dzokAslARQddq8FS4Ww65Paw== 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 4blqtf2dM8zmVS; Mon, 21 Jul 2025 06:17:14 +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 56L6HEkC071300; Mon, 21 Jul 2025 06:17:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56L6HEdL071297; Mon, 21 Jul 2025 06:17:14 GMT (envelope-from git) Date: Mon, 21 Jul 2025 06:17:14 GMT Message-Id: <202507210617.56L6HEdL071297@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 9ca855653f32 - main - libusb: implement libusb_hotplug_get_user_data 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: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9ca855653f32605f266e5e457581ec3e68fd4ff9 Auto-Submitted: auto-generated The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=9ca855653f32605f266e5e457581ec3e68fd4ff9 commit 9ca855653f32605f266e5e457581ec3e68fd4ff9 Author: ShengYi Hung AuthorDate: 2025-07-09 08:30:52 +0000 Commit: ShengYi Hung CommitDate: 2025-07-21 06:15:58 +0000 libusb: implement libusb_hotplug_get_user_data libusb provides a function to get the callback userdata for a given callback since this structure is opaque to libusb user. Approved by: markj (mentor), lwhsu (mentor) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51223 --- lib/libusb/libusb.3 | 5 +++++ lib/libusb/libusb.h | 2 ++ lib/libusb/libusb10_hotplug.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index da927f8985a8..2e2ac8b1e98b 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -781,6 +781,11 @@ This function unregisters a hotplug filter. This function releases the memory storage in .Fa pollfds , and is safe to call when the argument is NULL. +.Pp void * +.Fn libusb_hotplug_get_user_data "struct libusb_context *ctx" "libusb_hotplug_callback_handle callback_handle" +This function returns the user data from the opaque +.Fa callback_handle , +or returns NULL if no matching handle is found. .Sh LIBUSB VERSION 0.1 COMPATIBILITY The library is also compliant with LibUSB version 0.1.12. .Pp diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 1962152c0b68..520b81da3a75 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -594,6 +594,8 @@ typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx, int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle); void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle); +void *libusb_hotplug_get_user_data(struct libusb_context *ctx, + libusb_hotplug_callback_handle callback_handle); /* Streams support */ diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c index 369539d4512e..9c46d4926bfa 100644 --- a/lib/libusb/libusb10_hotplug.c +++ b/lib/libusb/libusb10_hotplug.c @@ -414,3 +414,21 @@ void libusb_hotplug_deregister_callback(libusb_context *ctx, free(handle); } + +void * +libusb_hotplug_get_user_data(struct libusb_context *ctx, + libusb_hotplug_callback_handle callback_handle) +{ + libusb_hotplug_callback_handle handle; + + ctx = GET_CONTEXT(ctx); + + HOTPLUG_LOCK(ctx); + TAILQ_FOREACH(handle, &ctx->hotplug_cbh, entry) { + if (handle == callback_handle) + break; + } + HOTPLUG_UNLOCK(ctx); + + return (handle); +}