Merge tag 'input-for-v6.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input fixes from Dmitry Torokhov:

- a fix for regression in input core introduced in 6.11 preventing
re-registering input handlers

- a fix for adp5588-keys driver tyring to disable interrupt 0 at
suspend when devices is used without interrupt

- a fix for edt-ft5x06 to stop leaking regmap structure when probing
fails and to make sure it is not released too early on removal.

* tag 'input-for-v6.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: fix regression when re-registering input handlers
Input: adp5588-keys - do not try to disable interrupt 0
Input: edt-ft5x06 - fix regmap leak when probe fails

+104 -65
+73 -61
drivers/input/input.c
··· 119 120 handle = rcu_dereference(dev->grab); 121 if (handle) { 122 - count = handle->handler->events(handle, vals, count); 123 } else { 124 list_for_each_entry_rcu(handle, &dev->h_list, d_node) 125 if (handle->open) { 126 - count = handle->handler->events(handle, vals, 127 - count); 128 if (!count) 129 break; 130 } ··· 2534 return 0; 2535 } 2536 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 - 2588 /** 2589 * input_register_handler - register a new input handler 2590 * @handler: handler to be registered ··· 2552 return error; 2553 2554 INIT_LIST_HEAD(&handler->h_list); 2555 - 2556 - if (handler->filter) 2557 - handler->events = input_handler_events_filter; 2558 - else if (handler->event) 2559 - handler->events = input_handler_events_default; 2560 - else if (!handler->events) 2561 - handler->events = input_handler_events_null; 2562 2563 error = mutex_lock_interruptible(&input_mutex); 2564 if (error) ··· 2626 } 2627 EXPORT_SYMBOL(input_handler_for_each_handle); 2628 2629 /** 2630 * input_register_handle - register a new input handle 2631 * @handle: handle to register ··· 2712 struct input_dev *dev = handle->dev; 2713 int error; 2714 2715 /* 2716 * We take dev->mutex here to prevent race with 2717 * input_release_device().
··· 119 120 handle = rcu_dereference(dev->grab); 121 if (handle) { 122 + count = handle->handle_events(handle, vals, count); 123 } else { 124 list_for_each_entry_rcu(handle, &dev->h_list, d_node) 125 if (handle->open) { 126 + count = handle->handle_events(handle, vals, 127 + count); 128 if (!count) 129 break; 130 } ··· 2534 return 0; 2535 } 2536 2537 /** 2538 * input_register_handler - register a new input handler 2539 * @handler: handler to be registered ··· 2603 return error; 2604 2605 INIT_LIST_HEAD(&handler->h_list); 2606 2607 error = mutex_lock_interruptible(&input_mutex); 2608 if (error) ··· 2684 } 2685 EXPORT_SYMBOL(input_handler_for_each_handle); 2686 2687 + /* 2688 + * An implementation of input_handle's handle_events() method that simply 2689 + * invokes handler->event() method for each event one by one. 2690 + */ 2691 + static unsigned int input_handle_events_default(struct input_handle *handle, 2692 + struct input_value *vals, 2693 + unsigned int count) 2694 + { 2695 + struct input_handler *handler = handle->handler; 2696 + struct input_value *v; 2697 + 2698 + for (v = vals; v != vals + count; v++) 2699 + handler->event(handle, v->type, v->code, v->value); 2700 + 2701 + return count; 2702 + } 2703 + 2704 + /* 2705 + * An implementation of input_handle's handle_events() method that invokes 2706 + * handler->filter() method for each event one by one and removes events 2707 + * that were filtered out from the "vals" array. 2708 + */ 2709 + static unsigned int input_handle_events_filter(struct input_handle *handle, 2710 + struct input_value *vals, 2711 + unsigned int count) 2712 + { 2713 + struct input_handler *handler = handle->handler; 2714 + struct input_value *end = vals; 2715 + struct input_value *v; 2716 + 2717 + for (v = vals; v != vals + count; v++) { 2718 + if (handler->filter(handle, v->type, v->code, v->value)) 2719 + continue; 2720 + if (end != v) 2721 + *end = *v; 2722 + end++; 2723 + } 2724 + 2725 + return end - vals; 2726 + } 2727 + 2728 + /* 2729 + * An implementation of input_handle's handle_events() method that does nothing. 2730 + */ 2731 + static unsigned int input_handle_events_null(struct input_handle *handle, 2732 + struct input_value *vals, 2733 + unsigned int count) 2734 + { 2735 + return count; 2736 + } 2737 + 2738 + /* 2739 + * Sets up appropriate handle->event_handler based on the input_handler 2740 + * associated with the handle. 2741 + */ 2742 + static void input_handle_setup_event_handler(struct input_handle *handle) 2743 + { 2744 + struct input_handler *handler = handle->handler; 2745 + 2746 + if (handler->filter) 2747 + handle->handle_events = input_handle_events_filter; 2748 + else if (handler->event) 2749 + handle->handle_events = input_handle_events_default; 2750 + else if (handler->events) 2751 + handle->handle_events = handler->events; 2752 + else 2753 + handle->handle_events = input_handle_events_null; 2754 + } 2755 + 2756 /** 2757 * input_register_handle - register a new input handle 2758 * @handle: handle to register ··· 2701 struct input_dev *dev = handle->dev; 2702 int error; 2703 2704 + input_handle_setup_event_handler(handle); 2705 /* 2706 * We take dev->mutex here to prevent race with 2707 * input_release_device().
+4 -2
drivers/input/keyboard/adp5588-keys.c
··· 822 { 823 struct i2c_client *client = to_i2c_client(dev); 824 825 - disable_irq(client->irq); 826 827 return 0; 828 } ··· 832 { 833 struct i2c_client *client = to_i2c_client(dev); 834 835 - enable_irq(client->irq); 836 837 return 0; 838 }
··· 822 { 823 struct i2c_client *client = to_i2c_client(dev); 824 825 + if (client->irq) 826 + disable_irq(client->irq); 827 828 return 0; 829 } ··· 831 { 832 struct i2c_client *client = to_i2c_client(dev); 833 834 + if (client->irq) 835 + enable_irq(client->irq); 836 837 return 0; 838 }
+18 -1
drivers/input/touchscreen/edt-ft5x06.c
··· 1121 } 1122 } 1123 1124 static void edt_ft5x06_disable_regulators(void *arg) 1125 { 1126 struct edt_ft5x06_ts_data *data = arg; ··· 1161 dev_err(&client->dev, "regmap allocation failed\n"); 1162 return PTR_ERR(tsdata->regmap); 1163 } 1164 1165 chip_data = device_get_match_data(&client->dev); 1166 if (!chip_data) ··· 1365 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); 1366 1367 edt_ft5x06_ts_teardown_debugfs(tsdata); 1368 - regmap_exit(tsdata->regmap); 1369 } 1370 1371 static int edt_ft5x06_ts_suspend(struct device *dev)
··· 1121 } 1122 } 1123 1124 + static void edt_ft5x06_exit_regmap(void *arg) 1125 + { 1126 + struct edt_ft5x06_ts_data *data = arg; 1127 + 1128 + if (!IS_ERR_OR_NULL(data->regmap)) 1129 + regmap_exit(data->regmap); 1130 + } 1131 + 1132 static void edt_ft5x06_disable_regulators(void *arg) 1133 { 1134 struct edt_ft5x06_ts_data *data = arg; ··· 1153 dev_err(&client->dev, "regmap allocation failed\n"); 1154 return PTR_ERR(tsdata->regmap); 1155 } 1156 + 1157 + /* 1158 + * We are not using devm_regmap_init_i2c() and instead install a 1159 + * custom action because we may replace regmap with M06-specific one 1160 + * and we need to make sure that it will not be released too early. 1161 + */ 1162 + error = devm_add_action_or_reset(&client->dev, edt_ft5x06_exit_regmap, 1163 + tsdata); 1164 + if (error) 1165 + return error; 1166 1167 chip_data = device_get_match_data(&client->dev); 1168 if (!chip_data) ··· 1347 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); 1348 1349 edt_ft5x06_ts_teardown_debugfs(tsdata); 1350 } 1351 1352 static int edt_ft5x06_ts_suspend(struct device *dev)
+9 -1
include/linux/input.h
··· 339 * @name: name given to the handle by handler that created it 340 * @dev: input device the handle is attached to 341 * @handler: handler that works with the device through this handle 342 * @d_node: used to put the handle on device's list of attached handles 343 * @h_node: used to put the handle on handler's list of handles from which 344 * it gets events 345 */ 346 struct input_handle { 347 - 348 void *private; 349 350 int open; ··· 356 357 struct input_dev *dev; 358 struct input_handler *handler; 359 360 struct list_head d_node; 361 struct list_head h_node;
··· 339 * @name: name given to the handle by handler that created it 340 * @dev: input device the handle is attached to 341 * @handler: handler that works with the device through this handle 342 + * @handle_events: event sequence handler. It is set up by the input core 343 + * according to event handling method specified in the @handler. See 344 + * input_handle_setup_event_handler(). 345 + * This method is being called by the input core with interrupts disabled 346 + * and dev->event_lock spinlock held and so it may not sleep. 347 * @d_node: used to put the handle on device's list of attached handles 348 * @h_node: used to put the handle on handler's list of handles from which 349 * it gets events 350 */ 351 struct input_handle { 352 void *private; 353 354 int open; ··· 352 353 struct input_dev *dev; 354 struct input_handler *handler; 355 + 356 + unsigned int (*handle_events)(struct input_handle *handle, 357 + struct input_value *vals, 358 + unsigned int count); 359 360 struct list_head d_node; 361 struct list_head h_node;