Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 24a6945

Browse files
nevackchenrui333
andauthored
usbutils: revisited portable.patch (#948)
Co-authored-by: Rui Chen <[email protected]>
1 parent 3583908 commit 24a6945

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

usbutils/portable.patch

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,18 @@ index 3e93c23..2a97df6 100644
115115

116116
#endif
117117
diff --git a/meson.build b/meson.build
118-
index c522283..7344f40 100644
118+
index c522283..ee4469f 100644
119119
--- a/meson.build
120120
+++ b/meson.build
121+
@@ -76,7 +76,7 @@ add_project_arguments('-include', 'config.h', language : 'c')
122+
#####################
123+
# man page generation
124+
#####################
125+
-install_man(['man/lsusb.8', 'man/lsusb.py.1', 'man/usb-devices.1', 'man/usbhid-dump.8'])
126+
+man_pages = ['man/lsusb.8', 'man/usbhid-dump.8']
127+
128+
129+
##########################
121130
@@ -87,13 +87,9 @@ lsusb_sources = [
122131
'desc-defs.h',
123132
'desc-dump.c',
@@ -158,7 +167,7 @@ index c522283..7344f40 100644
158167
+ ]
159168
+endif
160169
+
161-
+if libudev.found()
170+
+if get_option('with_udev') and libudev.found()
162171
+ add_project_arguments('-DHAVE_UDEV', language : 'c')
163172
+
164173
+ lsusb_sources += [
@@ -174,6 +183,23 @@ index c522283..7344f40 100644
174183

175184
################################
176185
# usbhid-dump build instructions
186+
@@ -128,6 +152,7 @@ usbhid_sources = [
187+
188+
executable('usbhid-dump', usbhid_sources, dependencies: libusb, install: true)
189+
190+
+if get_option('with_sysfs')
191+
##############################
192+
# usbreset build instructions
193+
##############################
194+
@@ -156,3 +181,8 @@ install_data(usb_devices_sources, install_dir: get_option('bindir'), install_mod
195+
# Also a hack, like was done for usb-devices, as this is "just" a script and
196+
# doesn't need to be compiled.
197+
install_data(files('lsusb.py'), install_dir: get_option('bindir'), install_mode: 'rwxr-xr-x')
198+
+
199+
+man_pages += ['man/lsusb.py.1', 'man/usb-devices.1']
200+
+endif
201+
+
202+
+install_man(man_pages)
177203
diff --git a/meson_options.txt b/meson_options.txt
178204
new file mode 100644
179205
index 0000000..aff1fc8
@@ -185,10 +211,10 @@ index 0000000..aff1fc8
185211
+option('with_tree_mode', type : 'boolean', value : false)
186212
diff --git a/names_no_udev.c b/names_no_udev.c
187213
new file mode 100644
188-
index 0000000..5712252
214+
index 0000000..9494b48
189215
--- /dev/null
190216
+++ b/names_no_udev.c
191-
@@ -0,0 +1,227 @@
217+
@@ -0,0 +1,222 @@
192218
+// SPDX-License-Identifier: GPL-2.0-or-later
193219
+/*
194220
+ * USB name database manipulation routines
@@ -212,7 +238,9 @@ index 0000000..5712252
212238
+
213239
+#include "usb-spec.h"
214240
+#include "names.h"
215-
+
241+
+#ifdef HAVE_SYSFS
242+
+#include "sysfs.h"
243+
+#endif
216244
+
217245
+/* ---------------------------------------------------------------------- */
218246
+
@@ -274,42 +302,27 @@ index 0000000..5712252
274302
+
275303
+const char *names_vendor(uint16_t vendorid)
276304
+{
277-
+ char modalias[64];
278-
+
279-
+ sprintf(modalias, "usb:v%04X*", vendorid);
280-
+ return hwdb_get(modalias, "ID_VENDOR_FROM_DATABASE");
305+
+ return NULL;
281306
+}
282307
+
283308
+const char *names_product(uint16_t vendorid, uint16_t productid)
284309
+{
285-
+ char modalias[64];
286-
+
287-
+ sprintf(modalias, "usb:v%04Xp%04X*", vendorid, productid);
288-
+ return hwdb_get(modalias, "ID_MODEL_FROM_DATABASE");
310+
+ return NULL;
289311
+}
290312
+
291313
+const char *names_class(uint8_t classid)
292314
+{
293-
+ char modalias[64];
294-
+
295-
+ sprintf(modalias, "usb:v*p*d*dc%02X*", classid);
296-
+ return hwdb_get(modalias, "ID_USB_CLASS_FROM_DATABASE");
315+
+ return NULL;
297316
+}
298317
+
299318
+const char *names_subclass(uint8_t classid, uint8_t subclassid)
300319
+{
301-
+ char modalias[64];
302-
+
303-
+ sprintf(modalias, "usb:v*p*d*dc%02Xdsc%02X*", classid, subclassid);
304-
+ return hwdb_get(modalias, "ID_USB_SUBCLASS_FROM_DATABASE");
320+
+ return NULL;
305321
+}
306322
+
307323
+const char *names_protocol(uint8_t classid, uint8_t subclassid, uint8_t protocolid)
308324
+{
309-
+ char modalias[64];
310-
+
311-
+ sprintf(modalias, "usb:v*p*d*dc%02Xdsc%02Xdp%02X*", classid, subclassid, protocolid);
312-
+ return hwdb_get(modalias, "ID_USB_PROTOCOL_FROM_DATABASE");
325+
+ return NULL;
313326
+}
314327
+
315328
+const char *names_audioterminal(uint16_t termt)
@@ -406,6 +419,14 @@ index 0000000..5712252
406419
+
407420
+ if (have_vendor && have_product)
408421
+ return;
422+
+#ifdef HAVE_SYSFS
423+
+ if (get_sysfs_name(sysfs_name, sizeof(sysfs_name), dev) >= 0) {
424+
+ if (!have_vendor)
425+
+ read_sysfs_prop(vendor, vendor_len, sysfs_name, "manufacturer");
426+
+ if (!have_product)
427+
+ read_sysfs_prop(product, product_len, sysfs_name, "product");
428+
+ }
429+
+#endif
409430
+}
410431
+
411432
+int names_init(void)

0 commit comments

Comments
 (0)