From nobody Tue Jun 23 14:29:32 2026 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 4gl6s83pybz6hVB0 for ; Tue, 23 Jun 2026 14:29:32 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gl6s82nV1z3w0x for ; Tue, 23 Jun 2026 14:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782224972; 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=/cSk9ixsXxK5fg5rTUyXabSBqT5LD/OAMZPwM3pxBNI=; b=RrrvgXPN+Ovm53SNoNEkFEndGsL1hz9LOol9hadgo+wSfmRmjSFprDsxWxb5URfzo7kq7R YH0v9n5cMFtypMk44NPgxO5UXbw0cvM3mPILjPk1HC/FOpjEmzpIIWAfybHPnaRiixLVbm ENIVQGfs7Z77NLhUOSYxC24bxO1wpqOcfwib66RCCrMpdav71JpGGYkLEEh44bKIztSVWF DqAUChm8VSIZiEnSGKhEfetLrMXfe3nKcHf/ktAeHf44f6a33oEiiDRoKPEFSqlNcWl1yp e+BW8SvhzoD+5HuneV5IAf4HO0GOXnxLrzon8otcodcUbrYkoFiBPo/vAJYSVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782224972; a=rsa-sha256; cv=none; b=sXg7m5MgY3+PN6JUiNdvGBpgeDKGyaEaev0qzjLHw+IGGM7MXkZ3DONYKI/EmH05Te8ELC 1CZG59daB4Aqrp9l4QKZ+iN8/z53aQ9c3rsgfXpRLTm4Bz9FcwSQ4u6ExhWTGO+Zzzzou0 +0cZkjYftNsCtGlUHvjfUrH9k7KaSQEXty26j0E9pkQ82N3LfwnHDsHhUpX13HiBXeG6Qr UUD18RxEsHLIbAaYFGSnF/j0lKEAxGFXmJHvp1LF2VUn/UMU0SnpA5duKbBWln0zMbiYoo fzfupLxys7d7glaqUqU5/ESCHThk2W/b850W72eboD9wW+B1yYzyyRhqPgb7hA== 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=1782224972; 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=/cSk9ixsXxK5fg5rTUyXabSBqT5LD/OAMZPwM3pxBNI=; b=e/Ijy1JzHl0wToUAZAk37nJKiTp9fKnriZSvbwxaZpEaFPl/1Wzer6gET5jshMiq9FaJAb 9OMqK5/mv2xYFs7IJ8y6E8raPFU+gVFiGt9MyRSunqh92BIX0x8lZIWKUsVmg/hijvyiWP i6GEvKzvlW3CoYvpG6DhxtlXnm8wLA89B5BYnshl7P1kx4FtVJglThWM2+5MHCHyyYn9Ur EAbEdDSKctKdHZHrDgdKVIFoy1YWDA796zME1EJDHF/PEEqTaP0mdjUSHYm4lQOdP5xskY L6CIAPd/vgMFvdZaXdl2B36vz3W9OsMKc0Y+JRbnnTAsswZzOd4ZbNUF8TStgw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gl6s81Yj0zdjR for ; Tue, 23 Jun 2026 14:29:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19824 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 23 Jun 2026 14:29:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 25c225106475 - main - libusb: Implement libusb_set_log_cb 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 25c2251064752b0ced310b1ed3795c8a68849b1c Auto-Submitted: auto-generated Date: Tue, 23 Jun 2026 14:29:32 +0000 Message-Id: <6a3a984c.19824.6def024a@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=25c2251064752b0ced310b1ed3795c8a68849b1c commit 25c2251064752b0ced310b1ed3795c8a68849b1c Author: ShengYi Hung AuthorDate: 2026-06-23 14:03:09 +0000 Commit: ShengYi Hung CommitDate: 2026-06-23 14:28:49 +0000 libusb: Implement libusb_set_log_cb Reviewed by: adrian Event: Halifax Hackathon 202606 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57770 --- lib/libusb/Makefile | 2 ++ lib/libusb/libusb.3 | 18 +++++++++++++++++- lib/libusb/libusb.h | 6 ++++++ lib/libusb/libusb10.c | 12 ++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile index f11083c94c86..af031ecb0544 100644 --- a/lib/libusb/Makefile +++ b/lib/libusb/Makefile @@ -73,6 +73,8 @@ MLINKS += libusb.3 libusb_has_capability.3 MLINKS += libusb.3 libusb_strerror.3 MLINKS += libusb.3 libusb_error_name.3 MLINKS += libusb.3 libusb_set_debug.3 +MLINKS += libusb.3 libusb_set_option.3 +MLINKS += libusb.3 libusb_set_log_cb.3 MLINKS += libusb.3 libusb_get_device_list.3 MLINKS += libusb.3 libusb_free_device_list.3 MLINKS += libusb.3 libusb_get_bus_number.3 diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index ff1d0b950b4b..42b2e90f148e 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 22, 2026 +.Dd June 23, 2026 .Dt LIBUSB 3 .Os .Sh NAME @@ -125,6 +125,22 @@ customize default callback function with .Fa value . .El .Pp +.Ft void +.Fn libusb_set_log_cb "libusb_context *ctx" "libusb_log_cb cb" "int mode" +Set the log handler to +.Fa cb . +The +.Fa mode +argument is a bitmask that selects which log messages the callback handles: +.Bl -tag -width LIBUSB_LOG_CB_CONTEXT -offset indent +.It Va LIBUSB_LOG_CB_GLOBAL +The callback handles global log messages and is inherited by all +subsequently created contexts. +.It Va LIBUSB_LOG_CB_CONTEXT +The callback handles log messages of the context +.Fa ctx . +.El +.Pp .Ft const char * .Fn libusb_strerror "int code" Get the ASCII representation of the error given by the diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 95f7faf900f8..1cf860cbb8ab 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -296,6 +296,11 @@ enum libusb_option { LIBUSB_OPTION_MAX = 4, }; +enum libusb_log_cb_mode { + LIBUSB_LOG_CB_GLOBAL = (1 << 0), + LIBUSB_LOG_CB_CONTEXT = (1 << 1), +}; + /* libusb structures */ struct libusb_context; @@ -675,6 +680,7 @@ int libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int void libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id); uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer); int libusb_set_option(libusb_context *ctx, enum libusb_option option, ...); +void libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode); #if 0 { /* indent fix */ diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index bd3c25c0f052..02507110d909 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -2160,3 +2160,15 @@ end: va_end(args); return (err); } + +void +libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode) +{ + if ((mode & LIBUSB_LOG_CB_GLOBAL) && usbi_default_context != NULL) + usbi_default_context->log_cb = cb; + if (mode & LIBUSB_LOG_CB_CONTEXT) { + ctx = GET_CONTEXT(ctx); + if (ctx != NULL) + ctx->log_cb = cb; + } +}