summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pyhalov <pyhalov@majordomo.ru>2019-06-15 19:41:58 +0300
committerOleg Pyhalov <pyhalov@majordomo.ru>2019-06-15 19:41:58 +0300
commit4809e45f3f9f896b85c1ceda03900f57419742c0 (patch)
tree35b857b9b6b2529e3291d549c23b599e9e3264af
parentinvoke panic (diff)
downloadlinux-panic-4809e45f3f9f896b85c1ceda03900f57419742c0.tar.gz
panic after any hid device plaggedHEADmaster
-rw-r--r--stick_driver.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/stick_driver.c b/stick_driver.c
index 1eb5177..1b9e3bf 100644
--- a/stick_driver.c
+++ b/stick_driver.c
@@ -2,6 +2,12 @@
#include <linux/kernel.h>
#include <linux/usb.h>
+/* #include <linux/hid.h */
+/*
+ * USB HID (Human Interface Device) interface class code
+ */
+#define USB_INTERFACE_CLASS_HID 3
+
MODULE_LICENSE ("GPL");
MODULE_AUTHOR ("Oleg Pyhalov");
MODULE_DESCRIPTION ("Module to invoke a kernel panic after USB connection.");
@@ -12,32 +18,39 @@ MODULE_VERSION ("0.1");
static int pen_probe (struct usb_interface *interface,
const struct usb_device_id *id)
{
- printk (KERN_INFO "[*] SolidusCode Pen drive (%04X:%04X) plugged\n",
+ printk (KERN_INFO "[*] sup2eng Pen drive (%04X:%04X) plugged\n",
id->idVendor, id->idProduct);
- panic ("USB was inserted. Bye.");
+ panic ("USB HID device was inserted. Panic!");
return 0; /* we will manage this device */
}
/* disconnect */
static void pen_disconnect (struct usb_interface *interface)
{
- printk (KERN_INFO "[*] SolidusCode Pen drive removed\n");
+ printk (KERN_INFO "[*] sup2eng Pen drive removed\n");
}
/* usb_device_id */
/* Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd */
/* Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub */
-static struct usb_device_id pen_table[] =
- {
- { USB_DEVICE (0x0627, 0x0001) },
- { } /* Terminating entry */
- };
-MODULE_DEVICE_TABLE (usb, pen_table);
+
+/* static struct usb_device_id pen_table[] = */
+/* { */
+/* { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, */
+/* { } /\* Terminating entry *\/ */
+/* }; */
+/* MODULE_DEVICE_TABLE (usb, pen_table); */
+
+static const struct usb_device_id pen_table[] = {
+ { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS,
+ .bInterfaceClass = USB_INTERFACE_CLASS_HID },
+ { } /* Terminating entry */
+};
/* usb_driver */
static struct usb_driver pen_driver =
{
- .name = "SolidusCode-USB Stick-Driver",
+ .name = "sup2eng-USB Stick-Driver",
.id_table = pen_table, /* usb_device_id */
.probe = pen_probe,
.disconnect = pen_disconnect
@@ -46,7 +59,7 @@ static struct usb_driver pen_driver =
static int __init pen_init (void)
{
int ret = -1;
- printk (KERN_INFO "[*] SolidusCode Constructor of driver");
+ printk (KERN_INFO "[*] sup2eng Constructor of driver");
printk (KERN_INFO "\tRegistering Driver with Kernel");
ret = usb_register (&pen_driver);
printk (KERN_INFO "\tRegistration is complete");
@@ -55,10 +68,12 @@ static int __init pen_init (void)
static void __exit pen_exit (void)
{
- printk (KERN_INFO "[*] SolidusCode Destructor of driver");
+ printk (KERN_INFO "[*] sup2eng Destructor of driver");
usb_deregister (&pen_driver);
printk (KERN_INFO "\tunregistration complete!");
}
+/* Entry point */
module_init(pen_init);
+
module_exit(pen_exit);