Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (c) 1999-2001 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Input driver event debug module - dumps all events into syslog
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) MODULE_DESCRIPTION("Input driver event debug module");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	printk(KERN_DEBUG pr_fmt("Event. Dev: %s, Type: %d, Code: %d, Value: %d\n"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	       dev_name(&handle->dev->dev), type, code, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static int evbug_connect(struct input_handler *handler, struct input_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			 const struct input_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct input_handle *handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	handle->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	handle->handler = handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	handle->name = "evbug";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	error = input_register_handle(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		goto err_free_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	error = input_open_device(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		goto err_unregister_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	printk(KERN_DEBUG pr_fmt("Connected device: %s (%s at %s)\n"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	       dev_name(&dev->dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	       dev->name ?: "unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	       dev->phys ?: "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  err_unregister_handle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	input_unregister_handle(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  err_free_handle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	kfree(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static void evbug_disconnect(struct input_handle *handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	printk(KERN_DEBUG pr_fmt("Disconnected device: %s\n"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	       dev_name(&handle->dev->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	input_close_device(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	input_unregister_handle(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	kfree(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static const struct input_device_id evbug_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	{ .driver_info = 1 },	/* Matches all devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{ },			/* Terminating zero entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) MODULE_DEVICE_TABLE(input, evbug_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static struct input_handler evbug_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.event =	evbug_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.connect =	evbug_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.disconnect =	evbug_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	.name =		"evbug",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	.id_table =	evbug_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static int __init evbug_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return input_register_handler(&evbug_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void __exit evbug_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	input_unregister_handler(&evbug_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) module_init(evbug_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) module_exit(evbug_exit);