HID: use standard debug APIs
authorThomas Weißschuh <linux@weissschuh.net>
Fri, 23 Dec 2022 21:30:19 +0000 (21:30 +0000)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Mon, 6 Feb 2023 14:11:45 +0000 (15:11 +0100)
The custom "debug" module parameter is fairly inflexible.
It can only manage debugging for all calls dbg_hid() at the same time.

Furthermore it creates a mismatch between calls to hid_dbg() which can
be managed by CONFIG_DYNAMIC_DEBUG and dbg_hid() which is managed by the
module parameter.

Furthermore the change to pr_debug() allows the debugging statements to
be completely compiled-out if desired.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Bastien Nocera <hadess@hadess.net>
Link: https://lore.kernel.org/r/20221223-hid-dbg-v1-1-5dcf8794f7f9@weissschuh.net
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
drivers/hid/hid-core.c
include/linux/hid.h

index 8ff08e6c2b13a2ffbb0045e22129dc5aa25302dd..7e7ae20e29ffb48de31538872f9cbb080c22c9ae 100644 (file)
 
 #define DRIVER_DESC "HID core driver"
 
-int hid_debug = 0;
-module_param_named(debug, hid_debug, int, 0600);
-MODULE_PARM_DESC(debug, "toggle HID debugging messages");
-EXPORT_SYMBOL_GPL(hid_debug);
-
 static int hid_ignore_special_drivers = 0;
 module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600);
 MODULE_PARM_DESC(ignore_special_drivers, "Ignore any special drivers and handle all devices by generic driver");
@@ -2910,10 +2905,6 @@ static int __init hid_init(void)
 {
        int ret;
 
-       if (hid_debug)
-               pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
-                       "debugfs is now used for inspecting the device (report descriptor, reports)\n");
-
        ret = bus_register(&hid_bus_type);
        if (ret) {
                pr_err("can't register hid bus\n");
index 3922b66c6da8667d5f81a85aa8551516fd744dee..6074d2a828fda4044d4bbaa62c8dc3c2708b71c4 100644 (file)
@@ -870,8 +870,6 @@ extern bool hid_is_usb(const struct hid_device *hdev);
 
 /* HID core API */
 
-extern int hid_debug;
-
 extern bool hid_ignore(struct hid_device *);
 extern int hid_add_device(struct hid_device *);
 extern void hid_destroy_device(struct hid_device *);
@@ -1179,11 +1177,7 @@ int hid_pidff_init(struct hid_device *hid);
 #define hid_pidff_init NULL
 #endif
 
-#define dbg_hid(fmt, ...)                                              \
-do {                                                                   \
-       if (hid_debug)                                                  \
-               printk(KERN_DEBUG "%s: " fmt, __FILE__, ##__VA_ARGS__); \
-} while (0)
+#define dbg_hid(fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
 
 #define hid_err(hid, fmt, ...)                         \
        dev_err(&(hid)->dev, fmt, ##__VA_ARGS__)