Commit a184cf98 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: make sure input handlers define only one processing method

Input core expects input handlers to be either filters, or regular
handlers, but not both. Additionally, for regular handlers it does
not make sense to define both single event method and batch method.

Refuse registering handler if it defines more than one method.
Reviewed-by: default avatarJeff LaBundy <jeff@labundy.com>
Reviewed-by: default avatarBenjamin Tissoires <bentiss@kernel.org>
Link: https://lore.kernel.org/r/20240703213756.3375978-3-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent b3d65108
......@@ -2517,6 +2517,26 @@ void input_unregister_device(struct input_dev *dev)
}
EXPORT_SYMBOL(input_unregister_device);
static int input_handler_check_methods(const struct input_handler *handler)
{
int count = 0;
if (handler->filter)
count++;
if (handler->events)
count++;
if (handler->event)
count++;
if (count > 1) {
pr_err("%s: only one event processing method can be defined (%s)\n",
__func__, handler->name);
return -EINVAL;
}
return 0;
}
/**
* input_register_handler - register a new input handler
* @handler: handler to be registered
......@@ -2530,6 +2550,10 @@ int input_register_handler(struct input_handler *handler)
struct input_dev *dev;
int error;
error = input_handler_check_methods(handler);
if (error)
return error;
error = mutex_lock_interruptible(&input_mutex);
if (error)
return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment