Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: zforce_ts - use dev_err_probe() where appropriate

Use dev_err_probe() helper to log deferrals in the devices_deferred
debugfs file and avoid extra messages in the logs.

Also rename "ret" variables holding error codes only to "error".

Tested-by: Andreas Kemnade <andreas@kemnade.info> # Tolino Shine2HD
Link: https://lore.kernel.org/r/20240824055047.1706392-13-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+113 -132
+113 -132
drivers/input/touchscreen/zforce_ts.c
··· 171 171 ret = i2c_master_send(client, buf, len); 172 172 if (ret < 0) { 173 173 dev_err(&client->dev, "i2c send data request error: %d\n", ret); 174 - return ret;; 174 + return ret; 175 175 } 176 176 177 177 dev_dbg(&client->dev, "waiting for result for command 0x%x\n", buf[2]); ··· 187 187 { 188 188 struct i2c_client *client = ts->client; 189 189 char buf[3]; 190 - int ret; 190 + int error; 191 191 192 192 dev_dbg(&client->dev, "%s: 0x%x\n", __func__, cmd); 193 193 ··· 195 195 buf[1] = 1; /* data size, command only */ 196 196 buf[2] = cmd; 197 197 198 - ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); 199 - if (ret < 0) { 200 - dev_err(&client->dev, "i2c send data request error: %d\n", ret); 201 - return ret; 198 + error = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); 199 + if (error) { 200 + dev_err(&client->dev, "i2c send data request error: %d\n", 201 + error); 202 + return error; 202 203 } 203 204 204 205 return 0; ··· 247 246 static int zforce_start(struct zforce_ts *ts) 248 247 { 249 248 struct i2c_client *client = ts->client; 250 - int ret; 249 + int error; 251 250 252 251 dev_dbg(&client->dev, "starting device\n"); 253 252 254 - ret = zforce_command_wait(ts, COMMAND_INITIALIZE); 255 - if (ret) { 256 - dev_err(&client->dev, "Unable to initialize, %d\n", ret); 257 - return ret; 253 + error = zforce_command_wait(ts, COMMAND_INITIALIZE); 254 + if (error) { 255 + dev_err(&client->dev, "Unable to initialize, %d\n", error); 256 + return error; 258 257 } 259 258 260 - ret = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y); 261 - if (ret) { 262 - dev_err(&client->dev, "Unable to set resolution, %d\n", ret); 263 - goto error; 259 + error = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y); 260 + if (error) { 261 + dev_err(&client->dev, "Unable to set resolution, %d\n", error); 262 + goto err_deactivate; 264 263 } 265 264 266 - ret = zforce_scan_frequency(ts, 10, 50, 50); 267 - if (ret) { 265 + error = zforce_scan_frequency(ts, 10, 50, 50); 266 + if (error) { 268 267 dev_err(&client->dev, "Unable to set scan frequency, %d\n", 269 - ret); 270 - goto error; 268 + error); 269 + goto err_deactivate; 271 270 } 272 271 273 - ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); 274 - if (ret) { 272 + error = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); 273 + if (error) { 275 274 dev_err(&client->dev, "Unable to set config\n"); 276 - goto error; 275 + goto err_deactivate; 277 276 } 278 277 279 278 /* start sending touch events */ 280 - ret = zforce_command(ts, COMMAND_DATAREQUEST); 281 - if (ret) { 279 + error = zforce_command(ts, COMMAND_DATAREQUEST); 280 + if (error) { 282 281 dev_err(&client->dev, "Unable to request data\n"); 283 - goto error; 282 + goto err_deactivate; 284 283 } 285 284 286 285 /* ··· 291 290 292 291 return 0; 293 292 294 - error: 293 + err_deactivate: 295 294 zforce_command_wait(ts, COMMAND_DEACTIVATE); 296 - return ret; 295 + return error; 297 296 } 298 297 299 298 static int zforce_stop(struct zforce_ts *ts) 300 299 { 301 300 struct i2c_client *client = ts->client; 302 - int ret; 301 + int error; 303 302 304 303 dev_dbg(&client->dev, "stopping device\n"); 305 304 306 305 /* Deactivates touch sensing and puts the device into sleep. */ 307 - ret = zforce_command_wait(ts, COMMAND_DEACTIVATE); 308 - if (ret != 0) { 306 + error = zforce_command_wait(ts, COMMAND_DEACTIVATE); 307 + if (error) { 309 308 dev_err(&client->dev, "could not deactivate device, %d\n", 310 - ret); 311 - return ret; 309 + error); 310 + return error; 312 311 } 313 312 314 313 return 0; ··· 452 451 { 453 452 struct zforce_ts *ts = dev_id; 454 453 struct i2c_client *client = ts->client; 455 - int ret; 454 + int error; 456 455 u8 payload_buffer[FRAME_MAXSIZE]; 457 456 u8 *payload; 458 457 bool suspending; ··· 483 482 * no IRQ any more) 484 483 */ 485 484 do { 486 - ret = zforce_read_packet(ts, payload_buffer); 487 - if (ret < 0) { 485 + error = zforce_read_packet(ts, payload_buffer); 486 + if (error) { 488 487 dev_err(&client->dev, 489 - "could not read packet, ret: %d\n", ret); 488 + "could not read packet, ret: %d\n", error); 490 489 break; 491 490 } 492 491 ··· 571 570 { 572 571 struct zforce_ts *ts = input_get_drvdata(dev); 573 572 struct i2c_client *client = ts->client; 574 - int ret; 573 + int error; 575 574 576 - ret = zforce_stop(ts); 577 - if (ret) 575 + error = zforce_stop(ts); 576 + if (error) 578 577 dev_warn(&client->dev, "stopping zforce failed\n"); 579 - 580 - return; 581 578 } 582 579 583 580 static int __zforce_suspend(struct zforce_ts *ts) 584 581 { 585 582 struct i2c_client *client = ts->client; 586 583 struct input_dev *input = ts->input; 587 - int ret; 584 + int error; 588 585 589 586 guard(mutex)(&input->mutex); 590 587 ··· 595 596 596 597 /* Need to start device, if not open, to be a wakeup source. */ 597 598 if (!input_device_enabled(input)) { 598 - ret = zforce_start(ts); 599 - if (ret) 600 - return ret; 599 + error = zforce_start(ts); 600 + if (error) 601 + return error; 601 602 } 602 603 603 604 enable_irq_wake(client->irq); ··· 605 606 dev_dbg(&client->dev, 606 607 "suspend without being a wakeup source\n"); 607 608 608 - ret = zforce_stop(ts); 609 - if (ret) 610 - return ret; 609 + error = zforce_stop(ts); 610 + if (error) 611 + return error; 611 612 612 613 disable_irq(client->irq); 613 614 } ··· 638 639 struct i2c_client *client = to_i2c_client(dev); 639 640 struct zforce_ts *ts = i2c_get_clientdata(client); 640 641 struct input_dev *input = ts->input; 641 - int ret; 642 + int error; 642 643 643 644 guard(mutex)(&input->mutex); 644 645 ··· 651 652 652 653 /* need to stop device if it was not open on suspend */ 653 654 if (!input_device_enabled(input)) { 654 - ret = zforce_stop(ts); 655 - if (ret) 656 - return ret; 655 + error = zforce_stop(ts); 656 + if (error) 657 + return error; 657 658 } 658 659 } else if (input_device_enabled(input)) { 659 660 dev_dbg(&client->dev, "resume without being a wakeup source\n"); 660 661 661 662 enable_irq(client->irq); 662 663 663 - ret = zforce_start(ts); 664 - if (ret < 0) 665 - return ret; 664 + error = zforce_start(ts); 665 + if (error) 666 + return error; 666 667 } 667 668 668 669 return 0; ··· 698 699 { 699 700 struct zforce_ts *ts; 700 701 struct input_dev *input_dev; 701 - int ret; 702 + int error; 702 703 703 704 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); 704 705 if (!ts) ··· 706 707 707 708 ts->gpio_rst = devm_gpiod_get_optional(&client->dev, "reset", 708 709 GPIOD_OUT_HIGH); 709 - if (IS_ERR(ts->gpio_rst)) { 710 - ret = PTR_ERR(ts->gpio_rst); 711 - dev_err(&client->dev, 712 - "failed to request reset GPIO: %d\n", ret); 713 - return ret; 714 - } 710 + error = PTR_ERR_OR_ZERO(ts->gpio_rst); 711 + if (error) 712 + return dev_err_probe(&client->dev, error, 713 + "failed to request reset GPIO\n"); 715 714 716 715 if (ts->gpio_rst) { 717 716 ts->gpio_int = devm_gpiod_get_optional(&client->dev, "irq", 718 717 GPIOD_IN); 719 - if (IS_ERR(ts->gpio_int)) { 720 - ret = PTR_ERR(ts->gpio_int); 721 - dev_err(&client->dev, 722 - "failed to request interrupt GPIO: %d\n", ret); 723 - return ret; 724 - } 718 + error = PTR_ERR_OR_ZERO(ts->gpio_int); 719 + if (error) 720 + return dev_err_probe(&client->dev, error, 721 + "failed to request interrupt GPIO\n"); 725 722 } else { 726 723 /* 727 724 * Deprecated GPIO handling for compatibility ··· 727 732 /* INT GPIO */ 728 733 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, 729 734 GPIOD_IN); 730 - if (IS_ERR(ts->gpio_int)) { 731 - ret = PTR_ERR(ts->gpio_int); 732 - dev_err(&client->dev, 733 - "failed to request interrupt GPIO: %d\n", ret); 734 - return ret; 735 - } 735 + 736 + error = PTR_ERR_OR_ZERO(ts->gpio_int); 737 + if (error) 738 + return dev_err_probe(&client->dev, error, 739 + "failed to request interrupt GPIO\n"); 736 740 737 741 /* RST GPIO */ 738 742 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, 739 743 GPIOD_OUT_HIGH); 740 - if (IS_ERR(ts->gpio_rst)) { 741 - ret = PTR_ERR(ts->gpio_rst); 742 - dev_err(&client->dev, 743 - "failed to request reset GPIO: %d\n", ret); 744 - return ret; 745 - } 744 + error = PTR_ERR_OR_ZERO(ts->gpio_rst); 745 + if (error) 746 + return dev_err_probe(&client->dev, error, 747 + "failed to request reset GPIO\n"); 746 748 } 747 749 748 750 ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); 749 - if (IS_ERR(ts->reg_vdd)) { 750 - ret = PTR_ERR(ts->reg_vdd); 751 - if (ret != -ENOENT) 752 - return ret; 751 + error = PTR_ERR_OR_ZERO(ts->gpio_rst); 752 + if (error) { 753 + if (error != -ENOENT) 754 + return dev_err_probe(&client->dev, error, 755 + "failed to request vdd supply\n"); 753 756 } else { 754 - ret = regulator_enable(ts->reg_vdd); 755 - if (ret) 756 - return ret; 757 + error = regulator_enable(ts->reg_vdd); 758 + if (error) 759 + return error; 757 760 758 761 /* 759 762 * according to datasheet add 100us grace time after regular ··· 760 767 udelay(100); 761 768 } 762 769 763 - ret = devm_add_action_or_reset(&client->dev, zforce_reset, ts); 764 - if (ret) { 765 - dev_err(&client->dev, "failed to register reset action, %d\n", 766 - ret); 767 - 768 - /* hereafter the regulator will be disabled by the action */ 769 - return ret; 770 - } 770 + error = devm_add_action_or_reset(&client->dev, zforce_reset, ts); 771 + if (error) 772 + return dev_err_probe(&client->dev, error, 773 + "failed to register reset action\n"); 771 774 772 775 snprintf(ts->phys, sizeof(ts->phys), 773 776 "%s/input0", dev_name(&client->dev)); 774 777 775 778 input_dev = devm_input_allocate_device(&client->dev); 776 - if (!input_dev) { 777 - dev_err(&client->dev, "could not allocate input device\n"); 778 - return -ENOMEM; 779 - } 779 + if (!input_dev) 780 + return dev_err_probe(&client->dev, -ENOMEM, 781 + "could not allocate input device\n"); 780 782 781 783 ts->client = client; 782 784 ts->input = input_dev; ··· 785 797 786 798 zforce_ts_parse_legacy_properties(ts); 787 799 touchscreen_parse_properties(input_dev, true, &ts->prop); 788 - if (ts->prop.max_x == 0 || ts->prop.max_y == 0) { 789 - dev_err(&client->dev, "no size specified\n"); 790 - return -EINVAL; 791 - } 800 + if (ts->prop.max_x == 0 || ts->prop.max_y == 0) 801 + return dev_err_probe(&client->dev, -EINVAL, "no size specified"); 792 802 793 803 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 794 804 ZFORCE_MAX_AREA, 0, 0); ··· 794 808 ZFORCE_MAX_AREA, 0, 0); 795 809 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 796 810 797 - ret = input_mt_init_slots(input_dev, ZFORCE_REPORT_POINTS, 811 + error = input_mt_init_slots(input_dev, ZFORCE_REPORT_POINTS, 798 812 INPUT_MT_DIRECT); 799 - if (ret) 800 - return ret; 813 + if (error) 814 + return error; 801 815 802 816 input_set_drvdata(ts->input, ts); 803 817 ··· 810 824 * Therefore we can trigger the interrupt anytime it is low and do 811 825 * not need to limit it to the interrupt edge. 812 826 */ 813 - ret = devm_request_threaded_irq(&client->dev, client->irq, 814 - zforce_irq, zforce_irq_thread, 815 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 816 - input_dev->name, ts); 817 - if (ret) { 818 - dev_err(&client->dev, "irq %d request failed\n", client->irq); 819 - return ret; 820 - } 827 + error = devm_request_threaded_irq(&client->dev, client->irq, 828 + zforce_irq, zforce_irq_thread, 829 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 830 + input_dev->name, ts); 831 + if (error) 832 + return dev_err_probe(&client->dev, error, 833 + "irq %d request failed\n", client->irq); 821 834 822 835 i2c_set_clientdata(client, ts); 823 836 ··· 828 843 dev_warn(&client->dev, "bootcomplete timed out\n"); 829 844 830 845 /* need to start device to get version information */ 831 - ret = zforce_command_wait(ts, COMMAND_INITIALIZE); 832 - if (ret) { 833 - dev_err(&client->dev, "unable to initialize, %d\n", ret); 834 - return ret; 835 - } 846 + error = zforce_command_wait(ts, COMMAND_INITIALIZE); 847 + if (error) 848 + return dev_err_probe(&client->dev, error, "unable to initialize\n"); 836 849 837 850 /* this gets the firmware version among other information */ 838 - ret = zforce_command_wait(ts, COMMAND_STATUS); 839 - if (ret < 0) { 840 - dev_err(&client->dev, "couldn't get status, %d\n", ret); 851 + error = zforce_command_wait(ts, COMMAND_STATUS); 852 + if (error) { 853 + dev_err_probe(&client->dev, error, "couldn't get status\n"); 841 854 zforce_stop(ts); 842 - return ret; 855 + return error; 843 856 } 844 857 845 858 /* stop device and put it into sleep until it is opened */ 846 - ret = zforce_stop(ts); 847 - if (ret < 0) 848 - return ret; 859 + error = zforce_stop(ts); 860 + if (error) 861 + return error; 849 862 850 863 device_set_wakeup_capable(&client->dev, true); 851 864 852 - ret = input_register_device(input_dev); 853 - if (ret) { 854 - dev_err(&client->dev, "could not register input device, %d\n", 855 - ret); 856 - return ret; 857 - } 865 + error = input_register_device(input_dev); 866 + if (error) 867 + return dev_err_probe(&client->dev, error, 868 + "could not register input device\n"); 858 869 859 870 return 0; 860 871 }