Skip to content

Commit d843304

Browse files
lynxeye-devdtor
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 78713df commit d843304

File tree

1 file changed

+16
-32
lines changed

1 file changed

+16
-32
lines changed

drivers/input/rmi4/rmi_f54.c

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ static const char * const rmi_f54_report_type_names[] = {
8181
= "Full Raw Capacitance RX Offset Removed",
8282
};
8383

84-
struct rmi_f54_reports {
85-
int start;
86-
int size;
87-
};
88-
8984
struct f54_data {
9085
struct rmi_function *fn;
9186

@@ -98,7 +93,6 @@ struct f54_data {
9893
enum rmi_f54_report_type report_type;
9994
u8 *report_data;
10095
int report_size;
101-
struct rmi_f54_reports standard_report[2];
10296

10397
bool is_busy;
10498
struct mutex status_mutex;
@@ -516,22 +510,17 @@ static void rmi_f54_work(struct work_struct *work)
516510
struct f54_data *f54 = container_of(work, struct f54_data, work.work);
517511
struct rmi_function *fn = f54->fn;
518512
u8 fifo[2];
519-
struct rmi_f54_reports *report;
520513
int report_size;
521514
u8 command;
522-
u8 *data;
523515
int error;
524516

525-
data = f54->report_data;
526517
report_size = rmi_f54_get_report_size(f54);
527518
if (report_size == 0) {
528519
dev_err(&fn->dev, "Bad report size, report type=%d\n",
529520
f54->report_type);
530521
error = -EINVAL;
531522
goto error; /* retry won't help */
532523
}
533-
f54->standard_report[0].size = report_size;
534-
report = f54->standard_report;
535524

536525
mutex_lock(&f54->data_mutex);
537526

@@ -556,28 +545,23 @@ static void rmi_f54_work(struct work_struct *work)
556545

557546
rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Get report command completed, reading data\n");
558547

559-
report_size = 0;
560-
for (; report->size; report++) {
561-
fifo[0] = report->start & 0xff;
562-
fifo[1] = (report->start >> 8) & 0xff;
563-
error = rmi_write_block(fn->rmi_dev,
564-
fn->fd.data_base_addr + F54_FIFO_OFFSET,
565-
fifo, sizeof(fifo));
566-
if (error) {
567-
dev_err(&fn->dev, "Failed to set fifo start offset\n");
568-
goto abort;
569-
}
548+
fifo[0] = 0;
549+
fifo[1] = 0;
550+
error = rmi_write_block(fn->rmi_dev,
551+
fn->fd.data_base_addr + F54_FIFO_OFFSET,
552+
fifo, sizeof(fifo));
553+
if (error) {
554+
dev_err(&fn->dev, "Failed to set fifo start offset\n");
555+
goto abort;
556+
}
570557

571-
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr +
572-
F54_REPORT_DATA_OFFSET, data,
573-
report->size);
574-
if (error) {
575-
dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n",
576-
__func__, report->size, error);
577-
goto abort;
578-
}
579-
data += report->size;
580-
report_size += report->size;
558+
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr +
559+
F54_REPORT_DATA_OFFSET, f54->report_data,
560+
report_size);
561+
if (error) {
562+
dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n",
563+
__func__, report_size, error);
564+
goto abort;
581565
}
582566

583567
abort:

0 commit comments

Comments
 (0)