From nobody Wed Aug 6 14:20:31 2025 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 4bxsrw6vkwz63mj8; Wed, 06 Aug 2025 14:20: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bxsrw0znrz3rSn; Wed, 06 Aug 2025 14:20:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754490032; 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=r3+HyZ5iRt1uUMaGS3gX8HkqjXGycRbg21GJMi5a9qY=; b=TL3zr0KzAvIAmY20CBbq6XyS5kqRYpZqfRIOKXupKWmObdmlPu5rlNjLUu9GWfvxI6sPyO JRdclVdzV8C5YfloJp0WMrWIwyonsyGM1YBETKdvITSnQiXZlgwjQI1AQ8z6yTQbsLmnfD RHDN1/hIW3Re1ps3YsJLmKxWNgS8dPGtrG84417hTK3VoIZ2x0rKydx4gqiWvROUNpT4MC XxpFaObPTDLxtE7B8xDPAQxmz95xOcoURIKo183yy9m93c8ktyLdxZfXf8+zKVLuEst/C1 G7NQNZa1FOTVxwVQT7cn+otI83HuTKRgFIvqS5zlZmLP18k3lRlUIS2G+4pxuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754490032; 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=r3+HyZ5iRt1uUMaGS3gX8HkqjXGycRbg21GJMi5a9qY=; b=n4Eeedj6foKpvfL6B5QDTZ0KsXvrz8vjM4sVs4KDF1A+2M8Bf7gTcmERGFziFAhpxZvNMs gYAFge3w1kMTnSewuJiZDlH5p68urla37G5/M9ATWgdwKdAwK7FlKfGmMLdrE+yNR29Z0H b9+nOnllIC/aQQhq5aPcKoGzhiMH0fJDgFrvFdV0zOmoiBuo7uajSgZdJVrb2zDqRkV8BX gYl17mKu06N+QDiHcnneMOQ4ogXArv9YrbEpkaGqGZaWHwHKsNJdwh0cG8mBtEc+MVJxt2 e9gFBZ+/s2jX2Xj3TOYhbq26/LaAALJZ1rvrdSOKQ62gYAXcai/Ppu+6ptJX9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754490032; a=rsa-sha256; cv=none; b=SpZyXXubM+aoV3zMMGY7Dqqw/jC/iCiY2pHC6kODYPl9/UNGJd+9eaEqTOpwc44HUqxjds Jah1LcfMrnFvdPCzjhnJiAFKTsc4ZQSwYgvz2+LEZiuqaKKsEakKtgaqbwa19mD3Q8oTNZ 9ZU7YP8zYmDkA+/N4Pvd8ZURstU/cDVHufrAWg3UU5cPIPyNPmvvxRSkS18d8FtOpoUl5C JLdIugcKIAfCAsPiGBFMYQugcEjvH8nqoIEtRp42AA+ttOrY738F8CQpAPUj0ybbDfQaN5 gEO4kbJ7zZ/9DwyBEdGi8qs2zrctj68Of9TIs4hn2xnwAj/YM42xObl9AWNyug== 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 4bxsrw0XXHz8K4; Wed, 06 Aug 2025 14:20:32 +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 576EKVUM009613; Wed, 6 Aug 2025 14:20:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 576EKVP7009610; Wed, 6 Aug 2025 14:20:31 GMT (envelope-from git) Date: Wed, 6 Aug 2025 14:20:31 GMT Message-Id: <202508061420.576EKVP7009610@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: 872065688515 - main - libusb: implement libusb_wrap_sys_device 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 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: 872065688515c0c4549b568f7573eb9e7deeedd7 Auto-Submitted: auto-generated The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=872065688515c0c4549b568f7573eb9e7deeedd7 commit 872065688515c0c4549b568f7573eb9e7deeedd7 Author: ShengYi Hung AuthorDate: 2025-08-05 12:59:06 +0000 Commit: ShengYi Hung CommitDate: 2025-08-06 14:05:40 +0000 libusb: implement libusb_wrap_sys_device The libusb_wrap_sys_device function can wrap an opened fd from the system into a libusb handler. However, in FreeBSD's libusb implementation, a USB device contains two fds: one for control transfers and another for normal (bulk, interrupt, isochronous) transfers. This design makes it impossible for FreeBSD to implement this function without exposing a different structure in libusb.h to provide two fds. Therefore, we return LIBUSB_ERROR_NOT_SUPPORTED to maintain API compatibility. Approved by: makrj (mentor), lwhsu (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51739 --- lib/libusb/libusb.3 | 8 ++++++++ lib/libusb/libusb.h | 1 + lib/libusb/libusb10.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 3093737c05d7..09140c914d68 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -209,6 +209,14 @@ Decrement the reference counter of the device .Fa dev . .Pp .Ft int +.Fn libusb_wrap_sys_device "libusb_context *ctx" "intptr_t sys_dev" "libusb_device_handle **dev_handle" +This function creates a libusb handler from a previously opened fd +.Fa sys_dev . +This function is provided for compatibility and is currently unimplemented. +It always returns +.Dv LIBUSB_ERROR_NOT_SUPPORTED . +.Pp +.Ft int .Fn libusb_open "libusb_device *dev" "libusb_device_handle **devh" Open a device and obtain a device_handle. Returns 0 on success, diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index d8a3e4b62995..277b551c46a1 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -506,6 +506,7 @@ int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); libusb_device *libusb_ref_device(libusb_device * dev); void libusb_unref_device(libusb_device * dev); +int libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle); int libusb_open(libusb_device * dev, libusb_device_handle ** devh); libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id); void libusb_close(libusb_device_handle * devh); diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 5c116b39ea17..e226def0b7b6 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -1918,3 +1918,10 @@ libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer, { return (LIBUSB_ERROR_NOT_SUPPORTED); } + +int +libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, + libusb_device_handle **dev_handle) +{ + return (LIBUSB_ERROR_NOT_SUPPORTED); +}