@@ -119,12 +119,12 @@ static void input_pass_values(struct input_dev *dev,
119119
120120 handle = rcu_dereference (dev -> grab );
121121 if (handle ) {
122- count = handle -> handler -> events (handle , vals , count );
122+ count = handle -> handle_events (handle , vals , count );
123123 } else {
124124 list_for_each_entry_rcu (handle , & dev -> h_list , d_node )
125125 if (handle -> open ) {
126- count = handle -> handler -> events (handle , vals ,
127- count );
126+ count = handle -> handle_events (handle , vals ,
127+ count );
128128 if (!count )
129129 break ;
130130 }
@@ -2534,57 +2534,6 @@ static int input_handler_check_methods(const struct input_handler *handler)
25342534 return 0 ;
25352535}
25362536
2537- /*
2538- * An implementation of input_handler's events() method that simply
2539- * invokes handler->event() method for each event one by one.
2540- */
2541- static unsigned int input_handler_events_default (struct input_handle * handle ,
2542- struct input_value * vals ,
2543- unsigned int count )
2544- {
2545- struct input_handler * handler = handle -> handler ;
2546- struct input_value * v ;
2547-
2548- for (v = vals ; v != vals + count ; v ++ )
2549- handler -> event (handle , v -> type , v -> code , v -> value );
2550-
2551- return count ;
2552- }
2553-
2554- /*
2555- * An implementation of input_handler's events() method that invokes
2556- * handler->filter() method for each event one by one and removes events
2557- * that were filtered out from the "vals" array.
2558- */
2559- static unsigned int input_handler_events_filter (struct input_handle * handle ,
2560- struct input_value * vals ,
2561- unsigned int count )
2562- {
2563- struct input_handler * handler = handle -> handler ;
2564- struct input_value * end = vals ;
2565- struct input_value * v ;
2566-
2567- for (v = vals ; v != vals + count ; v ++ ) {
2568- if (handler -> filter (handle , v -> type , v -> code , v -> value ))
2569- continue ;
2570- if (end != v )
2571- * end = * v ;
2572- end ++ ;
2573- }
2574-
2575- return end - vals ;
2576- }
2577-
2578- /*
2579- * An implementation of input_handler's events() method that does nothing.
2580- */
2581- static unsigned int input_handler_events_null (struct input_handle * handle ,
2582- struct input_value * vals ,
2583- unsigned int count )
2584- {
2585- return count ;
2586- }
2587-
25882537/**
25892538 * input_register_handler - register a new input handler
25902539 * @handler: handler to be registered
@@ -2604,13 +2553,6 @@ int input_register_handler(struct input_handler *handler)
26042553
26052554 INIT_LIST_HEAD (& handler -> h_list );
26062555
2607- if (handler -> filter )
2608- handler -> events = input_handler_events_filter ;
2609- else if (handler -> event )
2610- handler -> events = input_handler_events_default ;
2611- else if (!handler -> events )
2612- handler -> events = input_handler_events_null ;
2613-
26142556 error = mutex_lock_interruptible (& input_mutex );
26152557 if (error )
26162558 return error ;
@@ -2684,6 +2626,75 @@ int input_handler_for_each_handle(struct input_handler *handler, void *data,
26842626}
26852627EXPORT_SYMBOL (input_handler_for_each_handle );
26862628
2629+ /*
2630+ * An implementation of input_handle's handle_events() method that simply
2631+ * invokes handler->event() method for each event one by one.
2632+ */
2633+ static unsigned int input_handle_events_default (struct input_handle * handle ,
2634+ struct input_value * vals ,
2635+ unsigned int count )
2636+ {
2637+ struct input_handler * handler = handle -> handler ;
2638+ struct input_value * v ;
2639+
2640+ for (v = vals ; v != vals + count ; v ++ )
2641+ handler -> event (handle , v -> type , v -> code , v -> value );
2642+
2643+ return count ;
2644+ }
2645+
2646+ /*
2647+ * An implementation of input_handle's handle_events() method that invokes
2648+ * handler->filter() method for each event one by one and removes events
2649+ * that were filtered out from the "vals" array.
2650+ */
2651+ static unsigned int input_handle_events_filter (struct input_handle * handle ,
2652+ struct input_value * vals ,
2653+ unsigned int count )
2654+ {
2655+ struct input_handler * handler = handle -> handler ;
2656+ struct input_value * end = vals ;
2657+ struct input_value * v ;
2658+
2659+ for (v = vals ; v != vals + count ; v ++ ) {
2660+ if (handler -> filter (handle , v -> type , v -> code , v -> value ))
2661+ continue ;
2662+ if (end != v )
2663+ * end = * v ;
2664+ end ++ ;
2665+ }
2666+
2667+ return end - vals ;
2668+ }
2669+
2670+ /*
2671+ * An implementation of input_handle's handle_events() method that does nothing.
2672+ */
2673+ static unsigned int input_handle_events_null (struct input_handle * handle ,
2674+ struct input_value * vals ,
2675+ unsigned int count )
2676+ {
2677+ return count ;
2678+ }
2679+
2680+ /*
2681+ * Sets up appropriate handle->event_handler based on the input_handler
2682+ * associated with the handle.
2683+ */
2684+ static void input_handle_setup_event_handler (struct input_handle * handle )
2685+ {
2686+ struct input_handler * handler = handle -> handler ;
2687+
2688+ if (handler -> filter )
2689+ handle -> handle_events = input_handle_events_filter ;
2690+ else if (handler -> event )
2691+ handle -> handle_events = input_handle_events_default ;
2692+ else if (handler -> events )
2693+ handle -> handle_events = handler -> events ;
2694+ else
2695+ handle -> handle_events = input_handle_events_null ;
2696+ }
2697+
26872698/**
26882699 * input_register_handle - register a new input handle
26892700 * @handle: handle to register
@@ -2701,6 +2712,7 @@ int input_register_handle(struct input_handle *handle)
27012712 struct input_dev * dev = handle -> dev ;
27022713 int error ;
27032714
2715+ input_handle_setup_event_handler (handle );
27042716 /*
27052717 * We take dev->mutex here to prevent race with
27062718 * input_release_device().
0 commit comments