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

Input: synaptics-rmi4 - simplify data read in rmi_f54_work

The body of the for loop is only ever run once as the second standard_report
element is never changed from its initial zero init, so the loop condition is
never satisfies after the first run. Equally the start member of the first
element is never changed from 0, so the index offset is always a constant 0.

Remove this needless obfuscation of the code and write it in a straight
forward manner.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Link: https://lore.kernel.org/r/20191104114454.10500-3-l.stach@pengutronix.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Lucas Stach and committed by
Dmitry Torokhov
d843304b 78713dfa

+16 -32
+16 -32
drivers/input/rmi4/rmi_f54.c
··· 81 81 = "Full Raw Capacitance RX Offset Removed", 82 82 }; 83 83 84 - struct rmi_f54_reports { 85 - int start; 86 - int size; 87 - }; 88 - 89 84 struct f54_data { 90 85 struct rmi_function *fn; 91 86 ··· 93 98 enum rmi_f54_report_type report_type; 94 99 u8 *report_data; 95 100 int report_size; 96 - struct rmi_f54_reports standard_report[2]; 97 101 98 102 bool is_busy; 99 103 struct mutex status_mutex; ··· 510 516 struct f54_data *f54 = container_of(work, struct f54_data, work.work); 511 517 struct rmi_function *fn = f54->fn; 512 518 u8 fifo[2]; 513 - struct rmi_f54_reports *report; 514 519 int report_size; 515 520 u8 command; 516 - u8 *data; 517 521 int error; 518 522 519 - data = f54->report_data; 520 523 report_size = rmi_f54_get_report_size(f54); 521 524 if (report_size == 0) { 522 525 dev_err(&fn->dev, "Bad report size, report type=%d\n", ··· 521 530 error = -EINVAL; 522 531 goto error; /* retry won't help */ 523 532 } 524 - f54->standard_report[0].size = report_size; 525 - report = f54->standard_report; 526 533 527 534 mutex_lock(&f54->data_mutex); 528 535 ··· 545 556 546 557 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Get report command completed, reading data\n"); 547 558 548 - report_size = 0; 549 - for (; report->size; report++) { 550 - fifo[0] = report->start & 0xff; 551 - fifo[1] = (report->start >> 8) & 0xff; 552 - error = rmi_write_block(fn->rmi_dev, 553 - fn->fd.data_base_addr + F54_FIFO_OFFSET, 554 - fifo, sizeof(fifo)); 555 - if (error) { 556 - dev_err(&fn->dev, "Failed to set fifo start offset\n"); 557 - goto abort; 558 - } 559 + fifo[0] = 0; 560 + fifo[1] = 0; 561 + error = rmi_write_block(fn->rmi_dev, 562 + fn->fd.data_base_addr + F54_FIFO_OFFSET, 563 + fifo, sizeof(fifo)); 564 + if (error) { 565 + dev_err(&fn->dev, "Failed to set fifo start offset\n"); 566 + goto abort; 567 + } 559 568 560 - error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr + 561 - F54_REPORT_DATA_OFFSET, data, 562 - report->size); 563 - if (error) { 564 - dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n", 565 - __func__, report->size, error); 566 - goto abort; 567 - } 568 - data += report->size; 569 - report_size += report->size; 569 + error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr + 570 + F54_REPORT_DATA_OFFSET, f54->report_data, 571 + report_size); 572 + if (error) { 573 + dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n", 574 + __func__, report_size, error); 575 + goto abort; 570 576 } 571 577 572 578 abort: