Skip to content

Commit f4ee52f

Browse files
Marco Felschdtor
authored andcommitted
Input: edt-ft5x06 - move parameter restore into helper
We need to restore the parameters if we switch between the factory/work mode and during the resume process if we switched off the power-supply. Therefore refactor edt_ft5x06_work_mode() and move the "restore the parameters" into a helper routine so we can reuse it later. Signed-off-by: Marco Felsch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 255cdaf commit f4ee52f

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,29 @@ static const struct attribute_group edt_ft5x06_attr_group = {
527527
.attrs = edt_ft5x06_attrs,
528528
};
529529

530+
static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata)
531+
{
532+
struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
533+
534+
edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
535+
tsdata->threshold);
536+
edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
537+
tsdata->gain);
538+
if (reg_addr->reg_offset != NO_REGISTER)
539+
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
540+
tsdata->offset);
541+
if (reg_addr->reg_offset_x != NO_REGISTER)
542+
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x,
543+
tsdata->offset_x);
544+
if (reg_addr->reg_offset_y != NO_REGISTER)
545+
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y,
546+
tsdata->offset_y);
547+
if (reg_addr->reg_report_rate != NO_REGISTER)
548+
edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
549+
tsdata->report_rate);
550+
551+
}
552+
530553
#ifdef CONFIG_DEBUG_FS
531554
static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
532555
{
@@ -592,7 +615,6 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
592615
{
593616
struct i2c_client *client = tsdata->client;
594617
int retries = EDT_SWITCH_MODE_RETRIES;
595-
struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
596618
int ret;
597619
int error;
598620

@@ -624,24 +646,7 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
624646
kfree(tsdata->raw_buffer);
625647
tsdata->raw_buffer = NULL;
626648

627-
/* restore parameters */
628-
edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
629-
tsdata->threshold);
630-
edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
631-
tsdata->gain);
632-
if (reg_addr->reg_offset != NO_REGISTER)
633-
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
634-
tsdata->offset);
635-
if (reg_addr->reg_offset_x != NO_REGISTER)
636-
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x,
637-
tsdata->offset_x);
638-
if (reg_addr->reg_offset_y != NO_REGISTER)
639-
edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y,
640-
tsdata->offset_y);
641-
if (reg_addr->reg_report_rate != NO_REGISTER)
642-
edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
643-
tsdata->report_rate);
644-
649+
edt_ft5x06_restore_reg_parameters(tsdata);
645650
enable_irq(client->irq);
646651

647652
return 0;

0 commit comments

Comments
 (0)