Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c50ad34 authored by Anshul Garg's avatar Anshul Garg Committed by Dmitry Torokhov
Browse files

Input: do not try to filter out events if handler is not a filter



If given input handler is not a filter there is no point is iterating list
of events in a packet to see if some of them need to be filtered out.

Signed-off-by: default avatarAnshul Garg <anshul.g@samsung.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 5ab17145
Loading
Loading
Loading
Loading
+14 −10
Original line number Original line Diff line number Diff line
@@ -100,23 +100,24 @@ static unsigned int input_to_handler(struct input_handle *handle,
	struct input_value *end = vals;
	struct input_value *end = vals;
	struct input_value *v;
	struct input_value *v;


	if (handler->filter) {
		for (v = vals; v != vals + count; v++) {
		for (v = vals; v != vals + count; v++) {
		if (handler->filter &&
			if (handler->filter(handle, v->type, v->code, v->value))
		    handler->filter(handle, v->type, v->code, v->value))
				continue;
				continue;
			if (end != v)
			if (end != v)
				*end = *v;
				*end = *v;
			end++;
			end++;
		}
		}

		count = end - vals;
		count = end - vals;
	}

	if (!count)
	if (!count)
		return 0;
		return 0;


	if (handler->events)
	if (handler->events)
		handler->events(handle, vals, count);
		handler->events(handle, vals, count);
	else if (handler->event)
	else if (handler->event)
		for (v = vals; v != end; v++)
		for (v = vals; v != vals + count; v++)
			handler->event(handle, v->type, v->code, v->value);
			handler->event(handle, v->type, v->code, v->value);


	return count;
	return count;
@@ -143,8 +144,11 @@ static void input_pass_values(struct input_dev *dev,
		count = input_to_handler(handle, vals, count);
		count = input_to_handler(handle, vals, count);
	} else {
	} else {
		list_for_each_entry_rcu(handle, &dev->h_list, d_node)
		list_for_each_entry_rcu(handle, &dev->h_list, d_node)
			if (handle->open)
			if (handle->open) {
				count = input_to_handler(handle, vals, count);
				count = input_to_handler(handle, vals, count);
				if (!count)
					break;
			}
	}
	}


	rcu_read_unlock();
	rcu_read_unlock();