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: cypress_ps2 - propagate errors from lower layers

Do not override errors reported by lower layers with generic "-1",
but propagate them to the callers. Change the checks for errors to be
in the form of "if (error)" to maintain consistency.

Link: https://lore.kernel.org/r/20240628224728.2180126-4-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+35 -27
+35 -27
drivers/input/mouse/cypress_ps2.c
··· 97 97 unsigned char cmd, 98 98 unsigned char *param) 99 99 { 100 - int rc; 101 100 struct ps2dev *ps2dev = &psmouse->ps2dev; 102 101 enum psmouse_state old_state; 103 102 int pktsize; 103 + int rc; 104 104 105 105 ps2_begin_command(ps2dev); 106 106 ··· 112 112 memset(param, 0, pktsize); 113 113 114 114 rc = cypress_ps2_sendbyte(psmouse, 0xe9); 115 - if (rc < 0) 115 + if (rc) 116 116 goto out; 117 117 118 118 if (!wait_event_timeout(ps2dev->wait, ··· 322 322 323 323 static int cypress_query_hardware(struct psmouse *psmouse) 324 324 { 325 - int ret; 325 + int error; 326 326 327 - ret = cypress_read_fw_version(psmouse); 328 - if (ret) 329 - return ret; 327 + error = cypress_read_fw_version(psmouse); 328 + if (error) 329 + return error; 330 330 331 - ret = cypress_read_tp_metrics(psmouse); 332 - if (ret) 333 - return ret; 331 + error = cypress_read_tp_metrics(psmouse); 332 + if (error) 333 + return error; 334 334 335 335 return 0; 336 336 } ··· 339 339 { 340 340 struct cytp_data *cytp = psmouse->private; 341 341 unsigned char param[3]; 342 + int error; 342 343 343 - if (cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, param) < 0) 344 - return -1; 344 + error = cypress_send_ext_cmd(psmouse, CYTP_CMD_ABS_WITH_PRESSURE_MODE, 345 + param); 346 + if (error) 347 + return error; 345 348 346 349 cytp->mode = (cytp->mode & ~CYTP_BIT_ABS_REL_MASK) 347 350 | CYTP_BIT_ABS_PRESSURE; ··· 369 366 static int cypress_set_input_params(struct input_dev *input, 370 367 struct cytp_data *cytp) 371 368 { 372 - int ret; 369 + int error; 373 370 374 371 if (!cytp->tp_res_x || !cytp->tp_res_y) 375 372 return -EINVAL; ··· 386 383 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, cytp->tp_max_abs_y, 0, 0); 387 384 input_set_abs_params(input, ABS_MT_PRESSURE, 0, 255, 0, 0); 388 385 389 - ret = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS, 390 - INPUT_MT_DROP_UNUSED|INPUT_MT_TRACK); 391 - if (ret < 0) 392 - return ret; 386 + error = input_mt_init_slots(input, CYTP_MAX_MT_SLOTS, 387 + INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK); 388 + if (error) 389 + return error; 393 390 394 391 __set_bit(INPUT_PROP_SEMI_MT, input->propbit); 395 392 ··· 640 637 static int cypress_reconnect(struct psmouse *psmouse) 641 638 { 642 639 int tries = CYTP_PS2_CMD_TRIES; 643 - int rc; 640 + int error; 644 641 645 642 do { 646 643 cypress_reset(psmouse); 647 - rc = cypress_detect(psmouse, false); 648 - } while (rc && (--tries > 0)); 644 + error = cypress_detect(psmouse, false); 645 + } while (error && (--tries > 0)); 649 646 650 - if (rc) { 647 + if (error) { 651 648 psmouse_err(psmouse, "Reconnect: unable to detect trackpad.\n"); 652 - return -1; 649 + return error; 653 650 } 654 651 655 - if (cypress_set_absolute_mode(psmouse)) { 652 + error = cypress_set_absolute_mode(psmouse); 653 + if (error) { 656 654 psmouse_err(psmouse, "Reconnect: Unable to initialize Cypress absolute mode.\n"); 657 - return -1; 655 + return error; 658 656 } 659 657 660 658 return 0; ··· 664 660 int cypress_init(struct psmouse *psmouse) 665 661 { 666 662 struct cytp_data *cytp; 663 + int error; 667 664 668 665 cytp = kzalloc(sizeof(*cytp), GFP_KERNEL); 669 666 if (!cytp) ··· 675 670 676 671 cypress_reset(psmouse); 677 672 678 - if (cypress_query_hardware(psmouse)) { 673 + error = cypress_query_hardware(psmouse); 674 + if (error) { 679 675 psmouse_err(psmouse, "Unable to query Trackpad hardware.\n"); 680 676 goto err_exit; 681 677 } 682 678 683 - if (cypress_set_absolute_mode(psmouse)) { 679 + error = cypress_set_absolute_mode(psmouse); 680 + if (error) { 684 681 psmouse_err(psmouse, "init: Unable to initialize Cypress absolute mode.\n"); 685 682 goto err_exit; 686 683 } 687 684 688 - if (cypress_set_input_params(psmouse->dev, cytp) < 0) { 685 + error = cypress_set_input_params(psmouse->dev, cytp); 686 + if (error) { 689 687 psmouse_err(psmouse, "init: Unable to set input params.\n"); 690 688 goto err_exit; 691 689 } ··· 713 705 psmouse->private = NULL; 714 706 kfree(cytp); 715 707 716 - return -1; 708 + return error; 717 709 }