Re: [PATCH] usbip: tools: Add usbip host driver availability check
From: Zongmin Zhou
Date: Wed Mar 11 2026 - 22:18:25 EST
On 2026/3/11 20:13, Greg KH wrote:
On Tue, Mar 03, 2026 at 04:17:20PM +0800, Zongmin Zhou wrote:Thanks a lot for your valuable feedback! I fully understand your concerns on bus type hardcoding.
From: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>I think the "bus type" is changing in newer kernel versions, so be
Currently, usbip_generic_driver_open() doesn't verify that the required
kernel module (usbip-host or usbip-vudc) is actually loaded.
The function returns success even when no driver is present,
leading to usbipd daemon run success without driver loaded.
So add a check function to ensure usbip host driver has been loaded.
Signed-off-by: Zongmin Zhou <zhouzongmin@xxxxxxxxxx>
---
tools/usb/usbip/libsrc/usbip_device_driver.c | 2 ++
tools/usb/usbip/libsrc/usbip_host_common.c | 31 ++++++++++++++++++++
tools/usb/usbip/libsrc/usbip_host_common.h | 2 ++
tools/usb/usbip/libsrc/usbip_host_driver.c | 2 ++
4 files changed, 37 insertions(+)
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
index 927a151fa9aa..6da000fab26d 100644
--- a/tools/usb/usbip/libsrc/usbip_device_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
@@ -147,6 +147,8 @@ static int usbip_device_driver_open(struct usbip_host_driver *hdriver)
struct usbip_host_driver device_driver = {
.edev_list = LIST_HEAD_INIT(device_driver.edev_list),
.udev_subsystem = "udc",
+ .bus_type = "platform",
careful about attempting to hard-code anything like this. Devices can
move around between bus types just fine, that is not how they should
ever be referenced.
I sincerely apologize for not fully considering the compatibility of kernel version changes
and the design consistency of the project in the initial patch.
In the current usbip codebase (libsrc/usbip_common.h),
macros such as SYSFS_BUS_TYPE (defined as "usb") have long been
used to manage the sysfs directory names related to bus type,
and functions like write_sysfs_attribute rely on these macros to access the driver's sysfs interface.
So, can I follow the existing design plan? add macros in usbip_common.h
to unify the bus type definition of different drivers.
This way, any future kernel bus type changes can be adapted by only modifying the macro, not scattered code.
Looking forward to your reply.
Best regards.
thanks,
greg k-h