From nobody Tue May 05 16:49:04 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 4g94Gt14FVz6bwKG for ; Tue, 05 May 2026 16:49:10 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g94Gt0Jn8z3wg7 for ; Tue, 05 May 2026 16:49:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777999750; 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=0H7CnDe30UDAuKxc3iBzs/n3QTnVDPe/FDHgdvzL91E=; b=EUCiSpj7K2FP2wPwFYXbZLjFu6Hwj3k2N04scOCCTq7C7gkzwjtv7VNuSGGWSvOZbX7MXI agYWlM7TTnK7aO7ojSVjnQSrMT1IMup3Tsn3f3ioXDcWA7oxjzKk1j0hQtVyfW7LE+dIIT uX6+9V+PQSZgHis5WbU+uGdlytGdvcensRFFwp9TOAWLZppHIGlvlnUWdDj/krupjUqVsM cPIN+ErB5CKLdj2jFSQyOPSjNezBTRl+3n24gj1aXFDrvVT2bACsvtp646zrvc8gm2VtUy Znc9Vw9j1/TExp3cf8gGcIm4Qg7/Z5UsfhTStMpOVkpKmR5VAdBPA8Bi/7Wh5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777999750; a=rsa-sha256; cv=none; b=uK1X1ELWOvoIvhlKB67jSkdMFJLSsI6lO2BAcj93gK6WcpzJ1x7FC5opCue2uSAO5Cxxi4 fVexVDLLyR+CN+PWAwSG1Mmc61yK1J1QSAk8s2tCiaGAE8vaG0vCGw/D6OFz0f3ysIBL9N OHtFmzRQ5hbPv3mm8+0+0n5aYppoKUTuR8S1cPiPPuq8nP7XB6OEyctGmlhr2a5O+7Y6sB kVCTKGrj+pCTtes/j5D7mnbcLIVJatHshIY+qKkU9srzKWoSW9/L7Dqgpu00SHgHY/JlrT EVHKpVlIzfdbsYr1gmCIv2UIYvCddW/4DNQ3OFecnxS3PlrtLH7xA2OtJPusnQ== 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=1777999750; 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=0H7CnDe30UDAuKxc3iBzs/n3QTnVDPe/FDHgdvzL91E=; b=cSef10CkqlJZmjjsSdKuquiXgTNSQhKNxGy5t6LGGt2YNOVay/rgdiF60VShZXRBJl6Z/H YDfRGwnMJApBj6OzH7cr3IyJoJVTUJcKqrVcmpXAEZns/7CyOX0Z6huVTeSmFBsVpZuJTL n3C22UPvD9feP7vE0y7tjBxM8z+LvSDqv597WWTS+bYhWsbbgTI3H+lrObcEOjludU5qbO 5hAjL/FNLWK2LmBdAbPcFddcK8nktTuzt4UvUh0gt7EFsY6tqpGnvps+0xcIj7cixdIEkx ZjCrGXGPC6oZ0LUPUhKIebzr8c6GMB87cXYG1jT/t2xkLauwK2+ZSwNQ8F4jIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g94Gs6zdKz1F9n for ; Tue, 05 May 2026 16:49:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 271bf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 05 May 2026 16:49:04 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: bf2c6d23ad09 - main - Revert "libusb: change callback register handler to int" 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: bf2c6d23ad0988a8b5dccebccdbc6fda9482c6a2 Auto-Submitted: auto-generated Date: Tue, 05 May 2026 16:49:04 +0000 Message-Id: <69fa1f80.271bf.2ee93ad@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=bf2c6d23ad0988a8b5dccebccdbc6fda9482c6a2 commit bf2c6d23ad0988a8b5dccebccdbc6fda9482c6a2 Author: ShengYi Hung AuthorDate: 2026-05-05 16:46:07 +0000 Commit: ShengYi Hung CommitDate: 2026-05-05 16:48:46 +0000 Revert "libusb: change callback register handler to int" This reverts commit ce9ced951a0b9d004a3b007d4ac6e9087a1301a2. We should handle backward compatibility before introducing this patch as people may rely on old ABI. --- lib/libusb/libusb.h | 5 +++-- lib/libusb/libusb10.c | 1 - lib/libusb/libusb10.h | 2 -- lib/libusb/libusb10_hotplug.c | 50 ++++++++++++++++--------------------------- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index ec60ce336e5a..46a2ed5eb8a6 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -293,6 +293,7 @@ struct libusb_context; struct libusb_device; struct libusb_transfer; struct libusb_device_handle; +struct libusb_hotplug_callback_handle_struct; struct libusb_pollfd { int fd; @@ -321,7 +322,7 @@ typedef struct libusb_device_handle libusb_device_handle; typedef struct libusb_pollfd libusb_pollfd; typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data); typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data); -typedef int libusb_hotplug_callback_handle; +typedef struct libusb_hotplug_callback_handle_struct *libusb_hotplug_callback_handle; typedef struct libusb_device_descriptor { uint8_t bLength; @@ -631,7 +632,7 @@ typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx, libusb_device *device, libusb_hotplug_event event, void *user_data); 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 callback_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); diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 517630900f34..56c9caedab16 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -205,7 +205,6 @@ libusb_init_context(libusb_context **context, memset(ctx, 0, sizeof(*ctx)); ctx->devd_pipe = -1; - ctx->next_callback_id = 1; debug = getenv("LIBUSB_DEBUG"); if (debug != NULL) { diff --git a/lib/libusb/libusb10.h b/lib/libusb/libusb10.h index 354ff003de3e..eced364ef857 100644 --- a/lib/libusb/libusb10.h +++ b/lib/libusb/libusb10.h @@ -80,7 +80,6 @@ struct libusb_hotplug_callback_handle_struct { int devclass; libusb_hotplug_callback_fn fn; void *user_data; - int id; }; TAILQ_HEAD(libusb_device_head, libusb_device); @@ -119,7 +118,6 @@ struct libusb_context { libusb_pollfd_added_cb fd_added_cb; libusb_pollfd_removed_cb fd_removed_cb; void *fd_cb_user_data; - int next_callback_id; }; struct libusb_device { diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c index fd979fd4db14..359c818b5720 100644 --- a/lib/libusb/libusb10_hotplug.c +++ b/lib/libusb/libusb10_hotplug.c @@ -176,9 +176,8 @@ libusb_hotplug_equal(libusb_device *_adev, libusb_device *_bdev) } static int -libusb_hotplug_filter(libusb_context *ctx, - struct libusb_hotplug_callback_handle_struct *pcbh, libusb_device *dev, - libusb_hotplug_event event) +libusb_hotplug_filter(libusb_context *ctx, libusb_hotplug_callback_handle pcbh, + libusb_device *dev, libusb_hotplug_event event) { if (!(pcbh->events & event)) return (0); @@ -217,7 +216,8 @@ libusb_hotplug_scan(void *arg) { struct pollfd pfd; struct libusb_device_head hotplug_devs; - struct libusb_hotplug_callback_handle_struct *acbh, *bcbh; + libusb_hotplug_callback_handle acbh; + libusb_hotplug_callback_handle bcbh; libusb_context *ctx = arg; libusb_device *temp; libusb_device *adev; @@ -343,7 +343,7 @@ int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *phandle) { - struct libusb_hotplug_callback_handle_struct *handle; + libusb_hotplug_callback_handle handle; struct libusb_device *adev; ctx = GET_CONTEXT(ctx); @@ -365,17 +365,6 @@ int libusb_hotplug_register_callback(libusb_context *ctx, if (handle == NULL) return (LIBUSB_ERROR_NO_MEM); - handle->events = events; - handle->vendor = vendor_id; - handle->product = product_id; - handle->devclass = dev_class; - handle->fn = cb_fn; - handle->user_data = user_data; - CTX_LOCK(ctx); - if ((handle->id = ctx->next_callback_id++) < 0) - handle->id = ctx->next_callback_id = 1; - CTX_UNLOCK(ctx); - HOTPLUG_LOCK(ctx); if (ctx->hotplug_handler == NO_THREAD) { libusb_hotplug_enumerate(ctx, &ctx->hotplug_devs); @@ -384,6 +373,12 @@ int libusb_hotplug_register_callback(libusb_context *ctx, &libusb_hotplug_scan, ctx) != 0) ctx->hotplug_handler = NO_THREAD; } + handle->events = events; + handle->vendor = vendor_id; + handle->product = product_id; + handle->devclass = dev_class; + handle->fn = cb_fn; + handle->user_data = user_data; if (flags & LIBUSB_HOTPLUG_ENUMERATE) { TAILQ_FOREACH(adev, &ctx->hotplug_devs, hotplug_entry) { @@ -400,32 +395,23 @@ int libusb_hotplug_register_callback(libusb_context *ctx, HOTPLUG_UNLOCK(ctx); if (phandle != NULL) - *phandle = handle->id; + *phandle = handle; return (LIBUSB_SUCCESS); } void libusb_hotplug_deregister_callback(libusb_context *ctx, - libusb_hotplug_callback_handle callback_handle) + libusb_hotplug_callback_handle handle) { - struct libusb_hotplug_callback_handle_struct *handle; + ctx = GET_CONTEXT(ctx); - ctx = GET_CONTEXT(ctx); - - if (ctx == NULL || callback_handle == 0) + if (ctx == NULL || handle == NULL) return; HOTPLUG_LOCK(ctx); - TAILQ_FOREACH(handle, &ctx->hotplug_cbh, entry) { - if (handle->id == callback_handle) - break; - } - if (handle == NULL) - goto clean; TAILQ_REMOVE(&ctx->hotplug_cbh, handle, entry); libusb_interrupt_event_handler(ctx); - -clean: HOTPLUG_UNLOCK(ctx); + free(handle); } @@ -433,13 +419,13 @@ void * libusb_hotplug_get_user_data(struct libusb_context *ctx, libusb_hotplug_callback_handle callback_handle) { - struct libusb_hotplug_callback_handle_struct *handle; + libusb_hotplug_callback_handle handle; ctx = GET_CONTEXT(ctx); HOTPLUG_LOCK(ctx); TAILQ_FOREACH(handle, &ctx->hotplug_cbh, entry) { - if (handle->id == callback_handle) + if (handle == callback_handle) break; } HOTPLUG_UNLOCK(ctx);