Skip to content

Commit a635f9d

Browse files
author
Jiri Kosina
committed
HID: use debugfs for report dumping descriptor
It is a little bit inconvenient for people who have some non-standard HID hardware (usually violating the HID specification) to have to recompile kernel with CONFIG_HID_DEBUG to be able to see kernel's perspective of the HID report descriptor and observe the parsed events. Plus the messages are then mixed up inconveniently with the rest of the dmesg stuff. This patch implements /sys/kernel/debug/hid/<device>/rdesc file, which represents the kernel's view of report descriptor (both the raw report descriptor data and parsed contents). With all the device-specific debug data being available through debugfs, there is no need for keeping CONFIG_HID_DEBUG, as the 'debug' parameter to the hid module will now only output only driver-specific debugging options, which has absolutely minimal memory footprint, just a few error messages and one global flag (hid_debug). We use the current set of output formatting functions. The ones that need to be used both for one-shot rdesc seq_file and also for continuous flow of data (individual reports, as being sent by the device) distinguish according to the passed seq_file parameter, and if it is NULL, it still output to kernel ringbuffer, otherwise the corresponding seq_file is used for output. The format of the output is preserved. Signed-off-by: Jiri Kosina <[email protected]>
1 parent 8ebf975 commit a635f9d

File tree

8 files changed

+195
-122
lines changed

8 files changed

+195
-122
lines changed

drivers/hid/Kconfig

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ config HID
3131

3232
If unsure, say Y.
3333

34-
config HID_DEBUG
35-
bool "HID debugging support"
36-
default y
37-
depends on HID
38-
---help---
39-
This option lets the HID layer output diagnostics about its internal
40-
state, resolve HID usages, dump HID fields, etc. Individual HID drivers
41-
use this debugging facility to output information about individual HID
42-
devices, etc.
43-
44-
This feature is useful for those who are either debugging the HID parser
45-
or any HID hardware device.
46-
47-
If unsure, say Y.
48-
4934
config HIDRAW
5035
bool "/dev/hidraw raw HID device support"
5136
depends on HID

drivers/hid/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
#
44
hid-objs := hid-core.o hid-input.o
55

6+
ifdef CONFIG_DEBUG_FS
7+
hid-objs += hid-debug.o
8+
endif
9+
610
obj-$(CONFIG_HID) += hid.o
711

8-
hid-$(CONFIG_HID_DEBUG) += hid-debug.o
912
hid-$(CONFIG_HIDRAW) += hidraw.o
1013

1114
hid-logitech-objs := hid-lg.o

drivers/hid/hid-core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@
4444
#define DRIVER_DESC "HID core driver"
4545
#define DRIVER_LICENSE "GPL"
4646

47-
#ifdef CONFIG_HID_DEBUG
4847
int hid_debug = 0;
4948
module_param_named(debug, hid_debug, int, 0600);
5049
MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)");
5150
EXPORT_SYMBOL_GPL(hid_debug);
52-
#endif
5351

5452
/*
5553
* Register a new report for a device.
@@ -987,7 +985,6 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
987985

988986
if (offset >= field->report_count) {
989987
dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
990-
hid_dump_field(field, 8);
991988
return -1;
992989
}
993990
if (field->logical_minimum < 0) {
@@ -1721,6 +1718,8 @@ int hid_add_device(struct hid_device *hdev)
17211718
if (!ret)
17221719
hdev->status |= HID_STAT_ADDED;
17231720

1721+
hid_debug_register(hdev, dev_name(&hdev->dev));
1722+
17241723
return ret;
17251724
}
17261725
EXPORT_SYMBOL_GPL(hid_add_device);
@@ -1768,6 +1767,7 @@ static void hid_remove_device(struct hid_device *hdev)
17681767
{
17691768
if (hdev->status & HID_STAT_ADDED) {
17701769
device_del(&hdev->dev);
1770+
hid_debug_unregister(hdev);
17711771
hdev->status &= ~HID_STAT_ADDED;
17721772
}
17731773
}
@@ -1843,6 +1843,10 @@ static int __init hid_init(void)
18431843
{
18441844
int ret;
18451845

1846+
if (hid_debug)
1847+
printk(KERN_WARNING "HID: hid_debug parameter has been deprecated. "
1848+
"Debugging data are now provided via debugfs\n");
1849+
18461850
ret = bus_register(&hid_bus_type);
18471851
if (ret) {
18481852
printk(KERN_ERR "HID: can't register hid bus\n");
@@ -1853,6 +1857,8 @@ static int __init hid_init(void)
18531857
if (ret)
18541858
goto err_bus;
18551859

1860+
hid_debug_init();
1861+
18561862
return 0;
18571863
err_bus:
18581864
bus_unregister(&hid_bus_type);
@@ -1862,6 +1868,7 @@ static int __init hid_init(void)
18621868

18631869
static void __exit hid_exit(void)
18641870
{
1871+
hid_debug_exit();
18651872
hidraw_exit();
18661873
bus_unregister(&hid_bus_type);
18671874
}

0 commit comments

Comments
 (0)