@@ -75,6 +75,13 @@ static const struct da906x_chip_config da9062_regs = {
.name = "da9062-onkey",
};
+static void da9063_onkey_report_key(struct da9063_onkey *onkey,
+ unsigned int code, int value)
+{
+ input_report_key(onkey->input, code, value);
+ input_sync(onkey->input);
+}
+
static void da9063_poll_on(struct work_struct *work)
{
struct da9063_onkey *onkey = container_of(work,
@@ -87,12 +94,9 @@ static void da9063_poll_on(struct work_struct *work)
int error;
/* Poll to see when the pin is released */
- error = regmap_read(onkey->regmap,
- config->onkey_status,
- &val);
+ error = regmap_read(onkey->regmap, config->onkey_status, &val);
if (error) {
- dev_err(onkey->dev,
- "Failed to read ON status: %d\n", error);
+ dev_err(onkey->dev, "Failed to read ON status: %d\n", error);
goto err_poll;
}
@@ -107,8 +111,7 @@ static void da9063_poll_on(struct work_struct *work)
goto err_poll;
}
- input_report_key(onkey->input, KEY_POWER, 0);
- input_sync(onkey->input);
+ da9063_onkey_report_key(onkey, KEY_POWER, 0);
poll = false;
}
@@ -159,19 +162,13 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
unsigned int val;
int error;
- error = regmap_read(onkey->regmap,
- config->onkey_status,
- &val);
+ error = regmap_read(onkey->regmap, config->onkey_status, &val);
+ da9063_onkey_report_key(onkey, KEY_POWER, 1);
if (onkey->key_power && !error && (val & config->onkey_nonkey_mask)) {
- input_report_key(onkey->input, KEY_POWER, 1);
- input_sync(onkey->input);
schedule_delayed_work(&onkey->work, 0);
dev_dbg(onkey->dev, "KEY_POWER long press.\n");
} else {
- input_report_key(onkey->input, KEY_POWER, 1);
- input_sync(onkey->input);
- input_report_key(onkey->input, KEY_POWER, 0);
- input_sync(onkey->input);
+ da9063_onkey_report_key(onkey, KEY_POWER, 0);
dev_dbg(onkey->dev, "KEY_POWER short press.\n");
}
Adding da9063_onkey_report_key() for reporting key events makes the code simpler. So, simplify it. While at it, update multiline code that can fit to single line. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> --- v3: * New patch. --- drivers/input/misc/da9063_onkey.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)