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

Input: synaptics - do not abuse -1 as return value

Let's stop using -1 as a universal return value and instead propagate
errors from underlying calls up the stack.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+46 -25
+46 -25
drivers/input/mouse/synaptics.c
··· 82 82 static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) 83 83 { 84 84 unsigned char param[1]; 85 + int error; 85 86 86 - if (psmouse_sliced_command(psmouse, mode)) 87 - return -1; 87 + error = psmouse_sliced_command(psmouse, mode); 88 + if (error) 89 + return error; 90 + 88 91 param[0] = SYN_PS_SET_MODE2; 89 - if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE)) 90 - return -1; 92 + error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE); 93 + if (error) 94 + return error; 95 + 91 96 return 0; 92 97 } 93 98 ··· 539 534 { 540 535 static unsigned char param = 0xc8; 541 536 struct synaptics_data *priv = psmouse->private; 537 + int error; 542 538 543 539 if (!(SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) || 544 540 SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c))) 545 541 return 0; 546 542 547 - if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) 548 - return -1; 543 + error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL); 544 + if (error) 545 + return error; 549 546 550 - if (ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE)) 551 - return -1; 547 + error = ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE); 548 + if (error) 549 + return error; 552 550 553 551 /* Advanced gesture mode also sends multi finger data */ 554 552 priv->info.capabilities |= BIT(1); ··· 562 554 static int synaptics_set_mode(struct psmouse *psmouse) 563 555 { 564 556 struct synaptics_data *priv = psmouse->private; 557 + int error; 565 558 566 559 priv->mode = 0; 567 560 if (priv->absolute_mode) ··· 574 565 if (SYN_CAP_EXTENDED(priv->info.capabilities)) 575 566 priv->mode |= SYN_BIT_W_MODE; 576 567 577 - if (synaptics_mode_cmd(psmouse, priv->mode)) 578 - return -1; 568 + error = synaptics_mode_cmd(psmouse, priv->mode); 569 + if (error) 570 + return error; 579 571 580 - if (priv->absolute_mode && 581 - synaptics_set_advanced_gesture_mode(psmouse)) { 582 - psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); 583 - return -1; 572 + if (priv->absolute_mode) { 573 + error = synaptics_set_advanced_gesture_mode(psmouse); 574 + if (error) { 575 + psmouse_err(psmouse, 576 + "Advanced gesture mode init failed: %d\n", 577 + error); 578 + return error; 579 + } 584 580 } 585 581 586 582 return 0; ··· 612 598 static int synaptics_pt_write(struct serio *serio, unsigned char c) 613 599 { 614 600 struct psmouse *parent = serio_get_drvdata(serio->parent); 615 - char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ 601 + u8 rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ 602 + int error; 616 603 617 - if (psmouse_sliced_command(parent, c)) 618 - return -1; 619 - if (ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE)) 620 - return -1; 604 + error = psmouse_sliced_command(parent, c); 605 + if (error) 606 + return error; 607 + 608 + error = ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE); 609 + if (error) 610 + return error; 611 + 621 612 return 0; 622 613 } 623 614 ··· 1399 1380 } while (error && ++retry < 3); 1400 1381 1401 1382 if (error) 1402 - return -1; 1383 + return error; 1403 1384 1404 1385 if (retry > 1) 1405 1386 psmouse_dbg(psmouse, "reconnected after %d tries\n", retry); 1406 1387 1407 - if (synaptics_query_hardware(psmouse, &info)) { 1388 + error = synaptics_query_hardware(psmouse, &info); 1389 + if (error) { 1408 1390 psmouse_err(psmouse, "Unable to query device.\n"); 1409 - return -1; 1391 + return error; 1410 1392 } 1411 1393 1412 - if (synaptics_set_mode(psmouse)) { 1394 + error = synaptics_set_mode(psmouse); 1395 + if (error) { 1413 1396 psmouse_err(psmouse, "Unable to initialize device.\n"); 1414 - return -1; 1397 + return error; 1415 1398 } 1416 1399 1417 1400 if (info.identity != priv->info.identity || ··· 1426 1405 priv->info.model_id, info.model_id, 1427 1406 priv->info.capabilities, info.capabilities, 1428 1407 priv->info.ext_cap, info.ext_cap); 1429 - return -1; 1408 + return -ENXIO; 1430 1409 } 1431 1410 1432 1411 return 0;