aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2009-06-12 09:20:55 -0400
committerJiri Kosina <jkosina@suse.cz>2009-06-12 09:20:55 -0400
commita635f9dd83f3382577f4544a96df12356e951a40 (patch)
treec6fa27df6d01c34e304a32c9f423d569f7358346 /drivers/hid/hid-core.c
parent8ebf975608aaebd7feb33d77f07ba21a6380e086 (diff)
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 <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 8551693d645f..d4317db85b54 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -44,12 +44,10 @@
44#define DRIVER_DESC "HID core driver" 44#define DRIVER_DESC "HID core driver"
45#define DRIVER_LICENSE "GPL" 45#define DRIVER_LICENSE "GPL"
46 46
47#ifdef CONFIG_HID_DEBUG
48int hid_debug = 0; 47int hid_debug = 0;
49module_param_named(debug, hid_debug, int, 0600); 48module_param_named(debug, hid_debug, int, 0600);
50MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)"); 49MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)");
51EXPORT_SYMBOL_GPL(hid_debug); 50EXPORT_SYMBOL_GPL(hid_debug);
52#endif
53 51
54/* 52/*
55 * Register a new report for a device. 53 * Register a new report for a device.
@@ -987,7 +985,6 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
987 985
988 if (offset >= field->report_count) { 986 if (offset >= field->report_count) {
989 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 987 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
990 hid_dump_field(field, 8);
991 return -1; 988 return -1;
992 } 989 }
993 if (field->logical_minimum < 0) { 990 if (field->logical_minimum < 0) {
@@ -1721,6 +1718,8 @@ int hid_add_device(struct hid_device *hdev)
1721 if (!ret) 1718 if (!ret)
1722 hdev->status |= HID_STAT_ADDED; 1719 hdev->status |= HID_STAT_ADDED;
1723 1720
1721 hid_debug_register(hdev, dev_name(&hdev->dev));
1722
1724 return ret; 1723 return ret;
1725} 1724}
1726EXPORT_SYMBOL_GPL(hid_add_device); 1725EXPORT_SYMBOL_GPL(hid_add_device);
@@ -1768,6 +1767,7 @@ static void hid_remove_device(struct hid_device *hdev)
1768{ 1767{
1769 if (hdev->status & HID_STAT_ADDED) { 1768 if (hdev->status & HID_STAT_ADDED) {
1770 device_del(&hdev->dev); 1769 device_del(&hdev->dev);
1770 hid_debug_unregister(hdev);
1771 hdev->status &= ~HID_STAT_ADDED; 1771 hdev->status &= ~HID_STAT_ADDED;
1772 } 1772 }
1773} 1773}
@@ -1843,6 +1843,10 @@ static int __init hid_init(void)
1843{ 1843{
1844 int ret; 1844 int ret;
1845 1845
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
1846 ret = bus_register(&hid_bus_type); 1850 ret = bus_register(&hid_bus_type);
1847 if (ret) { 1851 if (ret) {
1848 printk(KERN_ERR "HID: can't register hid bus\n"); 1852 printk(KERN_ERR "HID: can't register hid bus\n");
@@ -1853,6 +1857,8 @@ static int __init hid_init(void)
1853 if (ret) 1857 if (ret)
1854 goto err_bus; 1858 goto err_bus;
1855 1859
1860 hid_debug_init();
1861
1856 return 0; 1862 return 0;
1857err_bus: 1863err_bus:
1858 bus_unregister(&hid_bus_type); 1864 bus_unregister(&hid_bus_type);
@@ -1862,6 +1868,7 @@ err:
1862 1868
1863static void __exit hid_exit(void) 1869static void __exit hid_exit(void)
1864{ 1870{
1871 hid_debug_exit();
1865 hidraw_exit(); 1872 hidraw_exit();
1866 bus_unregister(&hid_bus_type); 1873 bus_unregister(&hid_bus_type);
1867} 1874}