Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
HID: use debugfs for report dumping descriptor
Browse files Browse the repository at this point in the history
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 <jkosina@suse.cz>
  • Loading branch information
Jiri Kosina committed Jun 12, 2009
1 parent 8ebf975 commit a635f9d
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 122 deletions.
15 changes: 0 additions & 15 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ config HID

If unsure, say Y.

config HID_DEBUG
bool "HID debugging support"
default y
depends on HID
---help---
This option lets the HID layer output diagnostics about its internal
state, resolve HID usages, dump HID fields, etc. Individual HID drivers
use this debugging facility to output information about individual HID
devices, etc.

This feature is useful for those who are either debugging the HID parser
or any HID hardware device.

If unsure, say Y.

config HIDRAW
bool "/dev/hidraw raw HID device support"
depends on HID
Expand Down
5 changes: 4 additions & 1 deletion drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#
hid-objs := hid-core.o hid-input.o

ifdef CONFIG_DEBUG_FS
hid-objs += hid-debug.o
endif

obj-$(CONFIG_HID) += hid.o

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

hid-logitech-objs := hid-lg.o
Expand Down
13 changes: 10 additions & 3 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@
#define DRIVER_DESC "HID core driver"
#define DRIVER_LICENSE "GPL"

#ifdef CONFIG_HID_DEBUG
int hid_debug = 0;
module_param_named(debug, hid_debug, int, 0600);
MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)");
EXPORT_SYMBOL_GPL(hid_debug);
#endif

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

if (offset >= field->report_count) {
dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
hid_dump_field(field, 8);
return -1;
}
if (field->logical_minimum < 0) {
Expand Down Expand Up @@ -1721,6 +1718,8 @@ int hid_add_device(struct hid_device *hdev)
if (!ret)
hdev->status |= HID_STAT_ADDED;

hid_debug_register(hdev, dev_name(&hdev->dev));

return ret;
}
EXPORT_SYMBOL_GPL(hid_add_device);
Expand Down Expand Up @@ -1768,6 +1767,7 @@ static void hid_remove_device(struct hid_device *hdev)
{
if (hdev->status & HID_STAT_ADDED) {
device_del(&hdev->dev);
hid_debug_unregister(hdev);
hdev->status &= ~HID_STAT_ADDED;
}
}
Expand Down Expand Up @@ -1843,6 +1843,10 @@ static int __init hid_init(void)
{
int ret;

if (hid_debug)
printk(KERN_WARNING "HID: hid_debug parameter has been deprecated. "
"Debugging data are now provided via debugfs\n");

ret = bus_register(&hid_bus_type);
if (ret) {
printk(KERN_ERR "HID: can't register hid bus\n");
Expand All @@ -1853,6 +1857,8 @@ static int __init hid_init(void)
if (ret)
goto err_bus;

hid_debug_init();

return 0;
err_bus:
bus_unregister(&hid_bus_type);
Expand All @@ -1862,6 +1868,7 @@ static int __init hid_init(void)

static void __exit hid_exit(void)
{
hid_debug_exit();
hidraw_exit();
bus_unregister(&hid_bus_type);
}
Expand Down
Loading

0 comments on commit a635f9d

Please sign in to comment.